-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: Connectivity
-
None
-
Dotnet Drivers
-
None
-
None
-
None
-
None
-
None
-
None
CommandEventHelper uses ConcurrentDictionary[int, CommandState] for _state and iterates it in ConnectionFailed as if multiple commands could be in-flight simultaneously. This design dates back to 2016 when BinaryConnection had separate _sendLock/_receiveLock semaphores and a Dropbox mechanism to support multiplexing.
The multiplexing infrastructure was removed in Sept 2025 (CSHARP-3984, commit 81fa3cb4be8). Commands are now serialized per-connection via ExclusiveConnectionPool, so the concurrent data structures are unnecessary overhead.
Proposed changes:
- Replace ConcurrentDictionary[int, CommandState] with a plain Dictionary or single nullable CommandState field, since only one command is ever in-flight per connection
- Simplify the ConnectionFailed loop over _state.Keys (only ever processes 0 or 1 entries)
- Review and simplify any other concurrency primitives that were only needed for multiplexing