Skip to content

reach_rank tests: onDegreeSnapshotLoad written while a previous test's singleflight refresh still reads it (-race flake) #224

Description

@dborup

Problem

cd cmd/server && go test -race ./... can fail in TestReachRank_RefreshHonoursBackoffAfterQueuedFailure with "race detected during execution of test". This was found during the #222 review, which does not touch these files.

Fix direction

  • Have the earlier test wait for its in-flight refresh to finish before it returns, or
  • make the hook an atomic or a per-server field instead of a package variable.

Acceptance

  • go test -race -count=20 -run 'TestReachRank' ./cmd/server/ passes with no race reports.
  • The full -race suite no longer reports a race in reach_rank.

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).

    TestReachRank_ExpiredSnapshotAlwaysRefreshes now ends with awaitDegreeRefresh, which joins the "degree" singleflight key once more. A late refresh that a caller registered therefore finishes before the test returns, and can no longer read the next test's onDegreeSnapshotLoad hook. This is a test-only change. Under load, the race went from 5/200 processes to 0/200.

    Review nits (moving the join into t.Cleanup, so it also runs on the failure path) 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