concurrency-race-condition-testing
Skill1 starsChanged 54 days agoMITView on GitHub
Use when testing thread-safety, race conditions, deadlocks, double-submit, idempotency, optimistic/pessimistic locking, async ordering bugs, and flaky concurrency failures — with TSan, go -race, stress loops, barrier-based harnesses and parallel API calls.
In this repository98 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- 42crunch-api-security-testingSkill
- a-b-testingSkill
- acceptance-testingSkill
- accessibility-testingSkill
- ai-agent-evaluationSkill
- ai-code-securitySkill
- ai-ml-testingSkill
- analytics-tracking-testingSkill
- api-testingSkill
- authn-authz-testingSkill
- autonomous-qa-orchestrationSkill
- bdd-gherkin-testingSkill
- blockchain-smart-contract-testingSkill
- bug-reportingSkill
- chaos-resilience-testingSkill
- chatbot-voice-agent-testingSkill
- cicd-testingSkill
- cli-testingSkill
- cloud-infrastructure-testingSkill
- code-coverage-analysisSkill
- compatibility-testingSkill
- compliance-testingSkill
- configuration-feature-flag-testingSkill
- contract-testingSkill
- cross-browser-testingSkill
- database-testingSkill
- data-migration-testingSkill
- data-pipeline-etl-testingSkill
- date-time-timezone-testingSkill
- desktop-app-testingSkill
- disaster-recovery-backup-testingSkill
- e2e-testingSkill
- email-notification-testingSkill
- event-driven-messaging-testingSkill
- exploratory-testingSkill
- flaky-test-managementSkill
- functional-testingSkill
- fuzz-testingSkill
- game-testingSkill
- graphql-testingSkill
- iac-container-security-testingSkill
- installation-upgrade-testingSkill
- integration-testingSkill
- iot-embedded-testingSkill
- llm-security-auditSkill
- llm-testingSkill
- localization-testingSkill
- manual-testingSkill
- mcp-testingSkill
- memory-leak-resource-testingSkill
- microservices-testingSkill
- mobile-testingSkill
- mutation-testingSkill
- observability-testingSkill
- payment-ecommerce-testingSkill
- performance-testingSkill
- production-monitoring-synthetic-testingSkill
- property-based-testingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 48
Isolation: no dirty/non-repeatable/phantom reads at the level you claim (READ COMMITTED vs SERIALIZABLE).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Concurrency & Race-Condition Testing
Races don't fail on demand. You must force interleavings and detect violations.
Bug catalog (what to hunt)
Lost update (read-modify-write) · double spend / oversell (check-then-act) · duplicate submit / retry storms · deadlock (lock ordering) · livelock/starvation · stale cache after write · non-atomic multi-step DB ops · async callbacks out of order · TOCTOU file/permission checks · unsafe shared state in singletons · connection/thread-pool exhaustion.
Detection tools
| Stack | Tool |
| Go | go test -race -count=100 ./... |
| C/C++/Rust | ThreadSanitizer (-fsanitize=thread), loom (Rust) |
| Java | jcstress, -XX:+..., Thread dumps, jstack deadlock detection |
| Python | pytest-xdist, threading.Barrier, asyncio.gather stress |
| JS/TS | Promise.all bursts, jest --runInBand vs parallel diff |
| DB | Two sessions + pg_sleep/SLEEP() to widen windows; isolation-level tests |
| System | stress-ng, k6/Locust with identical concurrent requests |
Force the interleaving
# Fire N identical requests at the same instant (double-spend probe)
import threading, requests
N = 20; barrier = threading.Barrier(N); results = []
def hit():
barrier.wait()
results.append(requests.post(URL, json={"coupon":"ONCE"}, headers=H).status_code)
ts = [threading.Thread(target=hit) for _ in range(N)]
[t.start() for t in ts]; [t.join() for t in ts]
assert results.count(200) == 1, results # coupon must apply exactly once# bash/curl burst against an idempotent endpoint
seq 1 20 | xargs -P20 -I{} curl -s -o /dev/null -w "%{http_code}\n" -X POST -H "Idempotency-Key: k1" $URL | sort | uniq -cWhat to assert
- Exactly-once: inventory never < 0; balance conserved; one row per idempotency key; unique constraints hold.
- Isolation: no dirty/non-repeatable/phantom reads at the level you claim (
READ COMMITTEDvsSERIALIZABLE). - Liveness: operations finish under contention (timeouts, no deadlock); lock timeouts surface clean errors.
- Ordering: events processed in key order; consumers tolerate redelivery.
Fix patterns to recommend
Atomic SQL (UPDATE … SET qty = qty-1 WHERE qty>0) · optimistic locking (version column/ETag If-Match) · unique constraints + idempotency keys · advisory locks/SELECT … FOR UPDATE · consistent lock ordering · queue partitioning by key · immutable data.
Reporting
Include seed/iteration count, concurrency level, exact interleaving/log lines, and expected vs observed invariant. Rate by blast radius (money/data loss = Sev1).
Related
api-testing, database-testing, flaky-test-management, chaos-resilience-testing, event-driven-messaging-testing
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

