[JAVA-525] make it possible to override _id for GridFS file Created: 23/Feb/12  Updated: 18/Jun/12  Resolved: 18/Apr/12

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 2.8.0

Type: Improvement Priority: Major - P3
Reporter: Antoine Girbal Assignee: Jeffrey Yemin
Resolution: Done Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

This is needed for proper sharding support.
Right now it's hardcoded to use an ObjectId which means it's ever growing and hits the same shard.

Also it would allow to have a unique constraint on filename, if it's used as _id.



 Comments   
Comment by Jeffrey Yemin [ 18/Jun/12 ]

Closing for 2.8.0 release.

Comment by Jeffrey Yemin [ 18/Apr/12 ]

Added com.mongodb.gridfs.GridFSInputFile#setId method.

Comment by auto [ 18/Apr/12 ]

Author:

{u'login': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-525: Removed setting of write concern to allow clients to set it as appropriate
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/97020aac0054f598c5b8f9ace36d840913fe9ce1

Comment by auto [ 17/Apr/12 ]

Author:

{u'login': u'dgottlieb', u'name': u'Daniel Gottlieb', u'email': u'daniel.gottlieb@10gen.com'}

Message: JAVA-525: Move WriteConcern options to GridFS instantiation. Adding GridFS Chunks sounds like a bad idea if the GridFS file object failed to upsert properly
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/34ac92995a3ed6fd78574e6a48687a31923dddf6

Comment by auto [ 17/Apr/12 ]

Author:

{u'login': u'dgottlieb', u'name': u'Daniel Gottlieb', u'email': u'daniel.gottlieb@10gen.com'}

Message: JAVA-525: Allow users to override the _id field for GridFSFiles
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/e36aea594eca54873d28b371f43f5f8f56b4fea5

Comment by Mrityunjay Kant [ 17/Apr/12 ]

Agreed, this is a required feature to prevent sharding hot spots; it's a cause of concern for us as we speculate on using GridFS as a file store. Also, can we create a bug for Casbah to include this change?

Comment by Scott Hernandez (Inactive) [ 22/Mar/12 ]

Mark, we will be fixing sharding to support the

{files_id:1, n:1}

shard key (via the filemd5 command) in the future which will help for 2.2, but this might help in the meantime, and until people can upgrade their servers.

Comment by Mark [ 22/Mar/12 ]

I highly recommend this fix. Sharding creates a hotspot otherwise.

Comment by Scott Hernandez (Inactive) [ 27/Feb/12 ]

There are reasons you might want to use a custom files_id which isn't an ObjectId independent of the shard/hash issue.

Generated at Thu Feb 08 08:52:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.