go executor: prevent invalidation deadlocks#20
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
Supersedes #17 by folding its pending-invalidation cleanup into the synchronized lifecycle transition.
Root cause
The captured SIGQUIT dump showed an invalidation goroutine blocked on a task terminal channel for 122 minutes while holding Executor.mu. Thirteen task goroutines were then blocked trying to enter the next execution pass through that same mutex.
PR #15 / 59908fc introduced cross-goroutine KeepAlive lifecycle reads. PR #16 / 6472f72 then added a second unsynchronized writer that replaced ctx and terminalCh from task completion. Completion could swap in a fresh empty terminal channel just before invalidation evaluated its receive, permanently losing the signal. The pre-existing global mutex around that receive amplified one lost signal into a whole-executor deadlock.
Regression evidence
The regression test was committed first and failed under the race detector before the fix:
The fix also closes two adjacent teardown gaps found during review: dynamic errgroup registration during restart, and a watcher error being trapped behind a lifecycle guard.
Verification
go test -race . -run "^(TestKeepAliveInvalidationSynchronizesTaskCompletion|TestTaskWaitsForInvalidationCompletion|TestInvalidatingDependencyIsNotReady|TestShouldInvalidateCanReadTaskState|TestExecutorReturnsWatcherFailure)$" -count=20go test -race ./... -count=1