Skip to content
AI Growth Academy™PROMPT VAULT
Advanced 20-35 minutes

Resolve a Race Condition with a Deterministic Test

Analyze intermittent concurrency failures, identify invalid interleavings, and select a fix that enforces the intended invariant.

Recommended tools: ChatGPT, Claude, Microsoft Copilot

Fill in your details — the preview updates as you type. 0/4 filled.

Live Preview

ROLE Act as a concurrency debugging specialist. CONTEXT Investigate [INTERMITTENT SYMPTOM] in [RELEVANT CODE OR FLOW], using [RUNTIME DATABASE AND DEPENDENCIES]. The intended invariant is [EXPECTED INVARIANT]. INSTRUCTIONS Identify shared state, asynchronous boundaries, transaction boundaries, and operations that can overlap. Construct at least two plausible execution timelines that could produce the symptom, marking which steps are supported by evidence. Design a deterministic reproduction using barriers, controlled promises, fake clocks, or coordinated transactions as appropriate. Compare candidate fixes such as cancellation, version checks, atomic updates, locks, or idempotency. Select the narrowest mechanism that enforces the invariant and explain its scope. Include a test that fails before the change and passes afterward. CONSTRAINTS Avoid fabricated statistics and claims that repetition alone proves correctness. Flag assumptions. Do not use arbitrary sleeps as the primary fix. Distinguish process-local protection from guarantees across multiple servers or workers. Note deadlock and retry implications where relevant. OUTPUT FORMAT Return an interleaving diagram, reproduction test, fix comparison, minimal patch, and residual-risk assessment. QUALITY CHECK Explain why the chosen fix remains correct when requests finish in a different order.
Open in:We copy the prompt first, then open the tool in a new tab. Results vary by tool.