Repository navigation
Add opt-in locking for SQL Server commit reads (#31) - #73
Merged
Merged
Conversation
Restrict READCOMMITTEDLOCK to the two open-ended checkpoint queries used by legacy pollers. Preserve the existing default, bounded reads, stream loading, and other dialects. Co-authored-by: Codex <codex@openai.com>
Cover custom consumers using checkpoint ranges, date bounds or stream revisions as well as the built-in pollers. Keep the default, paging, snapshot queries and writes unchanged. Co-authored-by: Codex <codex@openai.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The RCSI mitigation requires expanded integration tests to pass on the final head against real SQL Server lock-wait behavior, but this review environment cannot run those tests.
No open issues 🎉
What changed in this PR
Adds opt-in SQL Server commit-read locking to mitigate skipped reads under READ_COMMITTED_SNAPSHOT, without guaranteeing checkpoint publication order or safe polling.
Changes:
- Applies
READCOMMITTEDLOCKto all seven commit-read statements while preserving default behavior, paging, snapshots, and writes. - Adds query-scope checks and ten integration cases covering lock waits with commit and rollback.
- Documents the option and its limitations.
| File | Description |
|---|---|
| src/NEventStore.Persistence.Sql/SqlDialects/MsSqlDialect.cs | Adds the opt-in constructor and commit-read hint helper. |
| src/NEventStore.Persistence.MsSql.Tests/CheckpointReadLockTests.cs | Adds query-scope and RCSI lock-wait tests. |
| Changelog.md | Documents the mitigation and unchanged behavior. |
Review effort: Balanced
AGiorgetti
marked this pull request as ready for review
December 3, 2026 10:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #31. Mitigates the RCSI symptom in #14 and #21 without closing those reports. SQL #72, #63, and NEventStore/NEventStore#425 remain separate.
Behavior
WithDialect(new MsSqlDialect(useReadCommittedLockForCommitReads: true))requestsREADCOMMITTEDLOCKfor all seven public commit-read statements: open-ended and bounded checkpoint reads, both date-based reads, and stream revision reads. The built-in and custom consumers share these statements. The hint helper uses the name from Feature/31 readcommitedlock #39.Verification
Co-authored by Alessandro Giorgetti and Codex (OpenAI).