CSHARP-6009: Send afterClusterTime on writes in causally-consistent sessions#2005
CSHARP-6009: Send afterClusterTime on writes in causally-consistent sessions#2005sanych-sun wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Implements CSHARP-6009 by sending readConcern.afterClusterTime on write commands when the session is causally consistent (and not in a transaction). A new ReadConcernHelper.GetReadConcernForWriteCommand helper centralizes this logic and is wired through all write operations (insert/update/delete/findAndModify/bulkWrite/clientBulkWrite/create/createIndexes/drop/dropDatabase/dropIndexes). The retryable write CreateCommand signature is extended to take a ConnectionDescription. Tests are added (new causal-consistency unified specs and runner entry), existing transaction specs are updated to expect afterClusterTime, and UnifiedDropCollectionOperation now supports a session argument so the new tests can drive dropCollection with a session.
Changes:
- Add
GetReadConcernForWriteCommandand applyreadConcern.afterClusterTimeto all write commands; threadConnectionDescriptionthroughRetryableWriteCommandOperationBase.CreateCommandand subclasses. - Add new unified causal-consistency write-command and clientBulkWrite test files; update existing transactions/convenient-api specs to expect
afterClusterTime; register aCausalConsistencyrunner. - Add session support to
UnifiedDropCollectionOperationand remove the unusedInsertSerializernested class fromRetryableInsertCommandOperation.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/MongoDB.Driver/Core/Operations/ReadConcernHelper.cs | New helper that returns only afterClusterTime for write commands. |
| src/MongoDB.Driver/Core/Operations/RetryableWriteCommandOperationBase.cs | Pass ConnectionDescription into CreateCommand. |
| src/MongoDB.Driver/Core/Operations/RetryableInsertCommandOperation.cs | Use new helper; remove unused InsertSerializer. |
| src/MongoDB.Driver/Core/Operations/RetryableUpdateCommandOperation.cs | Add readConcern to update command. |
| src/MongoDB.Driver/Core/Operations/RetryableDeleteCommandOperation.cs | Add readConcern to delete command. |
| src/MongoDB.Driver/Core/Operations/ClientBulkWriteOperation.cs | Add readConcern to bulkWrite command. |
| src/MongoDB.Driver/Core/Operations/FindOneAndUpdateOperation.cs | Add readConcern to findAndModify (update). |
| src/MongoDB.Driver/Core/Operations/FindOneAndReplaceOperation.cs | Add readConcern to findAndModify (replace). |
| src/MongoDB.Driver/Core/Operations/FindOneAndDeleteOperation.cs | Add readConcern to findAndModify (delete). |
| src/MongoDB.Driver/Core/Operations/CreateCollectionOperation.cs | Add readConcern to create command. |
| src/MongoDB.Driver/Core/Operations/CreateIndexesOperation.cs | Add readConcern to createIndexes command. |
| src/MongoDB.Driver/Core/Operations/DropCollectionOperation.cs | Add readConcern to drop command. |
| src/MongoDB.Driver/Core/Operations/DropDatabaseOperation.cs | Add readConcern to dropDatabase command; remove unused using. |
| src/MongoDB.Driver/Core/Operations/DropIndexOperation.cs | Add readConcern to dropIndexes command. |
| tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs | Register CausalConsistency unified test theory. |
| tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedDropCollectionOperation.cs | Support session argument for dropCollection. |
| specifications/causal-consistency/tests/causal-consistency-write-commands.{yml,json} | New unified tests asserting afterClusterTime on writes. |
| specifications/causal-consistency/tests/causal-consistency-clientBulkWrite.{yml,json} | New unified test asserting afterClusterTime on clientBulkWrite. |
| specifications/transactions/tests/unified/{commit,retryable-writes}.{yml,json} | Update expectations to require afterClusterTime on first transaction write. |
| specifications/transactions-convenient-api/tests/unified/callback-{commits,aborts}.{yml,json} | Update expectations to require afterClusterTime on first transaction write. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.