Skip to content

test: TestIssue1008_HandlerReturns503WhileSubpathIndexLoading races the background index build under load (-race flake) #227

Description

@dborup

Problem

Under CPU load, TestIssue1008_HandlerReturns503WhileSubpathIndexLoading in cmd/server fails occasionally with status = 200, want 503. This was found during the #214 review, which does not touch the store or the index code.

  • The test checks the not-ready window right after Load(). That window races the background subpath index build on the test's 6-transmission fixture. When the build finishes first, the handler already returns 200.
  • Measured with a pre-compiled -race binary:
  • It is a timing flake in the test, not a production bug.

Fix direction

Make the not-ready window deterministic in the test. For example, hold the subpath index build with a test hook or gate until the 503 has been asserted, then release it and assert 200. Do not rely on the build being slower than the request.

Acceptance

  • go test -race -count=200 -run TestIssue1008_HandlerReturns503WhileSubpathIndexLoading ./cmd/server/ passes under parallel CPU load (e.g. alongside another go test -race run).
  • The production readiness behaviour is unchanged.

Activity

  1. added a commit that references this issue on Oct 5, 2026
  2. dborup commented on Oct 5, 2026

    @dborup
    OwnerAuthor

    Fixed by #234 (merged as 3878d7ea).

    PacketStore.subpathBuildGate (nil in production) lets the test hold the background subpath index build until the 503 is asserted, then release it and assert 200. Under load the flake went from about 50/600 to 0/600. Readiness behaviour in production is unchanged, at the cost of one nil check per Load().

    The sibling TestIssue1008_PathHopIndexReadyFalseImmediatelyAfterLoad has the same race class for the path-hop builder (1/900 under heavy load). That, and the unguarded close(building) in the gate, are noted on #237.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions