stripe-archive / mosql

MongoDB → PostgreSQL streaming replication
MIT License
1.63k stars 225 forks source link

Bug in version on master? #56

Closed AndreaCrotti closed 10 years ago

AndreaCrotti commented 10 years ago

Hi everyone again, I wanted to use the fix done for the date and milliseconds so I installed mosql from github using this command:

gem specific_install -l https://github.com/stripe/mosql

After I do that and try to run it again however I get the following error. Is that something wrong I've done or a bug? Thanks

D, [2014-08-22T12:26:39.830805 #13367] DEBUG -- : (0.001841s) SET standard_conforming_strings = ON
D, [2014-08-22T12:26:39.832235 #13367] DEBUG -- : (0.001114s) SET client_min_messages = 'WARNING'
D, [2014-08-22T12:26:39.833352 #13367] DEBUG -- : (0.000774s) SET DateStyle = 'ISO'
D, [2014-08-22T12:26:39.838507 #13367] DEBUG -- : (0.003212s) CREATE TABLE IF NOT EXISTS "mosql_tailers" ("service" TEXT, "timestamp" INTEGER, PRIMARY KEY ("service"))
D, [2014-08-22T12:26:39.844902 #13367] DEBUG -- : (0.005652s) SELECT ("timestamp") FROM "mosql_tailers" WHERE ("service" = 'mosql') LIMIT 1
 INFO MoSQL: Creating table 'dp_comments_comment'...
E, [2014-08-22T12:26:39.847054 #13367] ERROR -- : PG::SyntaxError: ERROR:  syntax error at or near "NULL"
LINE 1: ...INT, "product_id" INT, "date" TIMESTAMP, PRIMARY KEY (NULL))
                                                                 ^: CREATE TABLE IF NOT EXISTS "dp_comments_comment" ("text" TEXT, "status" TEXT, "author_id" INT, "product_id" INT, "date" TIMESTAMP, PRIMARY KEY (NULL))
/var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:161:in `async_exec': PG::SyntaxError: ERROR:  syntax error at or near "NULL" (Sequel::DatabaseError)
LINE 1: ...INT, "product_id" INT, "date" TIMESTAMP, PRIMARY KEY (NULL))
                                                                 ^
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:161:in `block in execute_query'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/database/logging.rb:37:in `log_yield'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:161:in `execute_query'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:148:in `block in execute'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:124:in `check_disconnect_errors'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:148:in `execute'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:492:in `_execute'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:316:in `block (2 levels) in execute'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:513:in `check_database_errors'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:316:in `block in execute'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/database/connecting.rb:250:in `block in synchronize'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/connection_pool/threaded.rb:104:in `hold'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/database/connecting.rb:250:in `synchronize'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/adapters/postgres.rb:316:in `execute'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/database/query.rb:50:in `execute_dui'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/database/query.rb:43:in `execute_ddl'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/database/schema_methods.rb:632:in `create_table_from_generator'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/database/schema_methods.rb:188:in `create_table'
    from /var/lib/gems/2.0.0/gems/sequel-4.13.0/lib/sequel/database/schema_methods.rb:212:in `create_table?'
    from /var/lib/gems/2.0.0/gems/mosql-0.3.2/lib/mosql/schema.rb:83:in `block (2 levels) in create_schema'
    from /var/lib/gems/2.0.0/gems/mosql-0.3.2/lib/mosql/schema.rb:77:in `each'
    from /var/lib/gems/2.0.0/gems/mosql-0.3.2/lib/mosql/schema.rb:77:in `block in create_schema'
    from /var/lib/gems/2.0.0/gems/mosql-0.3.2/lib/mosql/schema.rb:76:in `each'
    from /var/lib/gems/2.0.0/gems/mosql-0.3.2/lib/mosql/schema.rb:76:in `create_schema'
    from /var/lib/gems/2.0.0/gems/mosql-0.3.2/lib/mosql/streamer.rb:90:in `initial_import'
    from /var/lib/gems/2.0.0/gems/mosql-0.3.2/lib/mosql/streamer.rb:28:in `import'
    from /var/lib/gems/2.0.0/gems/mosql-0.3.2/lib/mosql/cli.rb:162:in `run'
    from /var/lib/gems/2.0.0/gems/mosql-0.3.2/lib/mosql/cli.rb:16:in `run'
    from /var/lib/gems/2.0.0/gems/mosql-0.3.2/bin/mosql:5:in `<top (required)>'
    from /usr/local/bin/mosql:23:in `load'
    from /usr/local/bin/mosql:23:in `<main>'
nelhage commented 10 years ago

Hm, I think this is from the new version failing earlier because your mapping doesn't have _id mapped (as I mentioned in #57). We should make this error out better, but MoSQL really isn't going to work for you unless you map in _id, unfortunately

AndreaCrotti commented 10 years ago

Ah ok, the older version worked anyway, so that became a requirement in master then?

I think maybe adding some validation of the YAML before running the SQL and get a syntax error would be already good, thanks!