-
Notifications
You must be signed in to change notification settings - Fork 692
fix(livestore): stop periodic WAL flush goroutines before shutdown flush #6972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2eec2ad
65cc527
936adcc
1bef0e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,19 +175,38 @@ func (s *LiveStore) retryCompleteOp(op *completeOp, span oteltrace.Span, msg str | |
| }() | ||
| } | ||
|
|
||
| func (s *LiveStore) perTenantCutToWalLoop(instance *instance) { | ||
| // ticker | ||
| ticker := time.NewTicker(s.cfg.InstanceFlushPeriod) | ||
| defer ticker.Stop() | ||
| func (s *LiveStore) startPerTenantCutToWalLoop(inst *instance) { | ||
| s.cutToWalWg.Add(1) | ||
|
zhxiaogg marked this conversation as resolved.
|
||
| go func() { | ||
| defer s.cutToWalWg.Done() | ||
|
|
||
| for { | ||
| // Wait for startup to finish; also listen on cutToWalStop so we can | ||
| // exit if shutdown happens before startup completes. | ||
| select { | ||
| case <-ticker.C: | ||
| s.cutOneInstanceToWal(s.ctx, instance, false) | ||
| case <-s.ctx.Done(): | ||
| case <-s.startupComplete: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added comment and PR description for the livestore startup/shutdown process around WAL completion. |
||
| case <-s.cutToWalStop: | ||
| return | ||
|
zhxiaogg marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| ticker := time.NewTicker(s.cfg.InstanceFlushPeriod) | ||
| defer ticker.Stop() | ||
|
|
||
| for { | ||
| select { | ||
| case <-ticker.C: | ||
| s.cutOneInstanceToWal(s.ctx, inst, false) | ||
| case <-s.cutToWalStop: | ||
| return | ||
| case <-s.ctx.Done(): | ||
| return | ||
| } | ||
| } | ||
| }() | ||
| } | ||
|
|
||
| func (s *LiveStore) stopAllCutToWalLoops() { | ||
| close(s.cutToWalStop) | ||
| s.cutToWalWg.Wait() | ||
| } | ||
|
zhxiaogg marked this conversation as resolved.
|
||
|
|
||
| func (s *LiveStore) perTenantCleanupLoop(inst *instance) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.