[JAVA-340] Getting MongoInternalException "can't do getmore" while working on data > 10,000. Dont get the exception when working with lesser amounts of data Created: 29/Apr/11  Updated: 11/Sep/19  Resolved: 14/Jun/11

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

Type: Task Priority: Major - P3
Reporter: Nivi Kumar Assignee: Unassigned
Resolution: Done Votes: 0
Labels: cursor
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends

 Description   

DBCursor usersiteResult =
usersiteCollection.find( userSiteConditionObj );

try
{

while ( usersiteResult.hasNext() )

{ //Do operation }

catch(MongoInternalException e){
}



 Comments   
Comment by Antoine Girbal [ 13/May/11 ]

Hi Nivi,
let me know if this makes sense and I can close ticket.
thx

Comment by Antoine Girbal [ 09/May/11 ]

Nivi,
the likely issue as Eliot pointed out is that the cursor is timed out on the server.
This may happen if one of the batches takes more than 10min to process from the client side.
As such, using a smaller batch size should help, since the time between queries to mongod is smaller.
To test if that is the issue, you can set Bytes.QUERYOPTION_NOTIMEOUT as a query option and see if you can process all records.

Comment by Eliot Horowitz (Inactive) [ 08/May/11 ]

The most likely cause is a timed out cursor.
Are you doing a lot of client side work on these object or just iterating fast?
If you're doing client side work, you should make the batch size smaller (100 maybe) and see if that alleviates it.

Comment by Nivi Kumar [ 06/May/11 ]

Sorry about responding late. Since we are in run the business mode with this application, it takes a while to debug and respond.

I am not sure how many records it iterates through before throwing a response. However if I try to get through 10,000 records, it completes around 4000.
After I used 2.5.3 driver, I did not see the exception any more however it was still not processing all the records.
I then tried setting the batch size to 500 and then running it. By doing this, it seems like it is processing almost all the records . However it is taking a lot of time to do so. Is this a side effect of using batch size? If it took 100,000 records an hour or two before , now it is taking around 4-5 hours.

Comment by Antoine Girbal [ 03/May/11 ]

questions:

  • how many docs do you iterate through before you get exception?
  • how long does it take from the time you do find() to the time you get exception (e.g. 2min)?
  • can you run the exact same query in shell and iterate through docs, see if you get error too (do a find(...).forEach(...))
  • in shell, run same command and add .explain() at the end to get information.

One possible issue is that mongod needs to "scan and order" which has limitations in terms of how many records may be returned.
thanks

Comment by Nivi Kumar [ 02/May/11 ]

I tried with the 2.5.3 driver and I get this exception now

cursor not found on server

More info on what the application is trying to do.
I am trying to iterate through 5000 records. These 5000 records are obtained from another collection. Each record has a network location name. The application then reads the files in that location and stores relevant information in another collection. I used to run the same for over 100000 records and have not faced this issue before.

Comment by Nivi Kumar [ 02/May/11 ]

Thanks Antoine.

I currently don't have stack trace enabled in prod. This is the message in
log. I will try and run in test to get the full stack trace .

As for the driver , we are using mongo-2.0.jar. I will test with the latest
driver and get back to you.

Cheers
nivi

Comment by Antoine Girbal [ 02/May/11 ]

Hi Nivi,

  • could you give the exact exception you are getting, including possible stack trace.
  • what driver version are you using? If older than 2.5.3, is it possible for you to test with latest driver in testing environment?
    thanks
Comment by Nivi Kumar [ 02/May/11 ]

Any suggestions to overcome this issue?

Comment by Nivi Kumar [ 30/Apr/11 ]

usersitecondition obj is the query object user to query the user site collection.

DBObject userSiteRecordsCondition =
new BasicDBObject( MONGO_OPERATION_GTE, minUsrRecords );
userSiteRecordsCondition.put( MONGO_OPERATION_LTE, maxUsrRecords );

userSiteConditionObj.put( MongoDBCollectionFieldKeys.KEY_COUNTER_ID,
userSiteRecordsCondition );

The query is to get all records in the user site collection based on the minimum and maximum counter id that the user specifies. If min is 10 and max is 100, the query would get all the 90 records and iterate over it. For 10000 or less records it seems to be fine . However when it is more than that it throws the "cant get more exception"

Comment by Eliot Horowitz (Inactive) [ 30/Apr/11 ]

What are the contents of userSiteConditionObj

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