Repository navigation
fix(service)!: share worker lifecycle for consensus shutdown #1513
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
Open
lklimek
wants to merge
5
commits into
v1.8-dev
Choose a base branch
from
fix/consensus-wait-shutdown
base: v1.8-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,015
−348
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fd17edb
fix(consensus): wait for receive routine during shutdown
lklimek 71725a9
Merge remote-tracking branch 'origin/v1.8-dev' into fix/consensus-wai…
lklimek 8e431fc
fix(service)!: share worker lifecycle for consensus shutdown
lklimek ec8d306
fix(consensus): preserve in-flight work during manual shutdown
lklimek b8a6beb
Merge branch 'v1.8-dev' into fix/consensus-wait-shutdown
lklimek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Service lifecycle core | ||
|
|
||
| `BaseService.Start` gives `OnStart` an attempt-scoped child context. Parent | ||
| cancellation and manual `Stop` both cancel it. `Go(ctx, fn)` registers workers | ||
| using that context or a derived context; registration is synchronized with | ||
| shutdown and rejected for a different attempt or after shutdown begins. | ||
|
|
||
| Shutdown closes admission, marks `IsRunning` false, cancels the context and | ||
| calls `OnStop`. It then joins registered workers, calls optional `OnDrain`, and | ||
| releases `Wait`. `Stopping()` signals cancellation separately from completion. | ||
| `Stop` invokes `OnStop` synchronously but does not join registered workers. | ||
| Concurrent or recursive calls to `Stop` return immediately. | ||
|
|
||
| Hooks run outside the lifecycle mutex. `OnStop` must unblock workers without | ||
| waiting for its own registered work. Workers may call `Stop`; neither hooks nor | ||
| workers may call their own service's `Wait`. Release resources shared with | ||
| workers in `OnDrain`, or after `Stop` followed by `Wait`. | ||
|
|
||
| `IsRunning` is false during startup and shutdown. `Wait` joins the current | ||
| attempt, including startup and cleanup; it returns immediately before startup. | ||
| Failed `OnStart` cancels and joins its workers before retry becomes possible. | ||
| The implementation must roll back acquired resources: failed attempts do not | ||
| invoke `OnStop` or `OnDrain`. Successfully stopped services cannot restart. | ||
| Composite retries also require recreating children already successfully stopped. | ||
|
|
||
| ## First migration stage | ||
|
|
||
| Consensus State registers its receive loop and joins its queue fan-in and WAL | ||
| before returning. The timeout ticker, WAL and autofile group use shared worker | ||
| tracking. AutoFile explicitly joins its timer/signal worker. WAL ownership lasts | ||
| until the receive loop's final write. Consensus handoff admission is also joined, | ||
| so a late blocksync handoff cannot start State after reactor shutdown. | ||
|
|
||
| Node waits for reactors before closing event sinks and stores. The blocked | ||
| receive-loop regression and original node teardown tests verify this path | ||
| without using leaktest as an extra production-shutdown barrier. | ||
|
|
||
| This is a partial migration. Plain goroutines are not tracked automatically. | ||
| RPC/WebSocket handlers, mempool rechecks, reactor gossip and other service | ||
| workers retain their existing ownership mechanisms. This change does not claim | ||
| that Node.Wait joins every helper or introduce the broader durable-finalization | ||
| and dependency-lifetime changes from #1515. | ||
|
|
||
| Two compatibility bridges preserve existing parent-context lifetimes: blocksync | ||
| application during handoff and connection error callbacks after I/O shutdown. | ||
| Their local cancellation and join mechanisms remain in place in this stage. |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.