[DRIVERS-1602] Automate session refresh for long-lived cursors Created: 08/Mar/21  Updated: 31/Mar/22

Status: Backlog
Project: Drivers
Component/s: Sessions
Fix Version/s: None

Type: Improvement Priority: Critical - P2
Reporter: Matt Broadstone Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to PYTHON-1879 no_cursor_timeout not functioning as ... Closed
is related to RUBY-1503 still having problems with noCursorTi... Closed
is related to SERVER-6036 Disable cursor timeout for cursors th... Closed
Driver Changes: Needed

 Description   

The following code will throw an error when using the node driver:

const cursor = coll.find();
while (await cursor.hasNext()) {
  const doc = await cursor.next();
  await processDocForAnAccidentallyLongTime(doc);
} 

The reason is that the implicit session created when executing the initial find query controls the lifetime of the resulting cursor, and that session is automatically cleaned up after the logicalSessionsTimeoutMinutes (30 by default). When the user enters the second loop in the above example, they are confronted with an unhelpful "cursor id 124353857892752 does not exist" and then need to go learn a lot about how sessions work in MongoDB (they probably didn't even know an implicit session was created for them in the first place).

SPEC-1268 proposed that we add new drivers API for users to explicitly refresh their long-lived sessions, but this ticket proposes that we periodically send refreshSessions internally for active, long-lived cursors.


Generated at Thu Feb 08 08:23:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.