Skip to content

test(logservice): isolate manual HAKeeper bootstrap fixtures - #28554

Merged
XuPeng-SH merged 1 commit into
matrixorigin:mainfrom
gouhongshen:agent/issue-28550-6ed8ca3a
Sep 10, 2026
Merged

XuPeng-SH merged 1 commit into
matrixorigin:mainfrom
gouhongshen:agent/issue-28550-6ed8ca3a

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #28550

What this PR does / why we need it:

Root cause

runHAKeeperStoreTest started the production HAKeeper ticker while several tests directly drove bootstrap transitions on the same store. After the ticker cadence was shortened, the two owners could concurrently allocate IDs and advance the replicated state. This caused the reported idAllocator.Set/Next race, the test callback race, and nondeterministic initial-cluster watermarks.

Changes

  • Split the HAKeeper store fixture into ticker-enabled and manual-bootstrap modes.
  • Run tests that directly call bootstrap/checker transitions in manual mode (DisableWorkers=true), leaving ticker-dependent task fixtures unchanged.
  • Apply manual mode to initial-cluster, restore, bootstrap-cadence, recovery-bootstrap, and shared bootstrap tests.

Issue-to-test proof

Related to #28550:

  • TestSetInitialClusterInfo asserts that repeated initial-cluster proposals and rejected watermark restore leave the initial ID watermarks unchanged.
  • TestBootstrapWaitsForRemoteWALRecovery drives bootstrap through the remote WAL-recovery gate and verifies it remains deterministic.
  • Each reported test passed independently under -race -count=100; no race was reported.

Tests

  • mo-cgo-test -race -count=100 -run ^TestSetInitialClusterInfo$ ./pkg/logservice — PASS (19.430s)
  • mo-cgo-test -race -count=100 -run ^TestBootstrapWaitsForRemoteWALRecovery$ ./pkg/logservice — PASS (26.378s)
  • Focused manual-bootstrap consumer group, normal and -race — PASS.
  • GOWORK=off go vet -mod=readonly ./pkg/logservice with repository CGo include/library paths — PASS.
  • Full pkg/logservice normal run was attempted but is not a green result: a user-owned local minio process occupies 127.0.0.1:9001, causing the unrelated fixed-port TestNotHAKeeperErrorIsHandled startup failure and subsequent suite contamination. The process was not modified.

Residual risks

This is test-only fixture isolation. Production ticker behavior and ticker-dependent task fixture behavior are unchanged. Linux CI remains the final cross-platform validation.

@gouhongshen

gouhongshen commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Resolved CI blocker: #28546 was closed after main commit 7c643f4 removed the exact unused helper reported by arm64 SCA. This PR is rebased onto that commit and has a fresh CI head; no unresolved unrelated CI blockers remain.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force review conclusion: APPROVE. Exact head: 3023c77

No confirmed blocker found. Manual HAKeeper bootstrap now disables the competing ticker before construction, preserves Dragonboat replication, and retains the existing success/failure/recovery/watermark assertions. Cleanup and ownership paths remain coherent.

Non-blocking observations: the migrated tests do not prove automatic ticker scheduling or real admission/port release; construction assertions at store_hakeeper_check_test.go:428 remain nonfatal; shutdown and startup timing were not fault-tested.

CI run 34421377268 was still queued at review time, and the prior run had cancelled checks. I did not independently run local Go UT/race/vet, live cluster tests, fault injection, benchmarks, or compatibility testing.

@XuPeng-SH
XuPeng-SH merged commit 1c28541 into matrixorigin:main Sep 10, 2026
39 of 43 checks passed
XuPeng-SH pushed a commit that referenced this pull request Sep 10, 2026
## What type of PR is this?

- [x] BUG
- [ ] API-change
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to #28551

## What this PR does / why we need it:

### Root cause

Before the current `main` baseline, `TestFailedBootstrap` directly
overwrote `bootstrapCheckDeadline` while the HAKeeper ticker could read
it. The broader fixture race is now eliminated by #28554, which runs
manual bootstrap tests with workers disabled. This test still bypassed
the deadline owner to force expiry instead of using the existing
explicit-time bootstrap-check seam.

### Changes

- Drive failure expiry through `checkBootstrapWithSetterAt` with a
deliberately expired time.
- Use the production state setter and require that the replicated state
transition succeeds.
- Preserve the failure oracle: incomplete bootstrap transitions to
`HAKeeperBootstrapFailed`.

### Issue-to-test proof

`TestFailedBootstrap` exercises the same incomplete-bootstrap failure
path without mutating the production-owned deadline. The normal
bootstrap and remote WAL-recovery consumers of the shared helper remain
covered as controls.

### Tests

- `.agents/skills/mo-dev/scripts/mo-cgo-test -list
^(TestFailedBootstrap|TestBootstrap|TestBootstrapWaitsForRemoteWALRecovery)$
./pkg/logservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s -run
^(TestFailedBootstrap|TestBootstrap|TestBootstrapWaitsForRemoteWALRecovery)$
./pkg/logservice` (passed after rebase onto main@ac660ae56e, 1.545s)
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100
-timeout=240s -run ^TestFailedBootstrap$ ./pkg/logservice` (passed after
rebase onto main@ac660ae56e, 19.269s)

BVT is not applicable: this is an internal Go test ownership and
state-transition contract with no SQL or client-visible behavior.

### Residual risk

Production code is unchanged. #28554 in the base branch owns ticker
isolation for manual bootstrap fixtures; this PR is limited to the
deadline-driving seam. Fresh Linux CI is required after the rebase.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rigin#28554)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#28550

## What this PR does / why we need it:

### Root cause

`runHAKeeperStoreTest` started the production HAKeeper ticker while
several tests directly drove bootstrap transitions on the same `store`.
After the ticker cadence was shortened, the two owners could
concurrently allocate IDs and advance the replicated state. This caused
the reported `idAllocator.Set`/`Next` race, the test callback race, and
nondeterministic initial-cluster watermarks.

### Changes

- Split the HAKeeper store fixture into ticker-enabled and
manual-bootstrap modes.
- Run tests that directly call bootstrap/checker transitions in manual
mode (`DisableWorkers=true`), leaving ticker-dependent task fixtures
unchanged.
- Apply manual mode to initial-cluster, restore, bootstrap-cadence,
recovery-bootstrap, and shared bootstrap tests.

### Issue-to-test proof

Related to matrixorigin#28550:

- `TestSetInitialClusterInfo` asserts that repeated initial-cluster
proposals and rejected watermark restore leave the initial ID watermarks
unchanged.
- `TestBootstrapWaitsForRemoteWALRecovery` drives bootstrap through the
remote WAL-recovery gate and verifies it remains deterministic.
- Each reported test passed independently under `-race -count=100`; no
race was reported.

### Tests

- `mo-cgo-test -race -count=100 -run ^TestSetInitialClusterInfo$
./pkg/logservice` — PASS (19.430s)
- `mo-cgo-test -race -count=100 -run
^TestBootstrapWaitsForRemoteWALRecovery$ ./pkg/logservice` — PASS
(26.378s)
- Focused manual-bootstrap consumer group, normal and `-race` — PASS.
- `GOWORK=off go vet -mod=readonly ./pkg/logservice` with repository CGo
include/library paths — PASS.
- Full `pkg/logservice` normal run was attempted but is not a green
result: a user-owned local `minio` process occupies `127.0.0.1:9001`,
causing the unrelated fixed-port `TestNotHAKeeperErrorIsHandled` startup
failure and subsequent suite contamination. The process was not
modified.

### Residual risks

This is test-only fixture isolation. Production ticker behavior and
ticker-dependent task fixture behavior are unchanged. Linux CI remains
the final cross-platform validation.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [x] BUG
- [ ] API-change
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#28551

## What this PR does / why we need it:

### Root cause

Before the current `main` baseline, `TestFailedBootstrap` directly
overwrote `bootstrapCheckDeadline` while the HAKeeper ticker could read
it. The broader fixture race is now eliminated by matrixorigin#28554, which runs
manual bootstrap tests with workers disabled. This test still bypassed
the deadline owner to force expiry instead of using the existing
explicit-time bootstrap-check seam.

### Changes

- Drive failure expiry through `checkBootstrapWithSetterAt` with a
deliberately expired time.
- Use the production state setter and require that the replicated state
transition succeeds.
- Preserve the failure oracle: incomplete bootstrap transitions to
`HAKeeperBootstrapFailed`.

### Issue-to-test proof

`TestFailedBootstrap` exercises the same incomplete-bootstrap failure
path without mutating the production-owned deadline. The normal
bootstrap and remote WAL-recovery consumers of the shared helper remain
covered as controls.

### Tests

- `.agents/skills/mo-dev/scripts/mo-cgo-test -list
^(TestFailedBootstrap|TestBootstrap|TestBootstrapWaitsForRemoteWALRecovery)$
./pkg/logservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s -run
^(TestFailedBootstrap|TestBootstrap|TestBootstrapWaitsForRemoteWALRecovery)$
./pkg/logservice` (passed after rebase onto main@ac660ae56e, 1.545s)
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100
-timeout=240s -run ^TestFailedBootstrap$ ./pkg/logservice` (passed after
rebase onto main@ac660ae56e, 19.269s)

