I have written a console application that connects directly to Mongo and Traverses the entire DB to perform updates.
For some reason I get the same error every time on itteration 2288 (See stack trace below)
I have inspected the record via MongoVue and it appears OK and consistent with the rest.
I tried to add some try catch logic to see if its related to the specific record being deserialized however the itteration dies after the error is thrown.
Below is a cross section of the console output and the source.
Could this be related to a connection timeout or finite Cursor lifetime?
In other attempts to troubleshoot
I have
- Changed the code from a Linq Statement to a Enumerator and added try catch.
- Looked around for where to apply this reference I found elsewhere in stack overflow? // cursor.SetFlags(QueryFlags.NoCursorTimeout);??
- updated mongo db to version 2.4.9
- upgraded to version 1.8.3.9 of the c# driver.
Any help will be appreciated
Processing document #2276 4fd07744e178a26bac456911
Processing document #2277 4fd0774ae178a26bac45691d
Processing document #2278 4fd0775ae178a26bac456933
Processing document #2279 4fd0775de178a26bac45693a
Processing document #2280 4fd07764e178a26bac456944
Processing document #2281 4fd07767e178a26bac456947
Processing document #2282 4fd0776ae178a26bac45694d
Processing document #2283 4fd07770e178a26bac456959
Processing document #2284 4fd07774e178a26bac45695c
Processing document #2285 4fd07777e178a26bac456962
Processing document #2286 4fd07779e178a26bac456965
Processing document #2287 4fd07783e178a26bac45697b
Processing document #2288 4fd07786e178a26bac45697e
Cursor not found. at MongoDB.Driver.Internal.MongoReplyMessage`1.ReadFrom(Bso
nBuffer buffer, IBsonSerializationOptions serializationOptions)
at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBina
ryReaderSettings readerSettings, IBsonSerializer serializer, IBsonSerializationO
ptions serializationOptions)
at MongoDB.Driver.Operations.QueryOperation`1.GetNextBatch(IConnectionProvide
r connectionProvider, Int64 cursorId)
at MongoDB.Driver.Operations.QueryOperation`1.<Execute>d__0.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at ZeroPaper.OCR.Console.OCRConsole.Main(String[] args)
Processing document #2289 4fd07786e178a26bac45697e
using (MongoDocumentProvider mdp = new MongoDocumentProvider())
{
using (DocumentSecurityDisabler dsd = new DocumentSecurityDisabler())
{
int currentIndex = 0;
int counter = 0;
var docs = mdp.GetDocumentList(true);
var enumerate = docs.GetEnumerator();
bool traverse = true;
while(traverse)
{
try
{
if (enumerate.Current != null)
{
System.Console.WriteLine("Processing document #" + currentIndex + " " + enumerate.Current.OID);
enumerate.Current.Name = enumerate.Current.GetRegexName();
mdp.SaveDocument(enumerate.Current);
}
traverse = enumerate.MoveNext();
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message + " " + ex.StackTrace);
}
currentIndex++;
if (currentIndex > 999999) { traverse = false; };
}
}
}