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:
- The commit is rejected (HTTP 409)
- The response includes the conflicting transaction IDs
- Re-run
stategraph tf planto incorporate the latest state - 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