Skip to content

Improve idempotency of the Prepare() call when handling duplicate requests for the same claim #729

@shivamerla

Description

@shivamerla

During Prepare(), we rely on checkpoint data to ensure idempotency. If a claim’s checkpoint state is already ClaimCheckpointStatePrepareCompleted, we should skip device preparation on subsequent calls. However, the current flow incorrectly regresses the state from PrepareCompleted back to PrepareStarted, causing devices to be re-prepared.

Sequence of events:

1st Prepare() call

  • Load checkpoint into local checkpoint.
  • updateCheckpoint() immediately persists the state to ClaimCheckpointStatePrepareStarted.
  • Devices are prepared.
  • updateCheckpoint() persists the state as ClaimCheckpointStatePrepareCompleted.

2nd Prepare() call

  • Load checkpoint into local checkpoint (set toClaimCheckpointStatePrepareCompleted).
  • updateCheckpoint() immediately overwrites persistent state to ClaimCheckpointStatePrepareStarted.
  • Local checkpoint still shows ClaimCheckpointStatePrepareCompleted, so we skip device preparation.
  • Persistent state is now incorrectly set to ClaimCheckpointStatePrepareStarted again.

3rd Prepare() call

  • Load checkpoint into local checkpoint (now set to ClaimCheckpointStatePrepareStarted).
  • updateCheckpoint() again sets state to ClaimCheckpointStatePrepareStarted.
  • Local state is notClaimCheckpointStatePrepareCompleted, so devices are prepared again.

The fix for this is proposed with the PR.

Metadata

Metadata

Assignees

Labels

backport-25.8bugIssue/PR to expose/discuss/fix a bug

Type

No type

Projects

Status

Backlog

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions