pjfanning opened a new pull request, #335: URL: https://github.com/apache/pekko-persistence-r2dbc/pull/335
part of #332 port from akka/akka-persistence-r2dbc#278 Soft-delete semantics were missing for `DurableState`: `deleteObject(revision > 0)` was performing a hard row deletion instead of preserving revision history, and `changesBySlices`/`currentChangesBySlices` never emitted `DeletedDurableState`. ## Core changes - **`SerializedStateRow.payload`**: `Array[Byte]` → `Option[Array[Byte]]`; `null` = lazy backtracking load, `Some(bytes)` = normal payload, `None` = delete marker - **`deleteState(persistenceId, revision)`**: `revision == 0` → hard delete (previous behavior); `revision == 1` → insert delete marker row; `revision > 1` → update row with `serId=0`, empty payload, new timestamp — preserving revision number in DB - **`updateStateSql`**: `val` → `def(updateTags: Boolean)` so delete writes don't clobber the tags column - **Backtracking SQL**: adds `state_ser_id` to the backtracking `SELECT` to detect delete markers without a schema change - **`rowsBySlices`**: sets `payload = None` (vs `null`) for delete-marker rows during backtracking ## Store / projection - **`R2dbcDurableStateStore.createEnvelope`**: matches on `null` / `Some` / `None` to emit `UpdatedDurableState` (lazy), `UpdatedDurableState` (loaded), or `DeletedDurableState` respectively - **`R2dbcProjectionImpl`**: lazy-load path now returns `DeletedDurableState` when `getObject` resolves to `None` instead of throwing - **`R2dbcOffsetStore`**: handles `DeletedDurableState` in `createRecordWithOffset` (`envelopeLoaded = true`) ## Tests - `DurableStateStoreSpec`: replaces old deletion tests with "hard delete when revision=0", "delete payload but keep revision", "update revision when deleting", concurrent delete rejection tests - `DurableStateBySliceSpec`: adds "emit DeletedDurableState for latest deleted state" and "find delete" (live query) - `TestActors.DurableStatePersister`: adds `DeleteWithAck` command wrapping `Effect.delete()` -- 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]
