-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.4.7, 3.0.2
-
Component/s: Querying
-
None
-
ALL
-
Using a tailable cursor on a capped collection leads to memory leak in the server if the first cursor MoveNext does not get a record.
BsonValue lastId = collection.FindAll().SetSortOrder(SortBy.Descending("_id")).SetLimit(1).First()["_id"]; cursor = collection.Find(Query.GT("_id", lastId)) .SetFlags(QueryFlags.AwaitData | QueryFlags.TailableCursor | QueryFlags.NoCursorTimeout); using (var enumerator = new MongoCursorEnumerator<BsonDocument>(cursor)) { while (triggerThread.IsAlive) { if (enumerator.MoveNext()) { var document = enumerator.Current; if (document != null) { HandleNextData(document); } } else { if (enumerator.IsDead) { break; } if (!enumerator.IsServerAwaitCapable) { Thread.Sleep(TimeSpan.FromMilliseconds(100)); } } } }
If the cursor query is changed to "GTE"
cursor = collection.Find(Query.GTE("_id", lastId))
so as the first result the last record is returned all works fine.