Skip to content

CSHARP-6009: Send afterClusterTime on writes in causally-consistent sessions#2005

Draft
sanych-sun wants to merge 1 commit into
mongodb:mainfrom
sanych-sun:CSHARP-6009
Draft

CSHARP-6009: Send afterClusterTime on writes in causally-consistent sessions#2005
sanych-sun wants to merge 1 commit into
mongodb:mainfrom
sanych-sun:CSHARP-6009

Conversation

@sanych-sun
Copy link
Copy Markdown
Member

No description provided.

@sanych-sun sanych-sun requested a review from a team as a code owner May 19, 2026 20:32
@sanych-sun sanych-sun requested review from ajcvickers and Copilot May 19, 2026 20:32
@sanych-sun sanych-sun added the feature Adds new user-facing functionality. label May 19, 2026
@sanych-sun sanych-sun marked this pull request as draft May 19, 2026 20:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GetReadConcernForWriteCommand and apply readConcern.afterClusterTime to all write commands; thread ConnectionDescription through RetryableWriteCommandOperationBase.CreateCommand and subclasses.
  • Add new unified causal-consistency write-command and clientBulkWrite test files; update existing transactions/convenient-api specs to expect afterClusterTime; register a CausalConsistency runner.
  • Add session support to UnifiedDropCollectionOperation and remove the unused InsertSerializer nested class from RetryableInsertCommandOperation.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Adds new user-facing functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants