[JAVA-556] Wrong exception on too large query when Mongo object is not reused Created: 20/Apr/12 Updated: 31/Mar/15 Resolved: 25/Jun/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Cluster Management |
| Affects Version/s: | 2.7.2 |
| Fix Version/s: | 3.0.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Kay Agahd | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux 64 Bit |
||
| Description |
|
I'm using the Java driver v2.7.2 to query a sharded system consisting of 4 shards, each 3 replicas, running linux-mongodb-v2.0.1, v2.0.2 and v2.0.4. All mongos are running v2.0.1. The query I'm executing is of this type: When the inlist becomes too big (more than 265,000 id's in my case), I get the following exception, where max BSON size is greater than 2.6 times of the DBObject size: Exception in thread "main" com.mongodb.MongoInternalException: When I reuse the mongo object, I don't get the exception. Moreover, I can put up to 995,000 id's into the list without any problem. Exception in thread "main" com.mongodb.MongoException: could not However, when it's the first usage of the Mongo object then it's not yet reused and will fail as described above. For more details, please see: |
| 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 Jeffrey Yemin [ 25/Jun/13 ] |
|
See https://github.com/jyemin/mongo-java-driver/commit/fa0880c#L30R89 |
| Comment by Jeffrey Yemin [ 20/Apr/12 ] |
|
Ah, I mis-read the code. The first call is to Mongo.getConnector().getMaxBsonObjectSize(), while the second is to Mongo.getMaxBsonObjectSize(), which actually tries to fetch the value from the server. |
| Comment by Kay Agahd [ 20/Apr/12 ] |
|
Yes, I can reproduce it at any time. The size of the DBObject in the error message may vary though as for example here: Exception in thread "main" com.mongodb.MongoInternalException: DBObject of size 4208915 is over Max BSON size 16777216 > Am I correct that you're connecting to a replica set (by giving a list of seed servers)? No, I'm connecting to one mongos like this: |
| Comment by Jeffrey Yemin [ 20/Apr/12 ] |
|
Is this reproducible always? It looks like a race condition. What's happening is that Mongo.getMaxBsonObjectSize() will return 4MB when the Mongo instance is first created, since that was the default prior to 1.8.0. When using a replica set, the value is updated by a background thread. When running without a replica set, it's updated the first time the driver needs to find the primary/master. Am I correct that you're connecting to a replica set (by giving a list of seed servers)? A possible workaround for you, until we can fix this, is to create the Mongo instance and then sleep in a loop until Mongo.getMaxBsonObjectSize() returns 16MB. The confusing log message is just a symptom. Mongo.getMaxBsonObjectSize() is called again when constructing the exception, and by the time the second call is made, the value has been updated to 16MB. |