Resource-Level Locking

Velocity uses resource-level conflict detection instead of state-level locks. Two transactions only conflict if they modify overlapping resources.

Conflict Detection

At commit time, Stategraph checks whether any other concurrent transaction touches the same resources. A transaction conflicts with another if:

  • The other transaction is currently committing and touches overlapping resources
  • The other transaction committed after the current transaction was created and touches overlapping resources

Transactions that touch different resources never conflict, regardless of whether they operate on the same state.

Conflict Handling

If a conflict is detected at commit time:

  1. The commit is rejected (HTTP 409)
  2. The response includes the conflicting transaction IDs
  3. Re-run stategraph tf plan to incorporate the latest state
  4. Retry the commit

Concurrency

Non-overlapping transactions run in parallel through the entire lifecycle:

  • Concurrent plans — Multiple transactions can plan simultaneously against the same state
  • Concurrent applies — Transactions touching different resources apply simultaneously
  • Cross-state — Conflict detection works across state boundaries for multi-state transactions