Apache Software Foundation / Pekko Persistence JDBC
Merged upstreamCorrectnessMerged Sep 23, 2026

Honor snapshot selection lower bounds

Applied all four SnapshotSelectionCriteria bounds to current and legacy built-in DAOs while preserving the established upper-bound fallback for third-party custom DAOs.

apache/pekko-persistence-jdbc · #618

Persistence correctness and retention fix

JDBC snapshot loading and deletion now honor minimum sequence-number and timestamp bounds instead of silently applying only upper limits.

Problem

JdbcSnapshotStore discarded minSequenceNr and minTimestamp. Loads could return snapshots older than the requested interval, while criteria-based deletion could remove snapshots the caller intended to retain. The existing Pekko snapshot TCK did not cover these lower-bound cases.

Approach

Adds concrete criteria methods to the DAO contract, routes all four inclusive bounds into current and legacy SQL queries, and documents the custom-DAO compatibility behavior. Existing DAO methods remain available, and default implementations retain their prior upper-bound approximation.

Impact and scope

  • Makes snapshot recovery select the latest record inside the complete requested interval rather than only checking its upper edge.
  • Prevents bounded retention operations from deleting snapshots below the caller's minimum sequence or timestamp.
  • Preserves binary and behavioral compatibility for existing custom DAOs while allowing them to opt into exact lower-bound filtering.
  • Keeps persistence-ID isolation and inclusive boundary semantics consistent across current and legacy schemas.

Validation

  • Twenty of 30 new regression cases failed on the original implementation across H2 and PostgreSQL current/legacy configurations, establishing the defect before the fix.
  • Focused coverage exercised inclusive and intersecting bounds, empty ranges, unordered timestamps, deletion retention, custom DAO routing, typed retention, recovery with event replay, and persistence-ID isolation.
  • All 23 hosted checks passed, including H2 tests across Scala 2.13, 3.3, and 3.9 plus current and legacy DAO integration suites for MariaDB, MySQL, Oracle, PostgreSQL, and SQL Server.
  • The maintainer approved the final revision, the linked issue is closed, and the verified merge commit credits Goutam Adwant.