-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Component/s: None
-
Needed
In order to make cursor iteration blocking for tailable cursors, and in general to support the possibility of empty batches, driver implementations of cursor iteration typically have an inner loop within the method that advances the cursor:
while (serverCursor != null) { _nextBatch = getMore(); if (!_nextBatch.isEmpty()) { return true; // has more results } } return false; // no more results
Drivers should ensure that there is a check within that loop that the cursor has not been closed by another thread in the application.
while (serverCursor != null) { _nextBatch = getMore(); // if another thread closed the cursor, throw an exception so that this method terminates if (_closed) { throw ... } if (!_nextBatch.isEmpty()) { return true; // has more results } } return false; // no more results
This is necessary because a call to killCursors from the close method of the cursor will fail if there is a getMore in progress on that cursor, and thus the repeated calls to getMore in the loop will never encounter a cursorNotFound error and the loop will not exit.
- depends on
-
GODRIVER-125 Cursor iteration should complete (abnormally) when another goroutine closes the cursor
- Closed
-
JAVA-2651 Unable to exit from hasNext() for tailable cursor if cursor was closed from another thread
- Closed
-
CDRIVER-2361 Cursor iteration should complete (abnormally) when another thread closes the cursor
- Closed
-
CSHARP-2092 Cursor iteration should complete (abnormally) when another thread closes the cursor
- Closed
-
CXX-1469 Cursor iteration should complete (abnormally) when another thread closes the cursor
- Closed
-
NODE-1185 Cursor iteration should complete (abnormally) when another thread closes the cursor
- Closed
-
PHPC-1034 Cursor iteration should complete (abnormally) when another thread closes the cursor
- Closed
-
PYTHON-1408 Cursor iteration should complete (abnormally) when another thread closes the cursor
- Closed
-
RUST-168 Cursor iteration should complete (abnormally) when another thread closes the cursor
- Closed
-
RUBY-1253 Cursor iteration should complete abnormally when another thread closes the cursor
- Closed
- related to
-
SERVER-21710 Allow pinned ClientCursors to be killed on mongod
- Closed