Runner cancels a healthy running job after 10 cumulative (not consecutive) retriable broker poll errors

Đang mở Phù hợp với người mới
#4,820 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu trong src/Runner.Listener/BrokerMessageListener.cs, tại GetNextMessageAsync, và theo dõi continuousError cùng encounteringError thay đổi thế nào khi một lần thăm dò thành công hoặc ném ngoại lệ. Issue xác định đường đi thăm dò không có thông báo là một lần thăm dò thành công cần đặt lại các bộ đếm. Hãy xác nhận hành vi bằng các bài kiểm thử hiện có liên quan, nếu có, và kiểm tra rằng chỉ các lần thăm dò thất bại liên tiếp mới đạt đến giới hạn thử lại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Version / environment: runner v2.338.0 (the same code is on main; I did not read the v2.338.1 tag itself), Linux ARM64, self-hosted, systemd service.

What happens

While a job is running, the listener keeps polling the broker (GET .../message?...&status=Busy). On our network some of these long-polls hit the client's 100 s HTTP timeout. Each one that escapes the inner request retry is logged as Retriable exception: The HTTP request timed out after 00:01:40. and the listener backs off and polls again, as intended.

But after the 10th such exception during the same job, the listener shuts down its job dispatcher and sends a cancellation to the worker, even though the job itself is healthy (job renewals were still succeeding). The job ends as cancelled. On our machine a retriable exception escapes about every 9.5 minutes, so every job that runs longer than about 95 minutes is cancelled at that point. Three jobs in one day were cancelled at 95.4, 95.6 and 96.1 minutes; a job that finished at 93.75 minutes passed.

Log sequence at the cancellation (session ids removed):

[... INFO BrokerMessageListener] Retriable exception: The HTTP request timed out after 00:01:40.
[... INFO JobDispatcher] Shutting down JobDispatcher. Make sure all WorkerDispatcher has finished.
[... INFO JobDispatcher] Ensure WorkerDispatcher for job ... run to finish, cancel any running job.
[... INFO JobDispatcher] Send job cancellation message to worker for job ...
[... INFO JobDispatcher] finish job request for job ... with result: Canceled

In both logs I checked, this was exactly the 10th Retriable exception after the job started.

Cause in the source

src/Runner.Listener/BrokerMessageListener.cs, GetNextMessageAsync (v2.338.0, lines 281-371; the same lines on main):

  • line 281: int continuousError = 0;
  • line 284: var maxRetryCount = 10;
  • line 361: continuousError++; on every retriable exception
  • lines 369-371: else if (continuousError >= maxRetryCount) { throw; }

continuousError is never set back to 0. A poll that returns no message just does continue (lines ~306-309), and nothing else resets it. The call to GetNextMessageAsync stays open for the whole time a job runs, so the counter accumulates every poll failure over the job's lifetime, not consecutive ones as the name and the "random backoff ... consecutive error" comments suggest. Any sufficiently long job on a network with occasional dropped long-polls will eventually reach 10.

Expected behaviour

Only 10 consecutive failed polls should give up. A successful poll (including one that returns no message) should reset the counter.

Possible fix

Reset continuousError (and encounteringError) to 0 after a poll completes without throwing, i.e. just before the if (message == null) { continue; } check. I have not built or tested a patched runner. It may also be worth making maxRetryCount configurable.

Workaround

Keep jobs shorter than the point where the 10th escaped timeout happens (about 95 minutes for us).

Not established

Why the broker long-polls time out at 100 s on our network. They also happen on idle runners, and a renewjob POST sometimes fails with "The response ended prematurely". That may be our network; this issue is only about the listener treating cumulative errors as consecutive.

Ngôn ngữ chính
C#
Star
6.4k
Fork
1.5k
Merge trung bình
1 ngày 7 giờ
Pull request đã merge (30 ngày)
36

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của actions/runner

Tất cả issue của actions/runner

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.