You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2026/08/09 20:42:08 UTC

[I] JdbcSnapshotStore ignores minSequenceNr and minTimestamp from SnapshotSelectionCriteria [pekko-persistence-jdbc]

pjfanning opened a new issue, #591:
URL: https://github.com/apache/pekko-persistence-jdbc/issues/591

   Suggested by Claude.
   
   Pekko's SnapshotSelectionCriteria has four fields: maxSequenceNr, maxTimestamp, minSequenceNr, and minTimestamp. The JdbcSnapshotStore in pekko-persistence-jdbc pattern-matches on only the first two (max bounds) and silently discards the min bounds. This affects both loadAsync and deleteAsync.
   
   Affected file: core/src/main/scala/org/apache/pekko/persistence/jdbc/snapshot/JdbcSnapshotStore.scala
   
   Current behavior (lines 68-78 for load, 92-102 for delete):
   
   // loadAsync - only uses maxSequenceNr and maxTimestamp
   criteria match {
     case SnapshotSelectionCriteria(Long.MaxValue, Long.MaxValue, _, _) =>  // min fields discarded via _
       snapshotDao.latestSnapshot(persistenceId)
     case SnapshotSelectionCriteria(Long.MaxValue, maxTimestamp, _, _) =>
       snapshotDao.snapshotForMaxTimestamp(persistenceId, maxTimestamp)
     case SnapshotSelectionCriteria(maxSequenceNr, Long.MaxValue, _, _)
       snapshotDao.snapshotForMaxSequenceNr(persistenceId, maxSequenceN
     case SnapshotSelectionCriteria(maxSequenceNr, maxTimestamp, _, _) =>
       snapshotDao.snapshotForMaxSequenceNrAndMaxTimestamp(persistenceId, maxSequenceNr, maxTimestamp)
     case _ => Future.successful(None)
   }
   
   The _, _ wildcards explicitly ignore minSequenceNr and minTimestamp. The DAO methods and SQL queries have no parameters for min bounds at all.
   
   Impact:
   - loadAsync may return a snapshot that is below the caller's minimumamp
   - deleteAsync may delete snapshots that fall below the minimum boundr intended to keep
   - Any Pekko application relying on min-bounds filtering (e.g., SnapsquenceNr, maxTimestamp, minSequenceNr = 5, minTimestamp = ...)) gets
   incorrect results
   
   Note: The Pekko TCK (SnapshotStoreSpec) does not test min bounds, so this bug passes CI undetected.
   
   ---
   Plan for Changes
   
   Files to modify (7 files):
   
   1. SnapshotDao.scala — Add two new methods with default implementatility:
     - snapshotForCriteria(persistenceId, maxSequenceNr, maxTimestamp, minSequenceNr, minTimestamp) — defaults to existing max-only methods
     - deleteByCriteria(persistenceId, maxSequenceNr, maxTimestamp, minSequenceNr, minTimestamp) — defaults to existing max-only methods
   2. SnapshotQueries.scala (new schema) — Add query builders that cond filters (sequenceNumber >= minSequenceNr when > 0, created >=minTimestamp when > 0) alongside the existing max-bounds filters.
   3. DefaultSnapshotDao.scala — Override the new methods to use the new query builders.
   4. legacy/SnapshotQueries.scala — Same query builder additions for t
   5. legacy/ByteArraySnapshotDao.scala — Override the new methods for legacy DAO.
   6. JdbcSnapshotStore.scala — Replace the pattern-matching dispatch ic with direct calls to snapshotForCriteria and deleteByCriteria,passing all four bounds from the criteria.
   7. JdbcSnapshotStoreSpec.scala — Add directional tests:
     - loadAsync with minSequenceNr excludes snapshots below the min
     - loadAsync with minTimestamp excludes snapshots below the min
     - deleteAsync with minSequenceNr preserves snapshots below the min
     - deleteAsync with minTimestamp preserves snapshots below the min
   
   Binary compatibility:
   
   - New methods on SnapshotDao trait are concrete with default implemele (Java 8+ default interface methods)
   - Existing methods remain unchanged
   - MiMa should pass cleanly


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [I] JdbcSnapshotStore ignores minSequenceNr and minTimestamp from SnapshotSelectionCriteria [pekko-persistence-jdbc]

Posted by "goutamadwant (via GitHub)" <gi...@apache.org>.
goutamadwant commented on issue #591:
URL: https://github.com/apache/pekko-persistence-jdbc/issues/591#issuecomment-5660545017

   I tried to address the snapshot selection and deletion bounds in #618, with coverage for current and legacy DAOs. Could you take a look and let me know if you have any comments or suggestions?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [I] JdbcSnapshotStore ignores minSequenceNr and minTimestamp from SnapshotSelectionCriteria [pekko-persistence-jdbc]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on issue #591:
URL: https://github.com/apache/pekko-persistence-jdbc/issues/591#issuecomment-5233766664

   fyi @raboof @He-Pin @jrudolph @mdedetrich @Philippus @ptrdom 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [I] JdbcSnapshotStore ignores minSequenceNr and minTimestamp from SnapshotSelectionCriteria [pekko-persistence-jdbc]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning closed issue #591: JdbcSnapshotStore ignores minSequenceNr and minTimestamp from SnapshotSelectionCriteria
URL: https://github.com/apache/pekko-persistence-jdbc/issues/591


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org