-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
Per the Server Session spec:
An implicit session MUST be returned to the pool immediately following the completion of an operation. When an implicit session is associated with a cursor for use with getMore operations, the session MUST be returned to the pool immediately following a getMore operation that indicates that the cursor has been exhausted. In particular, it MUST not wait until all documents have been iterated by the application or until the application disposes of the cursor. For language runtimes that provide the ability to attach finalizers to objects that are run prior to garbage collection, the cursor class SHOULD return an implicit session to the pool in the finalizer if the cursor has not already been exhausted.
PHPC-1151 added a reference to Sessions on the Cursor object to ensure that the underlying libmongoc client session is kept active for all cursor-related operations (e.g. getMore, killCursors). PHPC-1152 adds emulation of implicit sessions in executeCommand() (similar to what CDRIVER-2578 did for change streams) to ensure that a command cursor shares the same session as its originating command.
As a result of these changes, we should ensure that the Cursor's reference to its Session is freed as soon as we observe that that cursor ID is zero. At that point, we know that the server's results have been exhausted (the cursor is closed) and the driver will neither issue another getMore nor attempt to kill the cursor during cleanup.
This is somewhat related to PHPC-1120 and its dependency CDRIVER-2503; however, those issues relate purely to libmongoc's own implicit sessions. With respect to PHPC, that pertains to executeQuery() and executeBulkWrite() only once PHPC-1152 has been implemented.
- is related to
-
PHPC-1151 Possible segfault is Session object is freed before Cursor
- Closed
-
CDRIVER-2578 mongoc_change_stream_t can send getMore with wrong lsid
- Closed
-
PHPC-1152 Aggregate may fail to use the same session for getMore commands
- Closed
-
PHPC-1120 Decrease likelihood of implicit session leaks
- Closed
-
CDRIVER-2503 Decrease likelihood of implicit session leaks
- Closed