BVT is not applicable: this is an internal Go test ownership and
state-transition contract with no SQL or client-visible behavior.

### Residual risk

Production code is unchanged. matrixorigin#28554 in the base branch owns ticker
isolation for manual bootstrap fixtures; this PR is limited to the
deadline-driving seam. Fresh Linux CI is required after the rebase.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rigin#28554)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#28550

## What this PR does / why we need it:

### Root cause

`runHAKeeperStoreTest` started the production HAKeeper ticker while
several tests directly drove bootstrap transitions on the same `store`.
After the ticker cadence was shortened, the two owners could
concurrently allocate IDs and advance the replicated state. This caused
the reported `idAllocator.Set`/`Next` race, the test callback race, and
nondeterministic initial-cluster watermarks.

### Changes

- Split the HAKeeper store fixture into ticker-enabled and
manual-bootstrap modes.
- Run tests that directly call bootstrap/checker transitions in manual
mode (`DisableWorkers=true`), leaving ticker-dependent task fixtures
unchanged.
- Apply manual mode to initial-cluster, restore, bootstrap-cadence,
recovery-bootstrap, and shared bootstrap tests.

### Issue-to-test proof

Related to matrixorigin#28550:

- `TestSetInitialClusterInfo` asserts that repeated initial-cluster
proposals and rejected watermark restore leave the initial ID watermarks
unchanged.
- `TestBootstrapWaitsForRemoteWALRecovery` drives bootstrap through the
remote WAL-recovery gate and verifies it remains deterministic.
- Each reported test passed independently under `-race -count=100`; no
race was reported.

### Tests

- `mo-cgo-test -race -count=100 -run ^TestSetInitialClusterInfo$
./pkg/logservice` — PASS (19.430s)
- `mo-cgo-test -race -count=100 -run
^TestBootstrapWaitsForRemoteWALRecovery$ ./pkg/logservice` — PASS
(26.378s)
- Focused manual-bootstrap consumer group, normal and `-race` — PASS.
- `GOWORK=off go vet -mod=readonly ./pkg/logservice` with repository CGo
include/library paths — PASS.
- Full `pkg/logservice` normal run was attempted but is not a green
result: a user-owned local `minio` process occupies `127.0.0.1:9001`,
causing the unrelated fixed-port `TestNotHAKeeperErrorIsHandled` startup
failure and subsequent suite contamination. The process was not
modified.

### Residual risks

This is test-only fixture isolation. Production ticker behavior and
ticker-dependent task fixture behavior are unchanged. Linux CI remains
the final cross-platform validation.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [x] BUG
- [ ] API-change
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#28551

## What this PR does / why we need it:

### Root cause

Before the current `main` baseline, `TestFailedBootstrap` directly
overwrote `bootstrapCheckDeadline` while the HAKeeper ticker could read
it. The broader fixture race is now eliminated by matrixorigin#28554, which runs
manual bootstrap tests with workers disabled. This test still bypassed
the deadline owner to force expiry instead of using the existing
explicit-time bootstrap-check seam.

### Changes

- Drive failure expiry through `checkBootstrapWithSetterAt` with a
deliberately expired time.
- Use the production state setter and require that the replicated state
transition succeeds.
- Preserve the failure oracle: incomplete bootstrap transitions to
`HAKeeperBootstrapFailed`.

### Issue-to-test proof

`TestFailedBootstrap` exercises the same incomplete-bootstrap failure
path without mutating the production-owned deadline. The normal
bootstrap and remote WAL-recovery consumers of the shared helper remain
covered as controls.

### Tests

