Repository navigation
Conversation
Background and parallel steps write the job context's embedded action state, post step registrations and ActionManager's composite caches from several threads. Concurrent writes corrupted these collections and failed unrelated steps. Fixes actions#4789 Co-Authored-By: Claude <[email protected]>
erezcor
marked this pull request as ready for review
November 15, 2026 18:31
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.
Fixes #4789
Background and
parallel:steps run composite actions on several threads, but some job-level collections those steps write are plainDictionary,HashSetandStack. When two composites write at once, the collection is corrupted, and later reads fail unrelated steps and post steps too (Operations that change non-concurrent collections must have exclusive access…,Unable to process file command 'state' successfully.).EmbeddedIntraActionStateis now aConcurrentDictionary.GITHUB_STATEandsave-stateadd a step's state withGetOrAdd.RegisterPostJobStepupdatesPostJobSteps,StepsWithPostRegisteredandEmbeddedStepsWithPostRegisteredunder a lock on the job context.ActionManager's composite caches (CachedEmbeddedStepIds,CachedEmbeddedPreSteps,CachedEmbeddedPostSteps,CachedActionContainers) are nowConcurrentDictionary. Every background step that uses a local composite prepares and loads it on its own thread.There is no feature flag because the change only adds synchronization and doesn't change behavior.
Tests: two L0 tests in
ExecutionContextL0register post steps and save state from 256 background steps at once. Againstmainthey failed in 6 of 6 and 4 of 6 local runs, with lost entries,KeyNotFoundExceptionandIndexOutOfRangeException. With this change they passed in 10 of 10 runs.Not covered here
Collection was modified; enumeration operation may not execute.failures in the issue have another cause. On released runners, every embedded step shallow-copies the job-levelgithubcontext (CompositeActionHandler) on its background thread, while the main thread keeps settinggithub.actionon that same object for each step it queues. Fix GitHub context inheritance in embedded execution contexts #4799 fixes this behindactions_fix_embedded_github_context, and v2.338.2 doesn't include it yet, so this PR leaves it alone.GITHUB_ENVandGITHUB_PATHstraight toGlobal.EnvironmentVariablesandGlobal.PrependPath. Only the background step's own commands are deferred. Other threads enumerate those collections when they set up a step. Deferring them, or synchronizing them, changes behavior, so it needs its own decision.