Fix race condition in retryProcess causing TestShutdown_DrainsRetriedTasks to fail - #5112
Closed
Future-Outlier with Copilot wants to merge 2 commits into
Closed
Fix race condition in retryProcess causing TestShutdown_DrainsRetriedTasks to fail#5112Future-Outlier with Copilot wants to merge 2 commits into
Future-Outlier with Copilot wants to merge 2 commits into
Conversation
…Tasks to fail Co-authored-by: Future-Outlier <76461262+Future-Outlier@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix failing GitHub Actions job Build historyserver
Fix race condition in retryProcess causing TestShutdown_DrainsRetriedTasks to fail
Aug 9, 2026
Collaborator
|
There's an existing PR here: #5105 |
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.
TestShutdown_DrainsRetriedTaskswas intermittently failing becauseretryProcesshad an early-exit guard that raced withshutdown()closingstopProducers.The race:
mockWriter.WriteFilesetsfailNext=falsebefore returning the error. The test'srequire.Eventuallyfires on that signal, immediately callingec.shutdown(). ButretryProcessis called a few instructions later insideprocessRotatedFile— afterWriteFilereturns but before the goroutine is spawned. IfstopProducersis already closed when the guard runs, the retry is silently abandoned.Fix: Replace the entry-point guard in
retryProcesswith afinalAttemptflag onrotationTask:select { case <-ec.stopProducers: return }guard at the top ofretryProcess— the goroutine is now always spawned.stopProducers(shutdown interrupt), settask.finalAttempt = true.processRotatedFile, if upload fails andtask.finalAttemptis true, log and abandon rather than re-enteringretryProcess— this preserves the single-final-attempt contract and prevents infinite retry loops.Why are these changes needed?
TestShutdown_DrainsRetriedTasksinhistoryserver/pkg/collector/eventcollectorwas failing in CI due to a race condition: the old guard inretryProcesscould fire before the retry goroutine was spawned, silently dropping the task instead of making one final upload attempt during shutdown.Related issue number
Labels
doc-updates-requiredlabel.breaking-changelabel.Checks