Skip to content

fix: join HAKeeper task scheduler before log store close - #26507

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
LeftHandCold:agent/fix-26487-logservice-shutdown
Jul 31, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
LeftHandCold:agent/fix-26487-logservice-shutdown

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #26487

What this PR does / why we need it:

store.ticker launched the HAKeeper task scheduler as a raw goroutine. During logservice shutdown, tickerStopper.Stop() joined the parent HAKeeper ticker but not that detached child, so NodeHost.Close() could destroy Dragonboat state while the child was still executing SyncRead.

This change registers the task scheduler with the existing tickerStopper. Scheduling remains independent from the HAKeeper tick and health-check loop, while shutdown now cancels and joins both loops before destroying the NodeHost.

The regression test blocks the scheduler in checker-state lookup, starts store.close, proves the ticker stopper has entered its terminal admission state, and verifies close cannot complete until the scheduler exits.

No SQL behavior, wire format, persisted data, configuration, or scheduling policy is changed.

Tested with:

.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=10m -run '^TestStoreCloseWaitsForTaskScheduleTicker$' ./pkg/logservice

.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=52 -timeout=10m -run '^TestTickerForTaskSchedule$' ./pkg/logservice

.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=30m ./pkg/logservice

.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=10 -timeout=30m -run '^TestBaseClusterCanWorkWithNewCluster$' ./pkg/embed

go vet ./pkg/logservice

go build ./pkg/logservice

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

Deep-reviewed current head 7d3e68d. Stopper admission and Stop linearization now own and join the task-scheduler ticker before NodeHost.Close, closing the shutdown race without coupling it to the HAKeeper tick loop. The close regression passed 100 race runs, TestTickerForTaskSchedule passed 44 race runs, and the full logservice race suite, build, and vet passed. No blocking issues found.

@XuPeng-SH
XuPeng-SH merged commit f9afec2 into matrixorigin:main Jul 31, 2026
23 checks passed
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…n#26507)

## 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:

issue matrixorigin#26487

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

`store.ticker` launched the HAKeeper task scheduler as a raw goroutine.
During logservice shutdown, `tickerStopper.Stop()` joined the parent
HAKeeper ticker but not that detached child, so `NodeHost.Close()` could
destroy Dragonboat state while the child was still executing `SyncRead`.

This change registers the task scheduler with the existing
`tickerStopper`. Scheduling remains independent from the HAKeeper tick
and health-check loop, while shutdown now cancels and joins both loops
before destroying the NodeHost.

The regression test blocks the scheduler in checker-state lookup, starts
`store.close`, proves the ticker stopper has entered its terminal
admission state, and verifies close cannot complete until the scheduler
exits.

No SQL behavior, wire format, persisted data, configuration, or
scheduling policy is changed.

Tested with:

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=10m
-run '^TestStoreCloseWaitsForTaskScheduleTicker$' ./pkg/logservice`

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=52 -timeout=10m
-run '^TestTickerForTaskSchedule$' ./pkg/logservice`

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=30m
./pkg/logservice`

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=10 -timeout=30m
-run '^TestBaseClusterCanWorkWithNewCluster$' ./pkg/embed`

`go vet ./pkg/logservice`

`go build ./pkg/logservice`

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…n#26507)

## 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:

issue matrixorigin#26487

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

`store.ticker` launched the HAKeeper task scheduler as a raw goroutine.
During logservice shutdown, `tickerStopper.Stop()` joined the parent
HAKeeper ticker but not that detached child, so `NodeHost.Close()` could
destroy Dragonboat state while the child was still executing `SyncRead`.

This change registers the task scheduler with the existing
`tickerStopper`. Scheduling remains independent from the HAKeeper tick
and health-check loop, while shutdown now cancels and joins both loops
before destroying the NodeHost.

The regression test blocks the scheduler in checker-state lookup, starts
`store.close`, proves the ticker stopper has entered its terminal
admission state, and verifies close cannot complete until the scheduler
exits.

No SQL behavior, wire format, persisted data, configuration, or
scheduling policy is changed.

Tested with:

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=10m
-run '^TestStoreCloseWaitsForTaskScheduleTicker$' ./pkg/logservice`

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=52 -timeout=10m
-run '^TestTickerForTaskSchedule$' ./pkg/logservice`

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=30m
./pkg/logservice`

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=10 -timeout=30m
-run '^TestBaseClusterCanWorkWithNewCluster$' ./pkg/embed`

`go vet ./pkg/logservice`

`go build ./pkg/logservice`

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…n#26507)

## 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:

issue matrixorigin#26487

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

`store.ticker` launched the HAKeeper task scheduler as a raw goroutine.
During logservice shutdown, `tickerStopper.Stop()` joined the parent
HAKeeper ticker but not that detached child, so `NodeHost.Close()` could
destroy Dragonboat state while the child was still executing `SyncRead`.

This change registers the task scheduler with the existing
`tickerStopper`. Scheduling remains independent from the HAKeeper tick
and health-check loop, while shutdown now cancels and joins both loops
before destroying the NodeHost.

The regression test blocks the scheduler in checker-state lookup, starts
`store.close`, proves the ticker stopper has entered its terminal
admission state, and verifies close cannot complete until the scheduler
exits.

No SQL behavior, wire format, persisted data, configuration, or
scheduling policy is changed.

Tested with:

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=10m
-run '^TestStoreCloseWaitsForTaskScheduleTicker$' ./pkg/logservice`

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=52 -timeout=10m
-run '^TestTickerForTaskSchedule$' ./pkg/logservice`

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=30m
./pkg/logservice`

`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=10 -timeout=30m
-run '^TestBaseClusterCanWorkWithNewCluster$' ./pkg/embed`

`go vet ./pkg/logservice`

`go build ./pkg/logservice`

Co-authored-by: XuPeng-SH <[email protected]>

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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants