DockerStatsService: docker stats child silently killed at execa maxBuffer (~100 min), stats freeze until resubscribe
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/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ệ
- docker, node.js, typescript
Hướng nghiên cứu
Start with api/src/unraid-api/graph/resolvers/docker/docker-stats.service.ts, focusing on how the service launches and handles the docker stats child process. Check how stream output is consumed and how exit events interact with active subscribers. The issue is done when stats continue updating while subscribed and an unexpected child exit is detected and handled.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
Unraid OS Version: 7.4.0, API 4.37.11+8e587fe2
Are you using a reverse proxy?
No, not for this issue. The stats consumer (Home Assistant Unraid integration) connects to the server's LAN IP directly, and everything below was diagnosed from the server shell.
Pre-submission Checklist
- I have verified that my Unraid OS is up to date
- I have tested this issue by accessing my server directly (not through a reverse proxy)
- This is not an Unraid Connect related issue (if it is, please submit via the support form instead)
Issue Description
DockerStatsService launches a long-lived docker stats child through execa (9.6.0) with the default buffer: true. The API reads stdout line by line through readline, but execa also buffers the full output, and terminates the subprocess once that buffer hits the default maxBuffer of 100 MB.
With 65 running containers, docker stats --format ... --no-trunc produces about 16.4 KB/s, so the child is killed about 100 minutes after every stream start.
The kill is never noticed:
- The exit handler only acts on
result.failed && !result.signal. Because the subprocess was terminated by a signal, nothing gets logged andstopStatsStream()is never called. statsProcesstherefore stays non-null, sostartStatsStream()returns early (if (this.statsProcess) return;), and the stream is never respawned.
Every container-stats subscription then freezes on its last values until all subscribers disconnect (which triggers stopStatsStream()), or until unraid-api restart.
Code: api/src/unraid-api/graph/resolvers/docker/docker-stats.service.ts (still present on main at 8e587fe).
Steps to Reproduce
- Run a server with a reasonable number of containers (65 here) and subscribe to Docker container stats (the HA Unraid integration, or a GraphQL
subscriptionin the sandbox). - Watch the child:
p=$(pgrep -f "CPUPerc.*no-trunc"); ps -o etime= -p $p; grep wchar /proc/$p/io - When
wcharreaches about 100,000,000 (~100 min here), the child disappears:pgrep -f "CPUPerc.*no-trunc"returns nothing.graphql-api.loghas no entry for it, and the last DockerStatsService line is stillStarting docker stats stream.
Rate check: timeout 60 docker stats --format '{{.ID}};{{.CPUPerc}};{{.MemUsage}};{{.MemPerc}};{{.NetIO}};{{.BlockIO}}' --no-trunc | wc -c → 985,200 bytes/60 s ≈ 16.4 KB/s → 100 MB in ~101 min.
Expected Behavior
The stats stream keeps running for as long as there are subscribers. If the child exits for any reason, the service notices and respawns it.
Actual Behavior
The stats stream stops silently about every 70-100 minutes, with nothing in the logs. Observed stream lifetimes from graphql-api.log Starting/Stopping pairs, compared with HA sensor history: about 85, 70, 95 and 100 minutes. Docker sensors freeze until something resubscribes.
Additional Context
Suggested fix:
this.statsProcess = execa('docker', ['stats', '--format', this.STATS_FORMAT, '--no-trunc'], {
buffer: false, // long-lived stream: never buffer (avoids maxBuffer termination)
reject: false,
});
- Drop
all: true. Nothing reads.all, and an unconsumed merged stream with buffering off can backpressure stdout. - Treat any child exit (including signal and
isMaxBuffer) as end-of-stream: clearstatsProcess, log it, and respawn while subscribers remain.
Locally, patching the built plugin.module-*.js from all: true to buffer: false resolves it.
Ruled out along the way: the Docker daemon (docker stats --no-stream stays responsive throughout), container OOMs, and container create/destroy/restart events (none of them kill the child).
- Ngôn ngữ chính
- TypeScript
- Star
- 123
- Fork
- 25
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của unraid/api
-
Temperature metrics: lm-sensors voltages, fan speeds and power are reported as temperatures (°C)Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
flash { guid } always fails: resolver no longer returns guid but the schema marks it non-nullableĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
parityHistory query fails with NaN when a parity-checks.log record has an empty errors fieldĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
yavorsky/unbuilt.app#65 ·
-
CVE security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
mckinsey/agents-at-scale-ark#4091 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
factory:subtask
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 94/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
NUS-Project-SaBai/project-sabai#386 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
android needs clarification
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
super-productivity/super-productivity#12105 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày