feat(mongo): modernize driver with SDAM, sessions, and wire features - #2880
feat(mongo): modernize driver with SDAM, sessions, and wire features#2880gedaiu wants to merge 90 commits into
Conversation
…gement improvements
…ne and mongos types
…demote stale primaries
…SL key file is present
…larity and error handling
…nd AggregateOptions
… namespace management
- Added compression helpers for negotiating compressors and (de)compressing OP_COMPRESSED payloads. - Introduced ServerDescription struct to manage server state and topology, including classification of server types. - Implemented wire protocol primitives for message length computation and OP_MSG body parsing. - Established wire-version compatibility with UDAs for enforcing version constraints on nullable fields. - Added comprehensive unit tests for all new functionalities to ensure correctness and reliability.
… topology management
…eartbeat management
…server selection timeouts
…opology scenarios
…ror is not masked by abort failure feat(serversession): add dirty state management to handle network errors in sessions feat(tests): update run script to ensure standalone mongod is always started for negative path testing
…causal consistency
…d update related logic
…ments and throw MongoDriverException
…d add related unittest
…er stop() and improve cooldown handling
…and improve error logging
…rded topology without altering mongos list
…es to prevent incorrect primary demotion
…unction with unittests
…s and enhance selectServer logic with tagSets support
…tion improvements - Updated `MongoCursor` to include `readPreferenceTags` in the `buildFindCommand` method, ensuring correct handling of read preferences during cursor operations. - Modified `buildFindCommand` and `buildAggregateCommand` to accept `tagSets`, allowing for more precise read preference configurations. - Implemented validation in `applySrvSeedlist` to reject multiple TXT records and ensure correct load-balanced configurations. - Added unit tests to verify that read preference tags are correctly included in commands and that SRV resolution behaves as expected. - Enhanced `MongoClientSettings` to track whether `loadBalanced` was explicitly set in the connection string, preventing unintended overrides from TXT records.
…ed IDs in bulk operations feat(collection): modify InsertOneResult to support various BSON types for inserted IDs feat(changestream): update documentation to clarify tailable cursor behavior in change streams
… data and validate against file length
…s to prevent allocation issues
…tial-carrying and handshake commands
…handling and dynamic configuration
…es and session management improvements
…ent validation errors feat(serversession): implement destructor for MongoClientSession to ensure session cleanup on shutdown
…d close method to MongoClient
…eplica set scenarios
… keys and enhance ClientEncryption with key vault integration
- Added concurrency contract documentation for MongoClient to clarify thread safety. - Implemented bulk write command partitioning to respect server limits on write operations. - Introduced methods to handle orphaned cursors during bulk write operations. - Enhanced session pool timeout handling based on server capabilities. - Improved topology management by pruning stale connection pools. - Added support for detecting invalidate events in change streams and managing resume points accordingly. - Updated encryption validation to enforce key length requirements for local KMS providers. - Enhanced retryable writes logic to ensure bulkWrite commands are only retried when appropriate. - Improved load balancer readiness checks in test scripts. - Updated session timeout tests to reflect server-advertised values.
vibe-serialization 1.2.0 dropped the implicit BsonObjectID->Bson conversion in Bson.opEquals; insertResults[0].insertedId is a Bson, so the comparison must wrap the BsonObjectID. Fixes the bulkwrite integration test failing to compile under dmd/vibe-serialization 1.2.0.
MongoDB 3.6 rejects opening a $changeStream on a non-existent database
("cannot open $changeStream for non-existent database"); newer servers
tolerate a missing collection. runReplicaSetTest dropped the collection
then watched it, so the priming read failed on 3.6. Create the collection
explicitly after the drop. Verified against a real mongod 3.6.23 replica
set and the existing 7.0 run.sh path.
A default MongoDB 3.6 mongod advertises no wire compressors, so zlib is never negotiated and no OP_COMPRESSED is ever sent. The reconnect-handshake compression bug cannot manifest without compression, so turn the OP_COMPRESSED precondition into a graceful skip instead of a hard assert. Verified: skips on a real 3.6 standalone, runs the full assertion on 7.0.
Brings in 4 upstream commits (rest void-return Content-Type fix, SMTP envelope sender). None touch mongodb/.
|
Closing in favor of a stacked, reviewable decomposition Hey! This branch grew into a ~14k-line near-total rewrite of the MongoDB driver, which is far too large to review in one piece. I've split it into 9 focused, dependency-ordered PRs, each based on the current upstream master, each compiling on its own with unit tests green, and each closing specific tracked issues. Together they reproduce this branch exactly, so I'm closing it here and moving the work into the stack below (please review in order): #2882 — MongoDB driver SDAM core: topology discovery, health monitoring, primary write-routing, per-query read preferences, read-preference tags. Closes #2845, #2847, #2848, #2849, #2851 |
Brings the MongoDB driver up to modern server-spec compliance so it can run reliably against replica sets and current MongoDB releases: SDAM-based topology monitoring with primary step-down recovery, server sessions with retryable writes and multi-document transactions, and per-query read preferences. On top of that it adds change streams, mongodb+srv seedlist resolution, load-balanced mode, Stable API, OP_COMPRESSED wire compression, client-side field level encryption, GridFS, and MongoDB 8.0 server-level bulkWrite, each backed by integration tests under tests/mongodb. Also fixes estimatedDocumentCount on missing collections and switches to X.509 auth when an SSL key file is configured.
Fixes #2845, fixes #2846, fixes #2847, fixes #2848, fixes #2849, fixes #2850, fixes #2851, fixes #2854, fixes #2855, fixes #2856, fixes #2858, fixes #2859, fixes #2860, fixes #2861, fixes #2862, fixes #2863, fixes #2864.