Skip to content

mongodb: fix data race on ChangeStream between TryNext and ResumeToken#4271

Open
mmatczuk wants to merge 1 commit intomainfrom
mmt/mongodb-fix-data-race-on-changestream-between-trynext-and-resumetoken
Open

mongodb: fix data race on ChangeStream between TryNext and ResumeToken#4271
mmatczuk wants to merge 1 commit intomainfrom
mmt/mongodb-fix-data-race-on-changestream-between-trynext-and-resumetoken

Conversation

@mmatczuk
Copy link
Copy Markdown
Contributor

The ack callback called stream.ResumeToken() from a different goroutine
than the one running stream.TryNext(), racing on the ChangeStream's
internal resume token field. Use the value already resolved by the
checkpoint system instead, which is both race-free and semantically
correct.

Fixes CON-418

The ack callback called stream.ResumeToken() from a different goroutine
than the one running stream.TryNext(), racing on the ChangeStream's
internal resume token field. Use the value already resolved by the
checkpoint system instead, which is both race-free and semantically
correct.

Fixes CON-418
@claude
Copy link
Copy Markdown

claude bot commented Apr 16, 2026

Commits
LGTM

Review
One-line fix replaces stream.ResumeToken() in the ack callback (running on a different goroutine) with *resumeToken from the checkpoint system's resolve(). The resume token was already captured safely in the main goroutine at track time, and the pointer is properly nil-guarded on line 915. Clean race fix.

LGTM

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.

1 participant