After mongos has established a cursor within a multi-document transaction, if a shard steps down then subsequent requests will fail with NotWritablePrimary error (or they can also fail later due to InterruptedDueToReplStateChange). In this case, AsyncResultsMerger will not attempt to clean up the shard cursors, because NotWritablePrimary/InterruptedDueToReplStateChange are not part of this list or errors. This will cause the shard cursor to be leaked.
NotWritablePrimary and InterruptedDueToReplStateChange (or the NotPrimaryError category?) should be made part of that list.
Edit: 'LockTimeout' errors can also occur, and AsyncResultsMerger will also not attempt to clean up cursors in this case.
- causes
-
PYTHON-3953 PyMongo should send killCursors on MaxTimeMSExpired Error
- Closed
- is related to
-
SERVER-81338 Improve the approach of sending killCursors request from AsyncResultsMerger
- Backlog
- related to
-
DRIVERS-2751 Update spec tests to reflect new killCursor behavior for ConnectionFailure
- Closed