A periodical about version control, git, and the future of agentic version control.

Concurrency Bugs in Multi-Step User Flows

Overlapping requests break flows that pass every solo test.

· 8 min read
Cover illustration for “Concurrency Bugs in Multi-Step User Flows”
End-to-End Regression Testing · November 29, 2026 · 8 min read · 1,910 words

Concurrency bugs in multi-step user flows are predictable failures of interaction. Software tested one operation at a time must serve overlapping requests in production. Making those flows reliable requires identifying the race windows, closing them where state changes, and independently verifying that later changes do not reopen them.

Why multi-step flows behave differently under concurrent load than they do in testing

A checkout, approval chain, RSVP, or budget-allocation flow usually appears in testing as an orderly sequence. A tester or automated suite completes one scenario before moving to the next, under controlled conditions. Production imposes a different order of events. Thousands of users can move through those same steps at once, while requests overlap in ways the application cannot predict. A decision that was valid when a flow began may no longer be valid when it commits.

Two operations can each behave correctly in isolation and produce an incorrect result when their steps interleave. The gap reflects how test environments are provisioned and QA workflows are designed. Those environments rarely recreate the ways sessions can affect each other when they overlap.

The four failure modes that account for most production concurrency incidents

Race conditions arise when correctness depends on the timing of operations that share state. In the classic inventory example, two users both pass an availability check before either completes the reservation. Both receive confirmation, but only one item ships. The other customer receives an apology. The application has treated the sequence of checking, reserving, and completing as if no competing request could intervene.

A time-of-check-to-time-of-use, or TOCTOU, window is a specific subclass of that race. The condition checked at decision time becomes invalid before execution. Approval chains and budget-allocation flows expose this gap clearly. By the time a later step uses an approved condition, a parallel request may have changed it.

Double-submit has a different trigger but a related structure. Two requests arrive together and both pass the “has this been submitted?” check before either commits. The customer is charged twice, or duplicate records appear. Disabling a button after a click removes one route to duplication, but it does not protect the server from replay.

Cache stampedes occur when multiple processes find the same stale entry and refresh it from origin simultaneously. The origin absorbs the requests the cache was meant to intercept. A related write-versus-cache-update race can also prolong stale data and give users inconsistent information. Neither requires a visibly broken individual request. Beyond these four modes, transaction sequences can produce deadlocks when processes each hold a lock the other needs, blocking progress in a combination that single-user testing rarely creates.

What these failure modes look like in real production systems

The janonisme/backend PR #22 described an investigation into a volunteer-budget race, in which eight concurrent-user tests with production pool settings found three live race conditions. The findings included an amplify “done” state that was never counted in team activity. Not every failure produced a visible error. The missing activity represented silent data-integrity loss, showing why error counts alone cannot describe the effect of concurrent execution.

The activepieces issue #14795, documented in August 2026, exposed silent data loss during concurrent flow edits. Its “X is editing this flow” banner existed only on the client. The server never rejected a conflicting write. A prior PR had added the banner lock while removing the previous server-side guard, leaving REST, MCP, and agent callers on the same unprotected write path. By the time a second writer’s POST committed, the state it had read could be outdated without any conflict signal reaching the application.

The objectstack-ai/objectstack issue #24817 concerned the wrong submitter identity in a multi-step approval. A later PR had changed the execution context handed to an approval node, breaking previously correct behavior. Existing tests did not cover concurrent, multi-step execution context. Unlike an inventory collision, this failure concerned which actor’s identity reached a later step. Shared state includes execution context alongside balances and editable records.

How the same failure modes scale into multi-agent and event-driven pipelines

The same race-condition logic applies when agents execute the steps. What changes is the response to ambiguity. In response to a duplicate execution, an LLM can misattribute state changes or attempt invalid recovery. A local coordination failure can therefore mutate downstream records.

EventBridge, SQS, and SNS provide at-least-once delivery. An agent’s tool call may succeed while the Lambda response times out before the orchestrator receives acknowledgment. Replaying the event then repeats the action. If the LLM sees identical tool outputs and concludes that the first attempt failed, its recovery can compound the duplicate.

Parallel agents also reproduce the inventory race through the “passing ships” problem. Two agents read the same account state, then proceed independently. One issues a refund while the other places an order, and the account goes negative. Neither has coordinated its action with the other. Shared mutable variables can also let one user’s data enter another agent session’s context, which puts compliance at risk.

Lifecycle and resource limits widen this risk. Cancellation does not automatically cross HTTP boundaries, so remote sub-agents can continue after their parent workflow is cancelled. Passing full outputs down a chain can also exhaust context limits, leaving later agents with truncated input. When branches compete for the same budget, resource exhaustion interacts with concurrency. Correctness consequently depends on controlling both state changes and the lifetime of the work that performs them.

Why sequential testing cannot surface these bugs and what coverage actually requires

Sequential tests lack the triggering condition for these failures. They verify operations in a predictable order, while concurrency correctness depends on the timing of overlapping sessions. More isolated assertions do not create that overlap. The defect can sit between two independently correct calls, beyond the behavior either test observes.

To cover that overlap, concurrent-user tests need to run the same multi-step flow from multiple sessions against a realistic database configuration. The environment helps set which operations can overlap. Recreating those interactions requires infrastructure and test-design work that organizations often defer until an incident exposes the gap.

Different failure modes also require different assertions. Idempotency tests replay requests or events and check that the outcome remains identical to the first execution. State-threading tests verify the actor scoped to each approval step rather than accepting context inherited from the previous decider. Agent pipelines need poison-pill resilience tests that inject duplicate events. Their checks must cover both repeated actions and invalid recovery paths, because preventing a duplicate write alone does not establish that the agent interpreted the event correctly.

Architectural patterns that eliminate the race windows rather than just detecting them

The architectural remedy is to enforce correctness where state is written. Idempotency keys and database unique constraints stop concurrent requests from creating the same business operation twice. A business-meaningful key can identify an order, event, or job run. The database rejects a conflicting write at the constraint level, instead of relying on two application checks to remain in agreement. This protection works whatever the client-side button does.

Critical reservation steps need protection across the check-and-write operation. Pessimistic locking holds the row in question until that operation finishes, so competing requests cannot proceed on the false assumption that the resource is available. The volunteer-budget fix used a Postgres advisory lock held until deliveries commit. Its scope was the reserved resource.

Collaborative editing needs a different mechanism because a visible editing lock does not cover every writer. With optimistic concurrency control, a caller submits the version it read with its write, and the server returns a 409 if that version has changed. The activepieces fix requires this protection on the draft flow version. Same-user sessions can conflict with each other too. Enforcing the version check on the write path covers UI editors, REST callers, MCP tools, and agents uniformly.

Event-driven agent pipelines can apply idempotency at two layers. A DynamoDB conditional write with a TTL claims an exclusive execution lock before an agent acts, rejecting duplicate events. Deterministic Step Functions execution names then prevent a second orchestration run if the lock succeeds but orchestration crashes. The TTL clears stale locks after hard failures.

Agent lifecycles require similarly explicit boundaries. Structured concurrency arranges tasks in a tree, with parents waiting for children, errors propagating upward, and cancellation flowing downward. Cancellation still needs a signal sent across HTTP boundaries. Session-isolated context prevents parallel runs from sharing mutable state, while scoped agentic identity limits access to that state. The Cloud Security Alliance describes an emerging layered model using OAuth 2.1 for tool-access authorization, complementing rather than replacing isolation within the application.

How verification at the PR stage catches concurrency regressions before they reach production

The approval-flow regression changed execution context, while the concurrent-edit regression removed a server guard when a client-side feature changed. Both passed their existing tests. PR-stage verification addresses that risk by testing the changed system before it becomes eligible for review and merge.

For a team protecting these flows, the concurrent-user suite must run against the PR branch. Gating that suite in CI makes a detected race regression block merge. UI flows also require concurrent sessions in a real browser. Checking that a page renders cannot establish that two users can safely complete the journey together.

An independent browser agent can exercise the affected journey after a coding agent changes it. The verification should encode the expected user outcome rather than an exact selector path, allowing it to survive UI redesigns. Independence is central to this arrangement. The agent that wrote the fix has already adopted an explanation of the flow, whereas a separate verifier tests the behavior under overlapping execution.

Code review adds a check before humans review the change. A reviewer agent can examine idempotency handling, lock scopes, and unprotected write paths against the mapped repository. The sequence is analyzer, developer, then reviewer. Browser execution tests the outcome, while code review examines protections that may not fail during a particular run. Neither substitutes for the architectural guarantees beneath them.

Closing the loop: from production signal back to verified fix without manual triage

A concurrency-aware workflow begins with a production signal from Sentry, CloudWatch, or a flapping alert in Slack. The trigger itself needs deduplication before the investigation starts. A unique index on the issue identifier can enforce once-per-issue agent invocation. Without that check, repeated alerts could make the repair workflow run the same work more than once.

An investigating agent then works from the stack trace, relevant git history, and affected code paths to locate a race window or missing idempotency guard. The fix for that fault goes into a draft PR with a regression test. Uncertainty needs an explicit stopping rule. The agent should change code only when the root cause is clear and the fix is scoped to a small number of files, leaving a diagnosis when those conditions are not met.

The draft PR then triggers independent verification of the affected flow, including concurrent browser sessions where the journey has a UI. The verifier is separate from the agent that wrote the change. Automated review checks the protections before engineers decide whether to merge. This takes production evidence through to a tested repair without a person having to guide each step.

Humans still decide the priorities, approval rules, and merges. Their review begins with a proposed fix that has already been investigated, written, tested, and independently examined. Nothing merges without human approval. The loop handles the volume of investigation and verification, while engineers apply judgment at the decision that commits the repair.

More in End-to-End Regression Testing