fix(runtime): tighten shutdown and failure events#23
Merged
Conversation
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.
Summary
Tightens two v1 lifecycle semantics in the runtime.
Runtime.ShutdownbeforeStopAllwhen the caller context has already expiredservekitservicefallback cleanup working with a fresh stop contextFailureEvents when a worker is already failedWhy
Runtime.Shutdownpreviously used one context across drain, idle wait, and stop. If the context expired during drain or idle wait, shutdown could still callStopAllwith an already-expired context. Context-aware workers could then returnDeadlineExceeded, causing Workerkit to mark them failed during shutdown.Separately, if
WorkerRuntime.ReportFailurewas called duringStartandWorker.Startlater returned an error, Workerkit could emit two lifecycle failure events for one startup failure path.Both behaviors make lifecycle and observability semantics noisier than they should be for v1.
Verification
make testmake test-race