Concurrency and Ordering Check
Send several requests at once and confirm replies stay attributable and the server stays consistent
Use when: the server indexes files or holds state that concurrent calls could race on
Avoid when: the server serialises all work by design and concurrency cannot occur
Procedure
- Write several requests with distinct ids
- Send them without waiting for individual replies
- Read replies and match each to its id
- Check that no reply is missing or duplicated
- Confirm the index was not left in a torn state after concurrent reads and one reload
- Record the observed ordering for the notes, since it is not guaranteed
Signals
- every id appears exactly once in the replies
- reply order differs from request order without breaking attribution
- a concurrent reload does not produce a partial index
- the server stays responsive throughout
Patterns
1. Distinct ids
requests 1..5 sent in one write
2. Attribution
replies keyed by id, never by arrival order
3. Torn state check
search after reload returns the same count
Pitfalls
- Assuming replies arrive in request order
- Reloading the index mid-call and reading a half-built list
- Treating a duplicated id as harmless when it means a lost reply
Done when
- every request id is answered exactly once
- the index is consistent after a concurrent reload