Skip to content

[Bug]: TestServiceBootstrapRestoresHAKeeperAndWAL races heartbeat status #26652

Closed

Description

@gouhongshen

Is there an existing issue for the same bug?

  • I searched open and closed issues for TestServiceBootstrapRestoresHAKeeperAndWAL, addWALRecoveryStatus, and the reported race locations; no matching issue exists.

Branch Name

main

Commit ID

Observed on PR head 1e72b8fc371475ed4db93d2e7600d33b6918ea0b; the failing LogService code and test are unchanged by that PR and match its base.

Other Environment Information

Actual Behavior

The race detector fails pkg/logservice.TestServiceBootstrapRestoresHAKeeperAndWAL because the test mutates the service's plain walRecovery.coordinator field while the live heartbeat worker reads it:

WARNING: DATA RACE
Write at ... by goroutine ...:
  pkg/logservice.TestServiceBootstrapRestoresHAKeeperAndWAL()
      pkg/logservice/service_bootstrap_test.go:165

Previous read at ... by goroutine ...:
  pkg/logservice.(*Service).addWALRecoveryStatus()
      pkg/logservice/wal_recovery_status.go:50
  pkg/logservice.(*Service).heartbeat()
      pkg/logservice/service_commands.go:248
  pkg/logservice.(*Service).heartbeatWorker()
      pkg/logservice/service_commands.go:186

NewService derives walRecovery.coordinator from configuration before starting the heartbeat worker, and production code does not mutate that role afterward. The test enables workers, then changes the field directly at lines 153 and 165 to reuse one live service for non-coordinator and coordinator restart scenarios. This violates the field's immutable-after-start ownership contract and races the heartbeat status read.

Expected Behavior

The test should exercise coordinator and non-coordinator restart behavior without mutating immutable service role state while background workers are running. Race-enabled LogService tests should complete without a detector report while preserving all existing recovery assertions.

Steps to Reproduce

  1. Run the focused test repeatedly with the race detector, preferably under runner load:

    .agents/skills/mo-dev/scripts/mo-cgo-test -race \
      -run '^TestServiceBootstrapRestoresHAKeeperAndWAL$' \
      -count=10 -timeout=600s ./pkg/logservice
  2. When a heartbeat reads recovery status after either direct test assignment, observe the race between service_bootstrap_test.go:153 or :165 and wal_recovery_status.go:50.

Additional information

  • A single focused local race run passed in 32.825 seconds, consistent with the heartbeat-dependent scheduling window; the CI race report identifies both conflicting accesses and their goroutine creation stacks.
  • The field and test were introduced together by commit 4f761829b847db116b84b211ee6924303c4fd140 in PR logservice: support offline WAL recovery #25867.
  • The workflow is already on attempt 2, so it must not be rerun again for this PR.
  • The failure is unrelated to PR test(gc): make deleter concurrency check deterministic #26644, whose diff changes only pkg/vm/engine/tae/db/gc/v3/deleter_test.go.

Activity

  1. added
    kind/bug
    on Aug 3, 2026
  2. self-assigned this
    on Aug 3, 2026
  3. added
    severity/s0
    ai-easy
    and removed on Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions