Skip to content

Make workload activation and deletion state transitions concurrency-safe #445

Closed

Description

@moonlight16

Problem

Workload activation, status refresh, and deletion use read-modify-write updates in Redis without compare-and-set protection. Concurrent requests can overwrite a newer state. For example, an activation or GET refresh can restore a record after deletion and leave Sandbox or Context resources orphaned.

Concurrent creation is already tracked by #356. The GET write-back race is also noted in #363. This issue covers the remaining workload lifecycle as one state-machine problem.

Scope

  • Add versioned or compare-and-set workload record updates.
  • Define allowed state transitions.
  • Prevent GET refresh from overwriting deleting or deleted.
  • Prevent activation from creating or recording Sandboxes after deletion begins.
  • Make cleanup and retry behavior idempotent.
  • Add deterministic concurrent activation/delete and GET/delete tests.

Acceptance criteria

  • A deleted workload cannot return to an active state.
  • Concurrent activation and deletion leave no orphaned Sandboxes or Context storage.
  • Retried operations converge on one valid terminal state.
  • Tests cover the races without timing-dependent sleeps.

Related work

Activity

  1. pdettori commented on Oct 17, 2026

    @pdettori
    Member

    Closing record, mapped to the issue's scope (pinned in #549):

    Known remainder, deliberately left as documented behavior: a create whose process dies between the reservation and the rollback leaves a creating record holding the name and one quota unit until the owner's DELETE clears it. A record TTL would not fix this safely — expiry skips the deleted transition that releases the quota unit, so it would leak permanently.

  2. added a commit that references this issue on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions