fix(livestore): stop periodic WAL flush goroutines before shutdown flush#6972
Merged
zhxiaogg merged 4 commits intografana:mainfrom Apr 15, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent concurrent writes to the same WAL during shutdown by stopping the per-tenant periodic “cut to WAL” loops before performing the final shutdown flush.
Changes:
- Added a dedicated stop channel and waitgroup to stop/wait for per-tenant periodic WAL flush goroutines during shutdown.
- Updated
perTenantCutToWalLoopto stop on the new stop signal rather than the service context. - Adjusted tests to stop the service via
services.StopAndAwaitTerminated(...)instead of callingliveStore.stopping(nil)directly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| modules/livestore/live_store.go | Adds shutdown coordination (cutToWalStop, cutToWalWg) and stops periodic WAL flush goroutines before shutdown flush. |
| modules/livestore/live_store_background.go | Hooks per-tenant periodic WAL flush loop into the new stop mechanism. |
| modules/livestore/live_store_test.go | Updates stopping-related tests to use the service stop path. |
mattdurham
reviewed
Apr 15, 2026
| case <-ticker.C: | ||
| s.cutOneInstanceToWal(s.ctx, instance, false) | ||
| case <-s.ctx.Done(): | ||
| case <-s.startupComplete: |
Contributor
There was a problem hiding this comment.
Can we add a comment that we will continue if startupComplete is met first we will continue. Copilot also mentions there is not a context check here, thats probably implicit in the other two but if we an either A pass it in, or document the behavior.
Contributor
Author
There was a problem hiding this comment.
added comment and PR description for the livestore startup/shutdown process around WAL completion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
The startup/shutdown procedure now:
cutToWalStopchannelcutToWalStopWhich issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]