-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Component/s: Change Streams
-
None
-
Needed
-
Summary
The change streams spec requires a resume after any non-server error, including the application canceling the getMore operation from next (Go, .NET with CancellationToken, Node?, Python (async API), Rust?, Java with Thread#interrupt and Structured Concurrency), and nothing requires the driver to keep the cursor ID when the resume's kill fails, which orphans the cursor:
Any error encountered which is not a server error (e.g. a timeout error or network error)
The bug works like this:
- app opens a change stream; the server creates a cursor for it
- app calls next and the driver sends a getMore that waits for new events
- app cancels the operation while the getMore is waiting
- getMore fails with a cancelation error, which is not a server error, so the spec says it's resumable
- driver resumes, trying to kill the old cursor before running a new aggregate
- killCursors uses the same cancelation context, so it fails before anything reaches the server
- the server cursor is orphaned. In Go, the ID is zeroed, so close has nothing to kill
- the server cursor stays open until it times out (10 minutes by default)
Motivation
Who is the affected end user?
Applications that call next on a change stream with a context they cancel or put a deadline on.
How does this affect the end user?
Unclear, wastes server resources and probably confusing metrics.
How likely is it that this problem or use case will occur?
Any change stream user who cancels or times out a next call is affected, which seems fairly likely.
If the problem does occur, what are the consequences and how severe are they?
Each canceled next leaves an orphaned cursor on the server for up to 10 minutes. Probably minor resource contention.
Is this issue urgent?
Not completely clear but almost certainly not urgent. Hesitation comes from cancelation misuse or really tight deadlines: e.g., racing network latency.
Is this ticket required by a downstream team?
No
Is this ticket only for tests?
No
Acceptance Criteria
- Need to update the spec excerpt from above to not attempt a resume on cancelation or deadline errors
- Add prose test, example in Go: https://github.com/10gen/go-driver-tools/blob/97942ea22e5989a169157ffc74a720aabee8b5c1/preston/repros/2.10.0/godriver_4243_cancel_test.go#L14
- related to
-
GODRIVER-4243 Change stream leaks the server cursor when Next's context expires or is canceled
-
- Needs Triage
-