[JAVA-790] Wrong type for option 'unique' in GridFS constructor Created: 22/Mar/13 Updated: 31/Mar/15 Resolved: 22/Aug/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | GridFS |
| Affects Version/s: | 2.10.1 |
| Fix Version/s: | 2.11.3, 3.0.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Rainer Reich | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
using mongodb-linux-x86_64-2.4.0 |
||
| Issue Links: |
|
||||||||
| Description |
|
In the ctor of GridFS the following call on DBCollection#ensureIndex sets a wrong value respectively the wrong type for option "unique", so that the index will not be found even if it exists:
The correct value would be true instead of 1:
|
| Comments |
| Comment by Jeffrey Yemin [ 31/Mar/15 ] |
|
Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released. |
| Comment by auto [ 12/Sep/13 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: to {unique : true}Branch: 2.11.x |
| Comment by auto [ 22/Aug/13 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: to {unique : true}Branch: master |
| Comment by auto [ 17/Aug/13 ] |
|
Author: {u'username': u'trnl', u'name': u'Uladzimir Mihura', u'email': u'trnl.me@gmail.com'}Message: fix(driver-compat) |
| Comment by Uladzimir Mihura [ 17/Aug/13 ] |
|
So ok, it fixes a problem already. I'll update 3.x code. -vova |
| Comment by Jeffrey Yemin [ 17/Aug/13 ] |
|
In 2.11.2, the ensureIndex calls were put in a try-catch. See |
| Comment by Sébastien Vauclair [ 10/Apr/13 ] |
|
We encountered the same problem, for a slightly different reason: some of our servers are configured to access Mongo using a readonly user, which is therefore not allowed to create any index. We will use the same temporary workaround DB#setReadOnly() until a fix is released. |
| Comment by Jeffrey Yemin [ 22/Mar/13 ] |
|
OK, I see. I can fix this in master and push a snapshot release to sonatype, but we don't have plans yet for another release (unless a major bug is found in 2.11.0). Would you use a snapshot release? |
| Comment by Rainer Reich [ 22/Mar/13 ] |
|
I don't know if it's a performance issue. We have a pretty special setup, where we connect to a single Mongo node, not to a replica set. The problem is, that Mongo then tries to create an index and complains that it's not connected to the primary. Our temporary workaround is to use DB#setReadOnly() which prevents DBCollection#ensureIndex() from doing anything. |
| Comment by Jeffrey Yemin [ 22/Mar/13 ] |
|
Are you noticing any performance degradation as a result of this? Note that the server will still ignore the index creation once it's been created the first time. |
| Comment by Rainer Reich [ 22/Mar/13 ] |
|
Well, ensureIndex ends up calling DBApiLayer#createIndex(...). There idxs.findOne(full) returns null, because it does not find any document where key unique has the value 1, because the value is really true. )' won't return anything, but )' will return the index |
| Comment by Jeffrey Yemin [ 22/Mar/13 ] |
|
I'm not sure what you mean. Why won't it be found? |