Automation · Parallelism & Concurrency
Race Conditions
Cheat sheet · https://pcornel.dk/topic.php?topic=5991
Answer
A race condition is a bug where the result depends on timing, such as two jobs allocating the same IP or editing the same file. Prevent it with locks, atomic operations and idempotent design.
Remember
- Race conditions depend on timing between jobs.
- Typical case: two jobs allocate the same IP.
- Locks and atomic operations prevent them.
First checks
- Shared resources identified — risk
- Atomic operations / compare-and-swap — safety
- Tests with concurrency — detection
Verify in this order
parallel tasks → shared resource → lock/atomic op
Where it usually breaks
Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5991