Skip to content

test: TestConcurrentSlotWaiterDrainedByShutdown races on a 40 ms sleep #140

Closed

Description

@ThomasK33

TestConcurrentSlotWaiterDrainedByShutdown fails intermittently because it waits on a 40 ms sleep instead of on the state it needs.

What happens

  1. The test fills the only slot (MaxConcurrent = 1) with event first, posts event waiter, then sleeps 40 ms (concurrent_test.go#L207) and calls Shutdown.
  2. It assumes waiter is already blocked on the slot when Shutdown starts, so Shutdown must log chat concurrent slot wait abandoned (concurrent_test.go#L220-L222).
  3. Under load the waiter's tail starts later. In the failing CI run, first was cancelled at 23:40:33.078, and waiter logged chat deferred dispatch started at the same millisecond, after the slot was free. The waiter never waited, so nothing logged "abandoned".

Evidence

Possible fix

Wait until waiter is blocked on the slot before calling Shutdown, for example through an export hook in export_test.go that reports the number of slot waiters, as QueueTurnCount does for the queue. Then remove the sleep.

Owner and trigger

The coder/chat maintainer triages this. Fix it before the next CI flake on this test, or with the next change to the concurrent strategy.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

Activity

  1. added
    needs-triageMaintainer needs to evaluate this issue
    ciContinuous integration / repo automation
    bugSomething isn't working
    ready-for-agentFully specified, ready for an AFK agent
    and removed
    needs-triageMaintainer needs to evaluate this issue
    on Oct 29, 2026
  2. ThomasK33 commented on Oct 30, 2026

    @ThomasK33
    MemberAuthor

    Triage: bug, ready-for-agent. The possible fix in the issue is the plan: add a slot-waiter count hook in export_test.go, wait on it before Shutdown, and remove the 40 ms sleep. It already cost one CI rerun on 7c6ce4a.

    Acceptance: run the loaded reproduction from the issue (16 spinners, 24 batches of 40 runs at -test.cpu=1). It must show failures on main and 0 of 960 failures with the fix. Put both counts in the PR body.


    Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: medium

  3. ThomasK33 commented on Oct 30, 2026

    @ThomasK33
    MemberAuthor

    I corrected the cause in #141. The 40 ms sleep is not the problem. With instrumented runs, every failure showed the waiter had already been waiting on the slot for about 40 ms when Shutdown started.

    Shutdown cancels the detached tails one at a time. When it is preempted during that pass, the first handler returns and frees its slot. The waiter then wins the slot while its own context is still live, and it runs its handler. Nothing logs "chat concurrent slot wait abandoned".

    #141 makes a detached tail that wins a slot after Shutdown began release the slot and abandon the wait. It adds a test that forces the window, and it removes the sleep. On the loaded repro, main fails 3 to 13 of 960 runs and the fix fails 0 of 960, three times.


    Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

  4. added a commit that references this issue on Oct 30, 2026
    db0b34f
  5. ThomasK33 commented on Oct 30, 2026

    @ThomasK33
    MemberAuthor

    Correction to the comment above: #141 does not remove the 40 ms sleep. A review showed that removing it made the old test reach the slot after Shutdown in almost every run, so it rarely checked a parked waiter. The merged version keeps the sleep and fixes the runtime. With the sleep on both sides, the loaded reproduction failed 8 of 960 runs on 7c6ce4a and 0 of 960 on the fix head, three times. The new test TestConcurrentSlotFreedDuringShutdownIsAbandoned covers the race directly.


    Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingciContinuous integration / repo automationready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions