-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Connections
Context
mnet.Connection was introduced in GODRIVER-3058 (PR #1475) as a composition shim: a concrete struct that bundles small interfaces (ReadWriteCloser, Describer, Streamer, Compressor, Pinner) so the x-package can return structs instead of interfaces, per Go's accept interfaces, return structs idiom. The struct was deliberately not meant to carry behavioral state of its own: its purpose was structural composition, allowing the package to subset description.Server and clean up x-package surface.
GODRIVER-3658 added a Close() override and a Closed() method backed by an atomic flag, breaking that contract. Beyond the abstraction violation, the flag is deceptive: it answers "did our code call Close?", not "is this connection usable?". A connection can be in an unusable state while Closed() returns false: most notably when the server closes the connection (idle timeout, step-down, restart, drop). The change-stream pre-flight check at change_stream_deployment.Connection() polls Closed() in this state and reuses dead connections, with the next getMore failing on a corpse. Treating this as urgent.
GODRIVER-3603 introduces a centralized bufio.Reader on topology.connection that enables non-destructive Peek. With Peek, the wrapper can run a real liveness probe and mnet.Connection can return to being a pure shim.
Definition of done
Replace c.conn.Closed() with !c.conn.IsAlive() in change_stream_deployment.Connection().
Remove Connection.Close() override, Connection.Closed() method, and the
closed atomic field from x/mongo/driver/mnet/connection.go. Close falls through to the embedded ReadWriteCloser via interface promotion.
Pitfalls
What should the implementer watch out for? What are the risks?
- depends on
-
GODRIVER-3603 Refactor to add Centralized bufio.Reader to topology.connection
-
- Backlog
-
- related to
-
GODRIVER-3603 Refactor to add Centralized bufio.Reader to topology.connection
-
- Backlog
-