mozilla-services / syncserver

Run-Your-Own Firefox Sync Server
Mozilla Public License 2.0
1.87k stars 145 forks source link

Postgres - Table bso fails at initialisation #12

Closed nsteinmetz closed 10 years ago

nsteinmetz commented 10 years ago

Hi, With PGSQL 9.3.4, when running "local/bin/gunicorn_paster syncserver.ini", I got:

File "/srv/datadisk01/home/web/steinmetz.fr/tools/syncserver/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 388, in do_execute cursor.execute(statement, parameters) ProgrammingError: (ProgrammingError) type modifier is not allowed for type "text" LINE 8: payload TEXT(262144) DEFAULT '' NOT NULL, ^ "\nCREATE TABLE bso (\n\tuserid INTEGER NOT NULL, \n\tcollection INTEGER NOT NULL, \n\tid VARCHAR(64) NOT NULL, \n\tsortindex INTEGER, \n\tmodified BIGINT NOT NULL, \n\tpayload TEXT(262144) DEFAULT '' NOT NULL, \n\tpayload_size INTEGER DEFAULT 0 NOT NULL, \n\tttl INTEGER DEFAULT 2100000000, \n\tPRIMARY KEY (userid, collection, id)\n)\n\n" {} 2014-04-10 21:45:10 [19344] [INFO] Worker exiting (pid: 19344) 2014-04-10 21:45:10 [19338] [INFO] Shutting down: Master 2014-04-10 21:45:10 [19338] [INFO] Reason: Worker failed to boot.

What I have so far in my schema:

[admin@steinmetz syncserver]$ psql -U mozfxsync -d mozfxsync Password for user mozfxsync: psql (9.3.4) Type "help" for help.. mozfxsync=> \dt public | collections | table | mozfxsync public | user_collections | table | mozfxsync

Seems lynked with this line : https://github.com/mozilla-services/server-syncstorage/blob/master/syncstorage/storage/sql/dbconnect.py#L107

And maybe latest commit : https://github.com/mozilla-services/server-syncstorage/commit/97fd39391aab21f9499fd82f6c5ec77609404156 ?

Hope it helps, Nicolas

nsteinmetz commented 10 years ago

Hmm looking as SQLAlchemy doc : http://docs.sqlalchemy.org/en/rel_0_9/core/types.html#sqlalchemy.types.Text :

''' In general, TEXT objects do not have a length; while some databases will accept a length argument here, it will be rejected by others. ''' Googling would show that Postgres would not accept a length.

Thus, you may need to do something like http://docs.sqlalchemy.org/en/rel_0_9/core/types.html#sqlalchemy.types.TypeDecorator.with_variant

which would lead to something like (options to be adjusted) and as far as I understand it:

Column("payload", Text(length=256*1024), nullable=False, server_default="").with_variant(postgresql.TEXT(nullable=False, server_default=""), 'postgresql'),

nsteinmetz commented 10 years ago

Here we are : https://github.com/mozilla-services/server-syncstorage/pull/18 :)

rfk commented 10 years ago

Great, thanks!! I''ll try to give it a proper try-out in the next day or so, if I can find the time during pycon.

nsteinmetz commented 10 years ago

You're welcome, no urgence and happy pycon !

nsteinmetz commented 10 years ago

@rfk any chance to review my PR ? ;-)

rfk commented 10 years ago

I finally got around to merging that PR