Repository navigation
Use checkpoint keyset paging across SQL dialects (#63) - #74
Merged
Merged
Conversation
Seek after each page's last checkpoint with the bucket and upper bound preserved. Keep legacy offset SQL for custom dialects and statements, and omit the limit for PageSize = 0. Co-authored-by: Codex <codex@openai.com>
Read expected checkpoints through the existing stream API rather than relying on Oracle's write result. Exercise a derived SQLite dialect with an overridden checkpoint query on both reader paths. Co-authored-by: Codex <codex@openai.com>
Add a protected virtual hook to customize the ordered seek or keep the legacy query for a given shape. Document that existing checkpoint SQL overrides must opt out or migrate. Co-authored-by: Codex <codex@openai.com>
Show inherited paging, complete and selective offset fallback, and adapted or fully custom keyset SQL. Call out the impact on existing checkpoint overrides under Breaking Changes. Co-authored-by: Codex <codex@openai.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the checkpoint keyset paging change.
No open issues 🎉
What changed in this PR
Replaces offset-based checkpoint paging with keyset paging across the five built-in SQL dialects, addressing #63. This improves catch-up reads and avoids skips caused by deleting earlier pages; concurrent publication ordering remains outside scope.
Changes:
- Adds sync and async checkpoint seeks while preserving bucket filters, inclusive upper bounds, and unlimited reads.
- Adds shared paging tests and SQLite deletion and derived-dialect regression tests.
- Documents the derived-dialect breaking change, migration options, and performance comparison plan.
| File | Description |
|---|---|
| src/NEventStore.Persistence.Sqlite.Tests/NEventStore.Persistence.Sqlite.Core.Tests.csproj | Includes shared checkpoint tests. |
| src/NEventStore.Persistence.Sqlite.Tests/CheckpointPagingDeletionTests.cs | Tests deletion safety and dialect customization. |
| src/NEventStore.Persistence.Sql/SqlPersistenceEngine.cs | Routes synchronous checkpoint reads through keyset paging. |
| src/NEventStore.Persistence.Sql/SqlPersistenceEngine.Async.cs | Adds equivalent asynchronous routing. |
| src/NEventStore.Persistence.Sql/SqlDialects/PagedEnumerationCollection.cs | Supports paging without offset tracking. |
| src/NEventStore.Persistence.Sql/SqlDialects/MsSqlDialect.cs | Exposes the locking-hint helper internally for reuse. |
| src/NEventStore.Persistence.Sql/SqlDialects/CommonSqlDialect.cs | Adds the overridable keyset query hook. |
| src/NEventStore.Persistence.Sql/SqlDialects/CommonDbStatement.cs | Executes keyset pages without offset parameters. |
| src/NEventStore.Persistence.Sql/SqlDialects/CheckpointKeysetQuery.cs | Generates dialect-specific checkpoint seek SQL. |
| src/NEventStore.Persistence.Sql.Tests/PersistenceTests.CheckpointPaging.cs | Tests ordering, scope, gaps, bounds, and unlimited reads. |
| src/NEventStore.Persistence.Sql.Tests/NEventStore.Persistence.Sql.Core.Tests.csproj | Keeps shared tests compiled through provider projects. |
| src/NEventStore.Persistence.PostgreSql.Tests/NEventStore.Persistence.PostgreSql.Core.Tests.csproj | Includes shared checkpoint tests. |
| src/NEventStore.Persistence.Oracle.Tests/NEventStore.Persistence.Oracle.Core.Tests.csproj | Includes shared checkpoint tests. |
| src/NEventStore.Persistence.MySql.Tests/NEventStore.Persistence.MySql.Core.Tests.csproj | Includes shared checkpoint tests. |
| src/NEventStore.Persistence.MsSql.Tests/NEventStore.Persistence.MsSql.Core.Tests.csproj | Includes shared checkpoint tests. |
| docs/Checkpoint-Seek-Paging.md | Explains behavior, migration, and performance verification. |
| Changelog.md | Records keyset paging and the derived-dialect breaking change. |
Review effort: Balanced
AGiorgetti
marked this pull request as ready for review
December 3, 2026 14:21
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 #63. Does not close #72 or NEventStore/NEventStore#425: keyset paging does not order concurrent commit publication.
Behavior
PageSize = 0sends one ordered query without a page limit. SQL Server retains the opt-in locking from Make MsSqlDialect compatible with AzureSql and READ COMMITTED SNAPSHOT #31.Breaking change for derived dialects
The keyset path bypasses the old virtual checkpoint SQL properties. Override
GetCheckpointKeysetQuery(bool scoped, bool bounded, int pageSize)to customize its SQL, or returnnullfor the query shapes that should still use the old overrides and offset paging. See the migration example.Verification
Co-authored by Alessandro Giorgetti and Codex (OpenAI).