vsivsi / meteor-file-collection

Extends Meteor Collections to handle file data using MongoDB gridFS.
http://atmospherejs.com/vsivsi/file-collection
Other
159 stars 37 forks source link

MongoDB 3.2 support? #95

Open snajjar opened 8 years ago

snajjar commented 8 years ago

Hello,

We've migrated our code from collectionFS to file-collection. While it works well in local, we can't get this to work in production:

ERR /home/vcap/app/.bluemix/app/programs/server/node_modules/fibers/future.js:278
ERR                         throw(ex);
ERR                               ^
ERR MongoError: driver is incompatible with this server version
ERR     at Object.Future.wait (/home/vcap/app/.bluemix/app/programs/server/node_modules/fibers/future.js:398:15)
ERR     at [object Object].MongoConnection._ensureIndex (packages/mongo/mongo_driver.js:790:1)
ERR     at FileCollection.Mongo.Collection._ensureIndex (packages/mongo/collection.js:635:1)
ERR     at new FileCollection (packages/vsivsi_file-collection/src/gridFS_server.coffee:68:15)

Local version is MongoDB 2.6.7, production version is 3.2.1 (at Compose.io).

Is the integration of Mongo 3 into file-collection planned?

vsivsi commented 8 years ago

Hi, thanks for reporting this.

file-collection itself uses the most up-to-date node.js mongodb driver (currently version 2.1.11) internally. In that respect it should already be fully compatible with Mongo 3.2. Unfortunately Meteor itself is stuck on the node.js mongodb driver version 1.4.x, which appears to be the source of this incompatibility.

See: https://docs.mongodb.org/ecosystem/drivers/driver-compatibility-reference/#reference-compatibility-mongodb-node

And: https://github.com/vsivsi/meteor-file-collection/issues/35#issuecomment-86790587

Because file-collection uses its own up-to-date mongodb driver internally, it should be straightforward for me to switch those indexing calls to use the newer driver rather than falling back to the Meteor driver. However, I expect there may be other issues lurking...

Because it looks like Meteor Collections themselves are incompatible with at least some aspects of MongoDB 3.2 (e.g. indexing). That fact may cause you other problems in the end.

I will try the "quick fix" to this immediate issue this afternoon and commit it to a branch for you to test with your setup. But until MDG updates Meteor itself to the node.js mongodb 2.1.x driver, I predict there will continue to be other issues using MongoDB 3.2

vsivsi commented 8 years ago

Please try the code on this branch with your MongoDB 3.2 provider and let me know how it goes.

https://github.com/vsivsi/meteor-file-collection/tree/mongo32_test

vsivsi commented 8 years ago

See also: https://github.com/meteor/meteor/issues/5809

vsivsi commented 8 years ago

And: https://github.com/meteor/meteor/issues/5763

snajjar commented 8 years ago

Hello @vsivsi. First of all, thanks for the awesome package, and thank you for the quick reaction! This is really appreciated :)

I've dug a little bit more into this, and it seems that you are right: the issue is indeed in Meteor itself.

I actually have a version of Meteor+CollectionFS that is running on a MongoDB 3.2.1! How is this possible? Maybe i'm using settings that don't break it?

Because file-collection uses its own up-to-date mongodb driver internally, it should be straightforward for me to switch those indexing calls to use the newer driver rather than falling back to the Meteor driver. However, I expect there may be other issues lurking...

I understand, but i really wouldn't recommand it. file-collection is a simple but great package and should rely on Meteor stability (this is twice as important today, as CollectionFS support has been dropped - or is in a unclear situation today - and i believe many Meteor user will switch over this package in the near future). For my own issue, i reverted to the previous version of Mongo, needed it to work.

Please let me know if you're still interested in testing with mongo32_test (it will take me some time to deploy this configuration again). I think the issue can be closed otherwise :)

vsivsi commented 8 years ago

I actually have a version of Meteor+CollectionFS that is running on a MongoDB 3.2.1! How is this possible? Maybe i'm using settings that don't break it?

CollectionFS probably doesn't create any indexes. That's the only call that seems to be dying in file-collection because I used the Meteor DB object/connection instead of my own. That's what I fixed on the test branch.

Yes, please do test it if you can. This change is arguably the right way to do it in any case given that the code already maintains its own driver and connection to the DB.

vsivsi commented 8 years ago

FYI, I published this indexing fix in FC version 1.3.3, so at least that error shouldn't crop-up again.

snajjar commented 8 years ago

Hello @vsivsi,

I'm sorry, i took some time to be available for testing. I tried to test the mongo32_test branch, but it seems that it needs to be updated to the new meteor 1.3.1 (at least, it'll simplify the test for me, since we updated the whole project).

Can you merge the current branch into meteor32_test? ty

vsivsi commented 8 years ago

Sure, I just did that. mongo32_test is now merged into the dev branch, which is currently two commits beyond the 1.3.3 release.