[CDRIVER-3438] Destroy exhaust cursor socket in mongoc_cursor_destroy regardless of client generation Created: 26/Nov/19  Updated: 28/Oct/23  Resolved: 16/Jan/20

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.16.0
Fix Version/s: 1.16.0

Type: Bug Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CDRIVER-3487 Exhaust cursors on single threaded dr... Backlog
is related to CDRIVER-3116 Do not disconnect sockets in mongoc_c... Closed
is related to CDRIVER-2857 Provide a reset method to be called o... Closed
is related to PHPC-1274 Reset libmongoc client after forking ... Closed

 Description   

When CDRIVER-2857 introduced the mongoc_client_reset() method, it added logic to mongoc_cursor_destroy() that skipped two actions if the client generation differed:

  1. Disconnect the socket for an active exhaust cursor
  2. Send a killCursors command for an active, normal cursor

At the time, mongoc_client_reset() also disconnected all nodes in the cluster, so the fact that mongoc_cursor_destroy() did not disconnect the socket for an active exhaust cursor was not important.

CDRIVER-3116 later changed mongoc_client_reset() such that sockets are left alone. I believe this means that users of exhaust cursors will no way of avoiding an error in a child process when attempting to re-use a socket from a parent that previously opened an exhaust cursor.

This may not be a significant issue, as our take-away from PHPC-1274 was that mongoc_client_reset() was mainly useful as a means to prevent children from destroying cursors owned by a parent and/or re-using session IDs from a parent. There was not stated goal of allowing a child process to continue using sockets from a parent's client, and I believe doing so would likely lead to an out-of-sequence wire protocol error since processes might read each other's responses unexpectedly.

Having said that, I'm curious if we should allow mongoc_cursor_destroy() to still disconnect a socket for an active exhaust cursor regardless of the client's generation.



 Comments   
Comment by Githook User [ 16/Jan/20 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-3438 destroy exhaust socket on reset
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/ab514aeb40a79c5902a08c18d39f2b361f94cdac

Generated at Wed Feb 07 21:18:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.