check then act
Reading whether something exists and then acting on the answer as two separate steps, which races under concurrency.
In more detail
Two workers can both check, both see nothing, and both act. Replace it with one atomic step: a unique constraint, a conditional write or a locking read.
Related terms
- race condition — A bug whose outcome depends on the timing of two things happening at once.
- atomic operation — An operation that happens completely or not at all, with no other operation able to see or act in between.
- unique constraint — A constraint that no two rows may have the same value in a column or combination of columns.
Taught in
- Idempotency, And Exactly Once As A Fiction — Scalable System Design & Distributed Architecture