← 输入框|github.com|刷新
Skip to content

Use checkpoint keyset paging across SQL dialects (#63) - #74

Merged
AGiorgetti merged 4 commits into
developfrom
fix/63-checkpoint-keyset-paging
Dec 3, 2026
Merged

AGiorgetti merged 4 commits into
developfrom
fix/63-checkpoint-keyset-paging

Conversation

@AGiorgetti

@AGiorgetti AGiorgetti commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Closes #63. Does not close #72 or NEventStore/NEventStore#425: keyset paging does not order concurrent commit publication.

Behavior

  • Seek strictly after each page's last checkpoint for SQL Server, PostgreSQL, MySQL, Oracle, and SQLite. Retain the original bucket predicate and inclusive upper bound.
  • PageSize = 0 sends 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.
  • Built-in dialects and their subclasses inherit keyset paging when using the built-in statement executor. Independent dialect implementations and separate statement wrappers keep their existing behavior. Stream, date, snapshot, and write paths are unchanged. No schema or core dependency change.

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 return null for the query shapes that should still use the old overrides and offset paging. See the migration example.

Verification

  • Tests first: SQLite reproduced a skipped row on page deletion, a missing limit on synchronous unpaged reads, and the same page deletion skip on inheriting dialects before the default changed.
  • Full local .NET 10 SQLite suite passed 157 tests with zero skips, including derived-dialect defaults, custom keyset SQL and per-query legacy fallback for both sync and async.
  • The previous head passed all five databases. The catch-up timing plan compares equivalent result sets. CI on the inheritance change passed all five databases on .NET 8, 9, and 10 (874 tests per runtime, zero skipped), and both Windows and Linux builds passed.

Co-authored by Alessandro Giorgetti and Codex (OpenAI).

AGiorgetti and others added 4 commits December 3, 2026 12:07
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>

Copilot AI 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.

🟢 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
AGiorgetti marked this pull request as ready for review December 3, 2026 14:21
@AGiorgetti
AGiorgetti merged commit c7acb72 into develop Dec 3, 2026
6 checks passed
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.

Implement safe checkpoint polling across all supported SQL engines [Order 06][P2] Replace offset checkpoint paging with keyset paging

2 participants