Skip to content

[Bug]: logservice HAKeeper bootstrap tests race on ID allocation and initial cluster state #28550

Closed

Description

@gouhongshen

Summary

The unsharded Ubuntu race suite reports unsynchronized HAKeeper bootstrap activity in pkg/logservice, causing two failures in the same package.

Reproduction

Observed

  1. TestBootstrapWaitsForRemoteWALRecovery reports a data race: the HAKeeper ticker calls (*idAllocator).Set through (*store).updateIDAlloc, while bootstrap calls (*idAllocator).Next through bootstrap.Manager.bootstrapLogService. A second race is reported in the test bootstrap callback at store_hakeeper_check_test.go:1173.
  2. TestSetInitialClusterInfo expects 0x4000a but receives 0x4280a at store_hakeeper_check_test.go:955 and :967, while the service logs that initial cluster info is already set.

Expected

HAKeeper bootstrap/ticker state and ID allocation are synchronized so race-enabled logservice tests have deterministic bootstrap state.

Scope

This is unrelated to matrixone#28291: that PR changes only four pkg/fileservice test files and does not touch logservice, HAKeeper, or bootstrap code.

Activity

  1. self-assigned this
    on Sep 9, 2026
  2. added
    kind/bug
    severity/s0
    ai-easy
    and removed on Sep 9, 2026
  3. gouhongshen commented on Sep 9, 2026

    @gouhongshen
    ContributorAuthor

    PR #28554 is trying to fix this issue.

  4. gouhongshen commented on Sep 10, 2026

    @gouhongshen
    ContributorAuthor

    PR #28554 has merged and is awaiting manual validation. The issue remains open.

  5. gouhongshen commented on Sep 10, 2026

    @gouhongshen
    ContributorAuthor

    Recurrence after #28554 merged:

    The test starts tickerForTaskSchedule before proceedHAKeeperToRunning; the ticker can therefore advance the state before the helper checks its intermediate bootstrap state. The service continued into HAKeeper running and allocated the task, but the transient-state assertion had already failed.

    This is the same root-cause class and exact state-value mismatch recorded in this issue. #28554 gave manual bootstrap fixtures exclusive worker ownership, but this test intentionally starts its own ticker before the helper and remains exposed.

    This recurrence is unrelated to PR #28272: pkg/logservice, pkg/hakeeper, and pkg/taskservice are unchanged across its exact base/head. The two failing test-source blobs are identical:

    • store_test.go: 55110833858d0313b28782d072f08db734481cee
    • store_hakeeper_check_test.go: dec77f429a93115b416ac4285941661c683029fa

    Run attempt 1 will receive the single permitted failed-job rerun after the workflow reaches a terminal state.

  6. iamlinjunhong commented on Sep 11, 2026

    @iamlinjunhong
    Contributor

    Recurrence from PR #28633 at exact head d0d1b70daa982c8a8da53e4199629f91bd7f3edd.

    The failed case is pkg/logservice.TestTickerForTaskSchedule under the race-enabled UT path. The complete log reports WARNING: DATA RACE: idAllocator.Capacity() at store_hakeeper_check.go:78 reads while bootstrap calls idAllocator.Next() at line 61 and the ticker/update path calls idAllocator.Set() at line 74. The test terminates with testing.go:1712: race detected during execution of test.

    Independent validation used the repository's mo-cgo-test wrapper with the CI race/tags/mode (-race -tags matrixone_test -vet=off -short -count=1 -timeout=40m -p 1) and the exact test. The PR head passed 3/3 runs. Clean detached up/main at e7d46d6dfb27696211ca828c55e245d3bd1b634d ran the same test 3 times; runs 1 and 2 passed, and run 3 reproduced the same idAllocator.Capacity versus Next/Set race. The PR diff is limited to four frontend/Arrow LOAD files; its dependency closure does not touch pkg/logservice, HAKeeper/bootstrap, idAllocator, or this test.

    This is a recurrence of the HAKeeper bootstrap/ticker ID-allocation race covered by this issue, now with the race detector exposing the unsynchronized Capacity access directly. Run 34490540322 had already consumed its single permitted failed-job rerun (attempt 1 to attempt 2); no second rerun is requested.

  7. XuPeng-SH commented on Sep 11, 2026

    @XuPeng-SH
    Contributor

    Additional occurrence from PR #28459

    The Ubuntu/x86 race suite reproduced the same unsynchronized HAKeeper ID-allocation access in TestTickerForTaskSchedule:

    The race detector reports concurrent unsynchronized access to the allocator's nextID/range state. This is outside PR #28459: the PR changes INSERT IGNORE warning propagation and does not modify pkg/logservice or pkg/hakeeper.

    This occurrence broadens the required fix beyond the two previously observed tests: all allocator readers and writers need one consistent synchronization/atomicity strategy, and the affected logservice tests should pass repeatedly under -race without sleeps or retries masking the race.

    The CodeQL failure on PR #28459 is separate: its annotation is the existing SHA-256/password alert at pkg/sql/compile/scheduler.go:553, also outside that PR's changed files.

  8. XuPeng-SH commented on Sep 11, 2026

    @XuPeng-SH
    Contributor

    Follow-up PR: #28668

    #28668

    This PR closes the confirmed TestTickerForTaskSchedule occurrence by giving manual bootstrap exclusive HAKeeper ownership while retaining the task-scheduling ticker under test, and by joining that ticker before fixture teardown.

    It intentionally does not claim to close the entire issue: TestTaskSchedulerCanReScheduleExpiredTasks still needs a separate single-driver redesign because it relies on background HAKeeper ticks for expiration.

  9. added a commit that references this issue on Sep 11, 2026
    123b4c1
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