Add thread-safety locks to StepsContext#4475
Merged
lokesh755 merged 2 commits intoJun 4, 2026
Merged
Conversation
6a9dd1b to
057432e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prepares the runner for future concurrent/background step execution by extending step/timeline wire contracts with background-step metadata and introducing synchronization around some shared mutable state (e.g., telemetry/step context).
Changes:
- Extend Results/RSWebApi/DTWebApi step & timeline contracts to carry background-step metadata (e.g.,
is_background, control type, control step IDs, parallel group). - Introduce a new pipeline step type (
BackgroundStepControl) and update step deserialization to recognize it. - Add locking around
StepsContextmutations and someGlobalContextcollection mutations to reduce concurrency hazards.
Show a summary per file
| File | Description |
|---|---|
| src/Sdk/WebApi/WebApi/ResultsHttpClient.cs | Populates new background-step fields when converting timeline records to Results “Step” payloads. |
| src/Sdk/WebApi/WebApi/Contracts.cs | Adds background-step fields to Results Step contract. |
| src/Sdk/RSWebApi/Contracts/StepResult.cs | Adds background-step fields to RSWebApi step result contract. |
| src/Sdk/DTWebApi/WebApi/TimelineRecord.cs | Adds background-step fields to timeline records and copies them during clone. |
| src/Sdk/DTPipelines/Pipelines/StepConverter.cs | Updates step JSON deserialization to instantiate BackgroundStepControl. |
| src/Sdk/DTPipelines/Pipelines/Step.cs | Registers new step type via KnownType and enum value. |
| src/Sdk/DTPipelines/Pipelines/JobStep.cs | Adds/clones ParallelGroupId for job steps. |
| src/Sdk/DTPipelines/Pipelines/BackgroundStepControl.cs | Introduces new pipeline step type for background control flow (wait/wait-all/cancel). |
| src/Sdk/DTPipelines/Pipelines/ActionStep.cs | Adds/clones Background flag on action steps. |
| src/Runner.Worker/StepsContext.cs | Adds a lock around several StepsContext mutation paths. |
| src/Runner.Worker/PipelineTemplateEvaluatorWrapper.cs | Locks around telemetry list writes for mismatch reporting. |
| src/Runner.Worker/Handlers/HandlerFactory.cs | Locks around global HashSet mutations that track Node migration telemetry. |
| src/Runner.Worker/GlobalContext.cs | Adds a shared lock object intended for guarding global collections. |
| src/Runner.Worker/ActionManifestManagerWrapper.cs | Locks around telemetry list writes for mismatch reporting. |
| src/Runner.Worker/ActionManager.cs | Locks around JobTelemetry additions in action download path. |
| src/Runner.Worker/ActionCommandManager.cs | Locks around JobTelemetry additions for action command telemetry. |
Copilot's findings
- Files reviewed: 7/7 changed files
- Comments generated: 6
TingluoHuang
reviewed
Jun 3, 2026
becd2c1 to
b88b481
Compare
b88b481 to
5007995
Compare
TingluoHuang
approved these changes
Jun 4, 2026
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
Adds thread-safety primitives to shared mutable state in the runner worker, preparing for concurrent step execution in background steps.
Why
Today, steps execute sequentially so these collections are never accessed concurrently. Background steps will allow multiple steps to run in parallel within a single job, meaning these shared collections can be mutated from multiple threads simultaneously. Adding locks now is a safe, no-op change for sequential execution and unblocks the background steps feature.