Skip to content

Conversation

@FGasper
Copy link
Collaborator

@FGasper FGasper commented Nov 14, 2025

This improves the prevention of stale reads to incorporate the latest-seen cluster time and to use majority read concern.

This is particularly relevant when reading from secondaries, but it can also, because of SERVER-53813, affect reads from primaries.

This removes a lag from a trace-level log in order to simplify things a bit. That data point is redundant with the periodically-reported lag in the logs anyway.

@FGasper FGasper marked this pull request as ready for review November 14, 2025 21:00
// or for the last generation, the change stream end time.
cmd = append(
cmd,
bson.E{"readConcern", bson.D{
Copy link
Collaborator

Choose a reason for hiding this comment

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

As we discussed on Slack in #go-driver channel, RunCommandCursor() will not use the read concern set on the MongoClient. Using read concern level "majority" must be set here explicitly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK. My takeaway from that thread was, “status quo is correct” … but it seems that that’s not actually the case.

Int("count", len(docIDs)).
Any("latestTimestamp", latestTimestamp).
Time("latestTimestampTime", latestTimestampTime).
Stringer("lag", lag).
Copy link
Collaborator

Choose a reason for hiding this comment

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

[question] What is the motivation for "lag" in the output here getting removed? I understand it is the only usage of changeEventBatch.clusterTime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It’s redundant with the lag that gets printed anyway in the logs’ periodic progress reports.

@FGasper FGasper requested a review from visemet November 18, 2025 20:40
@FGasper FGasper merged commit 8af63f5 into mongodb-labs:main Nov 19, 2025
103 checks passed
@FGasper FGasper deleted the REP-6832-afterclustertime-latest-clustertime branch November 19, 2025 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants