Skip to content

[MongoDB Storage] Fix occasional readConcern errors when using bulk_read_preference#710

Merged
rkistner merged 4 commits into
mainfrom
fix-session-clustertime
Jul 7, 2026
Merged

[MongoDB Storage] Fix occasional readConcern errors when using bulk_read_preference#710
rkistner merged 4 commits into
mainfrom
fix-session-clustertime

Conversation

@rkistner

@rkistner rkistner commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

When using bulk_read_preference: secondaryPreferred, these errors occasionally come up:

Sync stream error [PSYNC_S2001] Something went wrong
  readConcern atClusterTime value must not be greater than the current clusterTime. Requested clusterTime: { ts: Timestamp(1783421938, 355) }; current clusterTime: { ts: Timestamp(1783421938, 351) }

Sync stream error [PSYNC_S2001] Something went wrong
  [PSYNC_S2404] MongoDB server error while reading checksums: InvalidOptions

In #697, I originally went with this assumption from https://jira.mongodb.org/browse/DRIVERS-2860:

No need to do session_b.advance_cluster_time(session_a.cluster_time) because the MongoClient
already gossips the highest $clusterTime seen across all client sessions.

But it appears that assumption does not always hold here. Using advanceClusterTime as well is simple enough, and should resolve the issue.

Note that this effectively includes $clusterTime in the commands mongodb sends. It does not change how values are read, but should avoid the errors above. It may have additional implications for monotonic writes, but that should not affect our reads here.

@changeset-bot

changeset-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 891bf8c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@powersync/service-module-mongodb-storage Patch
@powersync/service-schema Patch
@powersync/service-module-convex Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mssql Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres Patch
@powersync/service-image Patch
@powersync/service-core Patch
@powersync/service-module-core Patch
@powersync/service-module-postgres-storage Patch
test-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rkistner
rkistner marked this pull request as ready for review July 7, 2026 15:28
@rkistner
rkistner requested a review from stevensJourney July 7, 2026 15:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 57daa4b5e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

stevensJourney
stevensJourney previously approved these changes Jul 7, 2026
@rkistner
rkistner merged commit 1f854d3 into main Jul 7, 2026
45 checks passed
@rkistner
rkistner deleted the fix-session-clustertime branch July 7, 2026 16:02
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