Concurrency and race-condition testing ideas
When many things happen at once, results can depend on who is first. Learn what concurrency, a race condition and a deadlock are, and how to test for them with repeats and checks.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: the last slice of cake. Two people see one slice left. Each looks, sees it, and reaches out at the same moment. Only one can have it, but both believed they could. The fault is not in either person. It is in the timing.
Daily List is a to-do list app. Lily and a friend both edit the same shared task at the same moment. One change quietly disappears.
Concurrency means many things happening at the same time inside one system. A is a fault where the result depends on which action happens to finish first. A deadlock is a freeze where two actions each wait for the other to finish.
Tom hears about the lost change from Lily. He cannot repeat it by hand, because he cannot press two buttons at exactly the same moment. He learns that he needs a way to make the timing happen on purpose.
The picture has a limit. People can see each other reaching. Software parts cannot, so the fault stays hidden until the timing lines up.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)
PLAIN WORDS · 2 in this section
- concurrency
- many things happening at the same time
- deadlock
- a stop where neither side can move
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Finding faults that appear only when two things happen at the same time, by forcing the timing and checking a rule.
- Two reach out
- Force the timing
- Check the slice count
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| Two people see one slice of cake | Two requests pass the same check |
| Both reach out at the same moment | Concurrency |
| Both believed they could take it | A race condition |
| Two people each waiting for the other to let go | A deadlock |
WHERE THIS PICTURE STOPS
- People can see each other reach, but software parts cannot.
- A cake has one slice left, while software may have many shared items.
- A cake race ends at once. A software race may show up once in many runs.
HOOK
Same moment, check the rule.
REMEMBER IT THIS WAY
A rule of thumb: if you see this, think that.
If a change vanishes only when two people act at the same moment, usually make the timing happen on purpose. Pressing two buttons by hand will not do it.
| In the trick | What it stands for |
|---|---|
| Race condition | a fault where the result depends on which action finishes first |
| Deadlock | a freeze where two actions each wait for the other |
A lost change that has nothing to do with timing will not appear however carefully you force the moment.
TELL A FRIEND
Two people reach for the last slice at the same moment, and each believed it was free. A test forces that moment and checks who got it.
OFTEN MIXED UP WITH Performance testing ideas: load, stress, spike, soak. The performance ideas lesson asks how the system copes with a crowd. This lesson asks whether answers stay right when two actions meet.
PRACTISE AND KEEP
Sources for this topic — 6 sources
- Market practice
Testing for Race Conditions (Open Worldwide Application Security Project wiki) ↗ — Open Worldwide Application Security Project (OWASP) · Archived wiki page on testing for race conditions in web applications, where data read at one moment is used later and may have changed in between (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Archived wiki page. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Concurrency testing and race conditions guide (QASkills blog) ↗ — QASkills · Guide: release many workers at once, hit the check-then-act path and assert that totals and counters stay correct, because sequential tests can pass while the bug remains (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Concurrency testing guide (Pinpoint blog) ↗ — Pinpoint · Guide: run the same operation from several threads against one shared resource and check the final state is correct (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Debugging Intermittent Test Failures (Firefox source docs) ↗ — Mozilla · Registry entry for the Firefox source documentation on intermittent failures. Used for the idea that a failure that comes and goes needs repeated runs and logs. Not reopened in this run.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition ↗ — MITRE (Common Weakness Enumeration) · r10h-cwe-367-toctou. Search excerpt, page not opened.
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Explicit locking, deadlocks (PostgreSQL documentation) ↗ — PostgreSQL Global Development Group · Official statement that PostgreSQL detects deadlocks and aborts one transaction (search excerpt, page not opened) | Historical initial-access note retained above. Later selected-source check: PostgreSQL18 §13.3.4 Deadlocks: the operative passage was opened7 November2026; two or more transactions can deadlock and PostgreSQL detects the cycle and aborts a participant. Other implementations may differ.
Found through a web search; the page was not opened (pending verification: official page not opened and not searched (web-search limit reached before the check); URL is the publisher's known address). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.