-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
-
Needed
-
🔵 Done
-
Minor Change
-
C Drivers
-
Not Needed
-
None
-
None
-
None
-
None
-
None
-
None
Proposal
Try to send killCursors on client-side cursor timeout
Background & Motivation
The C driver deliberately does not re-establish connection to send killCursors to the server in _mongoc_client_kill_cursor.
CSOT suggests it is OK to extend the timeout to send killCursors:
If a cursor times out client-side (e.g. a non-tailable cursor created with timeoutMode=CURSOR_LIFETIME), it’s imperative that drivers make a good-faith effort to close the server-side cursor even though the timeout has expired because failing to do so would leave resources open on the server for a potentially long time. It was decided that timeoutMS will be refreshed for close operations to allow the cursor to be killed server-side.
CSOT is a large project and not-yet implemented in the C driver. This ticket proposes a smaller change to improve a timeout caused by socketTimeoutMS.
Here is a failing test that shows killCursors is not sent after a client-side timeout (even though the cursor ID was returned by the server):
mongoc_cursor_t *cursor = mongoc_collection_aggregate(coll, MONGOC_QUERY_NONE, pipeline, tmp_bson("{'batchSize': 1 }"), NULL); // First document returned fast: ASSERT(mongoc_cursor_next(cursor, &got)); ASSERT(mongoc_cursor_get_id(cursor)); // Cursor established. // Second document triggers timeout: ASSERT(!mongoc_cursor_next(cursor, &got)); ASSERT(mongoc_cursor_error(cursor, &error)); ASSERT_ERROR_CONTAINS(error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "socket error or timeout"); mongoc_cursor_destroy(cursor); // Does not send killCursors!
- causes
-
PHPC-2660 Investigate changes in CDRIVER-6135: Send killCursors on client-side cursor timeout
-
- Backlog
-