concurrency-control
Registry Trigger
Use when
- control concurrent writes races locks leases optimistic conflicts and queues
Do not use when
- no task-local concurrency control decision is required
Skill Role
Preserve named invariants under overlapping writes, retries, leases, redelivery, and stale ownership.
High-Value Rules
- Name the resource and invariant, then choose the narrowest conditional update, compare-and-swap, transaction, partition, or scoped lock.
- Choose optimistic or pessimistic control from measured contention, storage semantics, latency, and recovery cost; no universal conflict-rate threshold is valid.
- Define retry, reject, merge, or escalation; when duplicate effects and the response contract require it, reuse a durable outcome, otherwise prove natural idempotence or safe re-execution.
- Bound and release locks and leases, order multi-resource locks, and reject stale distributed-lease holders with monotonic fencing.
- Prove the invariant with synchronized overlap and allowed-outcome assertions; add race or stress tooling when risk warrants it.
Anti-Patterns
- A
read → decide → act sequence is unsafe unless the store enforces the decision atomically.
- Enqueue deduplication does not make consumer side effects exactly once.
Execution Checklist
- Identify resources, invariants, overlap, and atomicity gaps.
- Specify mechanism, conflict response, retry/idempotency, lock order, and fencing.
- Verify deterministic race outcomes and the forbidden stale or duplicate effect.
Stop Conditions
Escalate when money, inventory, permissions, quotas, or cross-service reservations can violate an invariant, a distributed lease lacks fencing, or recovery is unproven.
Output Contract
- concurrency plan with critical sections locks conflicts and tests, evidence, and proof limits
Targeted References
| Path |
Type |
Load when |
Do not load when |
Required by |
Required output |
| benchmarks and patterns |
benchmark-pattern |
Lost updates, stale ownership, deadlocks, or contention need mechanism selection |
No overlapping actor can mutate the affected invariant |
analysis-agent, task-agent, review-agent |
option-comparison, selected-approach |
| checklist |
decision-checklist |
Concurrency spans retries, cancellation or timeout, lease ownership or another time-derived ownership claim, lock order, version reuse or ABA, duplicate effects, or scheduling fairness |
The resource has one serialized owner |
analysis-agent, task-agent, review-agent |
checklist-result, residual-risk |
| evidence patterns |
evidence-pattern |
Safety claims require synchronized overlap or contention artifacts |
No interleaving or ownership claim awaits proof |
analysis-agent, task-agent, review-agent |
evidence-record, proof-limit, residual-risk |
1---2name: concurrency-control3description: "`analysis-agent`/`task-agent`/`review-agent`: primary-Skill-selected for races, locks, optimistic conflicts, or worker overlap; never task owner; skip without concurrency impact."4metadata:5 source: https://skillmd.com/skills/machenjie/concurrency-control6---78# concurrency-control910## Registry Trigger1112**Use when**1314- control concurrent writes races locks leases optimistic conflicts and queues1516**Do not use when**1718- no task-local concurrency control decision is required1920## Skill Role2122Preserve named invariants under overlapping writes, retries, leases, redelivery, and stale ownership.2324## High-Value Rules2526- Name the resource and invariant, then choose the narrowest conditional update, compare-and-swap, transaction, partition, or scoped lock.27- Choose optimistic or pessimistic control from measured contention, storage semantics, latency, and recovery cost; no universal conflict-rate threshold is valid.28- Define retry, reject, merge, or escalation; when duplicate effects and the response contract require it, reuse a durable outcome, otherwise prove natural idempotence or safe re-execution.29- Bound and release locks and leases, order multi-resource locks, and reject stale distributed-lease holders with monotonic fencing.30- Prove the invariant with synchronized overlap and allowed-outcome assertions; add race or stress tooling when risk warrants it.3132## Anti-Patterns3334- A `read → decide → act` sequence is unsafe unless the store enforces the decision atomically.35- Enqueue deduplication does not make consumer side effects exactly once.3637## Execution Checklist38391. Identify resources, invariants, overlap, and atomicity gaps.402. Specify mechanism, conflict response, retry/idempotency, lock order, and fencing.413. Verify deterministic race outcomes and the forbidden stale or duplicate effect.4243## Stop Conditions4445Escalate when money, inventory, permissions, quotas, or cross-service reservations can violate an invariant, a distributed lease lacks fencing, or recovery is unproven.4647## Output Contract4849- concurrency plan with critical sections locks conflicts and tests, evidence, and proof limits5051## Targeted References5253| Path | Type | Load when | Do not load when | Required by | Required output |54|---|---|---|---|---|---|55| [benchmarks and patterns](references/benchmarks-and-patterns.md) | benchmark-pattern | Lost updates, stale ownership, deadlocks, or contention need mechanism selection | No overlapping actor can mutate the affected invariant | analysis-agent, task-agent, review-agent | option-comparison, selected-approach |56| [checklist](references/checklist.md) | decision-checklist | Concurrency spans retries, cancellation or timeout, lease ownership or another time-derived ownership claim, lock order, version reuse or ABA, duplicate effects, or scheduling fairness | The resource has one serialized owner | analysis-agent, task-agent, review-agent | checklist-result, residual-risk |57| [evidence patterns](references/evidence-patterns.md) | evidence-pattern | Safety claims require synchronized overlap or contention artifacts | No interleaving or ownership claim awaits proof | analysis-agent, task-agent, review-agent | evidence-record, proof-limit, residual-risk |