Fix com.mongodb.mongoexception$cursornotfound:cursor 0 not found on server

Source: Internet
Author: User

Background

It is often necessary to execute scripts to call Java programs to read the data in MongoDB, which would have been a simple task of switching to a background process and occasionally looking at logs. Today the Discovery program throws an exception "Com.mongodb.mongoexception$cursornotfound:cursor 0 not found on server". I didn't care at first, re-execution can continue to run, but after a while to throw the same mistake, it seems to fight.

Analysis

On Mogondb.org's official website, I found the same problem, a problem that was discovered and solved in 2013 years, and the official responded to the bug, and it was resolved in the version (2.11.0 release). The exception is because the cursor timed out .

exception: Perhaps in the operation involving Oplog, or there will be problems, please refer to: https://jira.mongodb.org/browse/JAVA-771

Solve
    • Scenario 1: Update the MongoDB class library to 2.11.0 above.

    • Scenario 2: If we cannot update the MOGONDB class library, it can also be resolved by setting the timeout parameter, as follows:

      Cursor.addoption (Com.mongodb.Bytes.QUERYOPTION_NOTIMEOUT);
Reference

Cursor not found on server:https://jira.mongodb.org/browse/java-907

Repeated cursornotfound exceptions on long-running process following oplog:https://jira.mongodb.org/browse/java-771

Fix com.mongodb.mongoexception$cursornotfound:cursor 0 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.