Skip to content

Port akka-core#31753: Run DurableStateBehavior delete effect asynchronously like persist#2752

Merged
pjfanning merged 2 commits intoapache:mainfrom
pjfanning:copilot/port-akka-core-pull-31753
Mar 19, 2026
Merged

Port akka-core#31753: Run DurableStateBehavior delete effect asynchronously like persist#2752
pjfanning merged 2 commits intoapache:mainfrom
pjfanning:copilot/port-akka-core-pull-31753

Conversation

@pjfanning
Copy link
Copy Markdown
Member

Delete effects in DurableStateBehavior were applied synchronously — side effects (thenRun, thenReply) fired immediately without waiting for the store to confirm the delete. This broke command ordering: commands queued after a delete could be processed before the delete completed.

akka/akka-core#31753

part of #2730

Changes

  • Running.scala: Added handleDelete in HandlingCommands that transitions to PersistingState (mirroring handlePersist). Added onDeleteSuccess/onDeleteFailed handlers to PersistingState. DeleteSuccess/DeleteFailure messages were previously Behaviors.unhandled.
  • DurableStateStoreInteractions.scala: Removed onDeleteInitiated hook (unused telemetry stub). Annotated cmd parameter as @nowarn unused.
  • DurableStateBehaviorReplySpec.scala: Renamed test suite; added "handle commands sequentially" test covering mixed increment + delete ordering.
  • DurableStateBehaviorSpec.scala (new): Basic tests for persist, delete, and sequential command handling on DurableStateBehavior.
c ! IncrementWithConfirmation(probe.ref)
c ! IncrementWithConfirmation(probe.ref)
c ! DeleteWithConfirmation(probe.ref)
c ! GetValue(probe.ref)
// Previously: GetValue could resolve before DeleteWithConfirmation completed
// Now: guaranteed ordering — Done, Done, Done, State(0)
probe.expectMessage(Done)
probe.expectMessage(Done)
probe.expectMessage(Done)
probe.expectMessage(State(0))

Copilot AI and others added 2 commits March 18, 2026 09:27
… way as persist

Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>
@pjfanning pjfanning added this to the 2.0.0-M2 milestone Mar 18, 2026
.debug("Received DeleteSuccess response after: {} nanos", System.nanoTime() - persistStartTime)
}

// TODO Might need to call hook method for Telemetry
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHOULD we remove this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't any harm keeping it. It is from the Akka PR

Copy link
Copy Markdown
Member

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pjfanning pjfanning merged commit bac4192 into apache:main Mar 19, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants