pjfanning opened a new pull request, #514: URL: https://github.com/apache/pekko-persistence-cassandra/pull/514
### Motivation `Buffer.add` relies on the invariant that a buffer only holds `pending` writes when `writeRequired` is set; when a batch fills it checks `require(pending.isEmpty, "Pending should be empty if write not required")`. `Buffer.addPending` broke that invariant: called on a buffer whose `writeRequired` was `false`, it left `pending` non-empty with `writeRequired = false`, so a later `add` filling the batch would throw and crash the `TagWriter`. ### Modification Port of akka/akka-persistence-cassandra#1015 (Akka Persistence Cassandra 1.2.0, Apache 2.0 since its change date 2026-10-25): `addPending` sets `writeRequired = true`. Added a `BufferSpec` case covering `addPending` on a buffer that does not yet require a write, followed by an `add` that fills the batch and a `writeComplete`. ### Result `Buffer` keeps its `writeRequired || pending.isEmpty` invariant after `addPending`. In the current `TagWriter`, `addPending` is only used in `writeInProgress`, and the next step is always `writeComplete`, which rebuilds the buffer from `pending` before any `add`. So I did not find a production path that reaches the failing `require` today; this hardens the `Buffer` contract rather than fixing an observed crash. ### Tests - `sbt "core/Test/testOnly org.apache.pekko.persistence.cassandra.journal.BufferSpec"` — passed (12 tests). Without the fix the new case fails: `false did not equal true (BufferSpec.scala:227)` on `shouldWrite()` after `addPending`. Needs no Cassandra. - `sbt "core/mimaReportBinaryIssues"` — passed. - `scalafmt --mode diff-ref=upstream/main --list` — no changes needed. - `git diff --check` — clean. ### References Refs akka/akka-persistence-cassandra#1015 - source of the fix (Akka Persistence Cassandra 1.2.0, BSL change date 2026-10-25). -- 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]
