Skip to content

Add thread-safety locks to StepsContext - #4475

Merged
lokesh755 merged 2 commits into
mainfrom
lokesh755-thread-safety-primitives-background-stepps
Jun 4, 2026
Merged

Add thread-safety locks to StepsContext#4475
lokesh755 merged 2 commits into
mainfrom
lokesh755-thread-safety-primitives-background-stepps

Conversation

@lokesh755

Copy link
Copy Markdown
Contributor

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.

CopilotAI review requested due to automatic review settings June 3, 2026 22:24
@lokesh755
lokesh755 requested a review from a team as a code ownerJune 3, 2026 22:24
@lokesh755
lokesh755force-pushed the lokesh755-thread-safety-primitives-background-stepps branch from 6a9dd1b to 057432eCompareJune 3, 2026 22:28

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 StepsContext mutations and some GlobalContext collection mutations to reduce concurrency hazards.
Show a summary per file
FileDescription
src/Sdk/WebApi/WebApi/ResultsHttpClient.csPopulates new background-step fields when converting timeline records to Results “Step” payloads.
src/Sdk/WebApi/WebApi/Contracts.csAdds background-step fields to Results Step contract.
src/Sdk/RSWebApi/Contracts/StepResult.csAdds background-step fields to RSWebApi step result contract.
src/Sdk/DTWebApi/WebApi/TimelineRecord.csAdds background-step fields to timeline records and copies them during clone.
src/Sdk/DTPipelines/Pipelines/StepConverter.csUpdates step JSON deserialization to instantiate BackgroundStepControl.
src/Sdk/DTPipelines/Pipelines/Step.csRegisters new step type via KnownType and enum value.
src/Sdk/DTPipelines/Pipelines/JobStep.csAdds/clones ParallelGroupId for job steps.
src/Sdk/DTPipelines/Pipelines/BackgroundStepControl.csIntroduces new pipeline step type for background control flow (wait/wait-all/cancel).
src/Sdk/DTPipelines/Pipelines/ActionStep.csAdds/clones Background flag on action steps.
src/Runner.Worker/StepsContext.csAdds a lock around several StepsContext mutation paths.
src/Runner.Worker/PipelineTemplateEvaluatorWrapper.csLocks around telemetry list writes for mismatch reporting.
src/Runner.Worker/Handlers/HandlerFactory.csLocks around global HashSet mutations that track Node migration telemetry.
src/Runner.Worker/GlobalContext.csAdds a shared lock object intended for guarding global collections.
src/Runner.Worker/ActionManifestManagerWrapper.csLocks around telemetry list writes for mismatch reporting.
src/Runner.Worker/ActionManager.csLocks around JobTelemetry additions in action download path.
src/Runner.Worker/ActionCommandManager.csLocks around JobTelemetry additions for action command telemetry.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 6

Comment threadsrc/Runner.Worker/PipelineTemplateEvaluatorWrapper.cs Outdated
Comment threadsrc/Runner.Worker/PipelineTemplateEvaluatorWrapper.cs Outdated
Comment threadsrc/Runner.Worker/ActionManifestManagerWrapper.cs Outdated
Comment threadsrc/Runner.Worker/ActionManifestManagerWrapper.cs Outdated
Comment threadsrc/Runner.Worker/StepsContext.cs
Comment threadsrc/Runner.Worker/GlobalContext.cs Outdated
Comment threadsrc/Runner.Worker/GlobalContext.cs Outdated
@lokesh755
lokesh755force-pushed the lokesh755-thread-safety-primitives-background-stepps branch from becd2c1 to b88b481CompareJune 4, 2026 03:25
@lokesh755
lokesh755force-pushed the lokesh755-thread-safety-primitives-background-stepps branch from b88b481 to 5007995CompareJune 4, 2026 17:52
@lokesh755lokesh755 changed the title Add thread-safety locks for shared GlobalContext collections and StepsContextAdd thread-safety locks to StepsContextJun 4, 2026
@lokesh755
lokesh755 merged commit 77d6014 into mainJun 4, 2026
12 checks passed
@lokesh755
lokesh755 deleted the lokesh755-thread-safety-primitives-background-stepps branch June 4, 2026 18:08
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@lokesh755@TingluoHuang