You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps Server 2019并行流水线任务被取消问题求助

Azure DevOps Server 2019 双代理并行运行流水线时任务被取消问题

我们使用Azure DevOps Server 2019,在同一服务器上创建了代理池并配置了两个代理。当前遇到的问题:

  • 单条流水线可正常运行
  • 并行运行两条流水线时,其中一条会在数分钟后被取消,仅提示错误The operation was canceled,无其他详细日志
  • 怀疑是同一服务器上的两个代理共用MSBuild导致冲突

流水线截图

流水线截图1
流水线截图2
流水线截图3

失败流水线的system.debug日志

日志1(Build solution步骤失败)

##[debug]Re-evaluate condition on job cancellation for step: 'Build solution **/*.sln'.
##[debug]Leaving Get-SolutionFiles.
##[debug]Leaving C:\agents\w1\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.166.2\MSBuild.ps1.
##[error]The operation was canceled.
##[debug]System.OperationCanceledException: The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at Microsoft.VisualStudio.Services.Agent.Util.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.DefaultStepHost.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.PowerShell3Handler.RunAsync() at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync() at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken)
Finishing: Build solution **/*.sln

日志2(NuGet restore步骤失败)

##[debug]  C:\agents\w1\106\s\ClientApp\node_modules\faker\lib\locales\de_CH\name (directory)
##[error]The operation was canceled.
##[debug]System.OperationCanceledException: The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at Microsoft.VisualStudio.Services.Agent.Util.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.DefaultStepHost.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, CancellationToken cancellationToken) at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.NodeHandler.RunAsync() at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync() at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken)
Finishing: NuGet restore

排查与解决步骤

  1. 隔离代理运行账户
    确保两个代理使用不同的本地用户账户运行,避免同一账户下的资源锁冲突。卸载现有代理后,用不同账户重新配置两个代理。

  2. 验证MSBuild并发兼容性

    • 升级MSBuild到对应VS版本的最新版(如VS2019的MSBuild 16.x),旧版本可能存在单实例限制。
    • 在MSBuild步骤添加参数/m:1禁用并行构建,测试是否仍出现取消问题,排除构建本身的并行冲突。
  3. 检查服务器资源瓶颈
    监控并行运行时的CPU、内存、磁盘IO占用,若资源耗尽,Agent会主动终止任务。可限制代理池并行任务数或升级服务器硬件。

  4. 确保代理工作目录独立
    配置两个代理时指定不同的工作目录(work文件夹),避免同一目录下的文件锁冲突。

  5. 查看详细日志定位原因

    • 服务器端日志路径:C:\Program Files\Azure DevOps Server 2019\Application Tier\Logs,查找任务取消触发源。
    • 代理端日志路径:每个代理的_diag文件夹,检查是否有资源访问拒绝、进程强制终止记录。
  6. 禁用代理进程复用
    在代理的config.json中添加"reuseProcess": false,强制每个任务启动新进程,避免进程间资源共享冲突,修改后重启代理服务。

内容的提问来源于stack exchange,提问作者Harish334363

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 08:01:27