pjfanning opened a new pull request, #516: URL: https://github.com/apache/pekko-persistence-cassandra/pull/516
### Motivation `ReconciliationSession` prepares its five statements eagerly and stores the resulting `Future`s in plain `val`s. If a prepare fails — for example because the `Reconciliation` is created before the keyspace and tables exist, or Cassandra is briefly unavailable — the failed `Future` is kept and every later `deleteFromTagView`, `deleteTagProgress`, `deleteTagScannning`, `selectAllTagProgress` and `selectTagProgress` call fails with it for the lifetime of the instance. `Cleanup.deleteAllTaggedEvents` goes through the same session. akka/akka-persistence-cassandra#1056 (Akka Persistence Cassandra 1.2.0, Apache 2.0 since its change date 2026-10-25) fixed this problem for the journal, read journal, event update, tagged statements and cleanup. Pekko already has those fixes from #106 (`RetryableFutureEval`), but the reconciler was not covered by either change. ### Modification - `ReconciliationSession` holds its prepared statements in `RetryableFutureEval`, the helper the rest of the plugin already uses, so a failed prepare is forgotten and retried on the next call. - Renamed the fields with a `Ps` suffix (as `selectAllTagProgressPs` already had), so they no longer share names with the `deleteTagProgress` / `deleteTagScannning` methods. - Statements are now prepared on first use rather than in the constructor, as `RetryableFutureEval` is lazy. No code is copied from Akka; upstream's `CachedPreparedStatement` is not introduced, since `RetryableFutureEval` covers the same need. Upstream also turned the snapshot store's prepared statements from `def`s into cached values. I left that out: a `def` re-prepares on every call and so never keeps a failure, which means there is no failure for this PR to fix there. ### Result A `Reconciliation` whose prepare failed recovers once the statement can be prepared, instead of failing permanently. ### Tests - `sbt "core/Test/testOnly org.apache.pekko.persistence.cassandra.reconciler.ReconciliationSessionPrepareSpec"` — passed. New spec: creates a `ReconciliationSession` against a keyspace that does not exist yet, creates the schema, and expects the session to recover. Without the fix it fails: `InvalidQueryException: keyspace reconciliationsessionpreparelater does not exist` keeps being returned after the keyspace was created. - `sbt "core/Test/testOnly org.apache.pekko.persistence.cassandra.reconciler.*"` — passed (7 suites, 10 tests). - `sbt "core/Test/testOnly org.apache.pekko.persistence.cassandra.cleanup.*"` — 19 passed, 1 failed: `CleanupSpec` "delete all for many persistenceId, many events, many snapshots" timed out after 5 seconds at `CleanupSpec.scala:440`. It fails the same way on unmodified `main` locally. - Cassandra was a plain `cassandra:latest` container. `docker compose up cassandra-latest` fails on macOS (`chown` of the mounted `cassandra.yaml` is denied). - `sbt "core/mimaReportBinaryIssues"` — passed. - `sbt core/headerCheckAll core/Test/headerCheckAll` — passed; the new spec's header was generated by sbt. - `scalafmt --mode diff-ref=upstream/main --list` — no changes needed. - `git diff --check` — clean. ### References Refs akka/akka-persistence-cassandra#1056 - upstream fix for failed prepared statements being cached; Refs #106 - Pekko's earlier equivalent, which this extends to the reconciler. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
