Skip to content

[Order 02][P1] Fix async paged-query infinite loop when PageSize is zero #60

Description

@AGiorgetti

Priority order

Order: 02 of 09
Priority: P1 correctness

Problem

Async paged reads can loop forever when the configured page size is 0 and the result set is empty.

Evidence:

  • src/NEventStore.Persistence.Sql/SqlDialects/CommonDbStatement.cs:331
  • Continuation condition is while (Dialect.CanPage && recordsRead == PageSize).
  • SqlPersistenceEngine allows PageSize == 0, where zero represents infinite page size.

Impact

  • Empty async reads can hang for pageable dialects.
  • Affected APIs include checkpoint reads, bucket-scoped reads, and stream reads that call ExecutePagedQueryAsync.

Mandatory test-first workflow

  • Add tests first that reproduce or verify the issue before changing production code.
  • Include an async empty-result test with configured page size 0.
  • Cover at least GetFromAsync(0, observer, token) and one bucket-scoped async read.
  • The test must fail or time out before the fix and complete after the fix.

Proposed action

  • Base continuation on the computed local pageSize.
  • Continue only when pageSize > 0 && recordsRead == pageSize.

Acceptance criteria

  • Empty async reads complete when PageSize == 0.
  • Multi-page async reads still return ordered, complete results when PageSize > 0.
  • Sync behavior is unchanged.

Source: docs/Project-Analysis-Issue-Drafts.md.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions