Mongodb:cursor not found on server

Source: Internet
Author: User
Tags mongodb collection

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.