- `.agents/skills/mo-dev/scripts/mo-cgo-test -list
^(TestFailedBootstrap|TestBootstrap|TestBootstrapWaitsForRemoteWALRecovery)$
./pkg/logservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s -run
^(TestFailedBootstrap|TestBootstrap|TestBootstrapWaitsForRemoteWALRecovery)$
./pkg/logservice` (passed after rebase onto main@ac660ae56e, 1.545s)
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100
-timeout=240s -run ^TestFailedBootstrap$ ./pkg/logservice` (passed after
rebase onto main@ac660ae56e, 19.269s)

BVT is not applicable: this is an internal Go test ownership and
state-transition contract with no SQL or client-visible behavior.

### Residual risk

Production code is unchanged. matrixorigin#28554 in the base branch owns ticker
isolation for manual bootstrap fixtures; this PR is limited to the
deadline-driving seam. Fresh Linux CI is required after the rebase.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rigin#28554)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#28550

## What this PR does / why we need it:

### Root cause

`runHAKeeperStoreTest` started the production HAKeeper ticker while
several tests directly drove bootstrap transitions on the same `store`.
After the ticker cadence was shortened, the two owners could
concurrently allocate IDs and advance the replicated state. This caused
the reported `idAllocator.Set`/`Next` race, the test callback race, and
nondeterministic initial-cluster watermarks.

### Changes

- Split the HAKeeper store fixture into ticker-enabled and
manual-bootstrap modes.
- Run tests that directly call bootstrap/checker transitions in manual
mode (`DisableWorkers=true`), leaving ticker-dependent task fixtures
unchanged.
- Apply manual mode to initial-cluster, restore, bootstrap-cadence,
recovery-bootstrap, and shared bootstrap tests.

### Issue-to-test proof

Related to matrixorigin#28550:

- `TestSetInitialClusterInfo` asserts that repeated initial-cluster
proposals and rejected watermark restore leave the initial ID watermarks
unchanged.
- `TestBootstrapWaitsForRemoteWALRecovery` drives bootstrap through the
remote WAL-recovery gate and verifies it remains deterministic.
- Each reported test passed independently under `-race -count=100`; no
race was reported.

### Tests

- `mo-cgo-test -race -count=100 -run ^TestSetInitialClusterInfo$
./pkg/logservice` — PASS (19.430s)
- `mo-cgo-test -race -count=100 -run
^TestBootstrapWaitsForRemoteWALRecovery$ ./pkg/logservice` — PASS
(26.378s)
- Focused manual-bootstrap consumer group, normal and `-race` — PASS.
- `GOWORK=off go vet -mod=readonly ./pkg/logservice` with repository CGo
include/library paths — PASS.
- Full `pkg/logservice` normal run was attempted but is not a green
result: a user-owned local `minio` process occupies `127.0.0.1:9001`,
causing the unrelated fixed-port `TestNotHAKeeperErrorIsHandled` startup
failure and subsequent suite contamination. The process was not
modified.

### Residual risks

This is test-only fixture isolation. Production ticker behavior and
ticker-dependent task fixture behavior are unchanged. Linux CI remains
the final cross-platform validation.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [x] BUG
- [ ] API-change
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#28551

## What this PR does / why we need it:

### Root cause

Before the current `main` baseline, `TestFailedBootstrap` directly
overwrote `bootstrapCheckDeadline` while the HAKeeper ticker could read
it. The broader fixture race is now eliminated by matrixorigin#28554, which runs
manual bootstrap tests with workers disabled. This test still bypassed
the deadline owner to force expiry instead of using the existing
explicit-time bootstrap-check seam.

### Changes

- Drive failure expiry through `checkBootstrapWithSetterAt` with a
deliberately expired time.
- Use the production state setter and require that the replicated state
transition succeeds.
- Preserve the failure oracle: incomplete bootstrap transitions to
`HAKeeperBootstrapFailed`.

### Issue-to-test proof

`TestFailedBootstrap` exercises the same incomplete-bootstrap failure
path without mutating the production-owned deadline. The normal
bootstrap and remote WAL-recovery consumers of the shared helper remain
covered as controls.

### Tests

- `.agents/skills/mo-dev/scripts/mo-cgo-test -list
^(TestFailedBootstrap|TestBootstrap|TestBootstrapWaitsForRemoteWALRecovery)$
./pkg/logservice`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s -run
^(TestFailedBootstrap|TestBootstrap|TestBootstrapWaitsForRemoteWALRecovery)$
./pkg/logservice` (passed after rebase onto main@ac660ae56e, 1.545s)
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100
-timeout=240s -run ^TestFailedBootstrap$ ./pkg/logservice` (passed after
rebase onto main@ac660ae56e, 19.269s)

BVT is not applicable: this is an internal Go test ownership and
state-transition contract with no SQL or client-visible behavior.

### Residual risk

Production code is unchanged. matrixorigin#28554 in the base branch owns ticker
isolation for manual bootstrap fixtures; this PR is limited to the
deadline-driving seam. Fresh Linux CI is required after the rebase.

This branch was previously deployed

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

Labels

kind/bug Something isn't working kind/test-ci size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants