我不断从我的 java mongodb 客户端收到以下异常:
原因:com.mongodb.MongoCursorNotFoundException:查询失败,错误代码 -5 和错误消息'Cursor 105639140478 not found on server1:27017' on server1:27017
代码如下:
MongoCollection<Document> db = (bunch of code to load up one of these objects)
FindIterable<Document> cur = db.find().projection(desiredFields).noCursorTimeout(true);
MongoCursor<Document> cursor = cur.iterator();
while(cursor.hasNext()) {
Document o = cursor.next();
doStuff(o);
}
我已经设置了 noCursorTimeout,但我仍然遇到异常。它在超时之前处理了大约 110,000 条记录,因此它显然能够进行某种工作(否则它不会处理任何记录),但同时它也不能正常工作,因为我希望它不会在之后超时专门设置 noCursorTimeout(true)。