Query MongoDB Collection Data update, the data is more than 400w. I use the cursor (cursor) to fetch 1w at a time, handling the update. An exception occurred while the program was traversing a cursor during a certain period of time running! dbcursor cursor = tabcoll.find (queryobj). Skip (StartRow). Limit (pageSize);
Complete exception information:
Com.mongodb.mongoexception$cursornotfound:cursor not found on server
At Com.mongodb.dbapilayer$result.init (dbapilayer.java:379)
At Com.mongodb.dbapilayer$result._advance (dbapilayer.java:426)
At Com.mongodb.dbapilayer$result.hasnext (dbapilayer.java:408)
At Com.mongodb.dbcursor._hasnext (dbcursor.java:495)
At Com.mongodb.DBCursor.hasNext (dbcursor.java:515)
At Com.bsdwwd.boss.util.deal.UpdateTUserMongoByInfo.deal (updatetusermongobyinfo.java:106)
At Com.bsdwwd.boss.util.deal.UpdateTUserMongoByInfo.detailDeal (updatetusermongobyinfo.java:53)
At Com.bsdwwd.boss.util.process.AbstractProcess.run (abstractprocess.java:181)
At Java.lang.Thread.run (thread.java:662)
The reason is that the cursor object retrieved by default has a time limit, after which time the cursor is gone (I guess it should be recycled by MongoDB daemon)
Workaround:after you get to the cursor object, set thecursor.addoption (bytes.queryoption_notimeout)///default cursor open with time limit set to no time limit Note:after the cursor is used, be sure to close (the cursor is the last, canonical operation). What a weird mistake it's going to happen!
Mongodb:cursor not found on server