Skip to content

ci(docker-task): clear a dead zccache daemon's state before the task (#3383) - #3384

Merged
zackees merged 2 commits into
masterfrom
fix/3383-zccache-stale-daemon
Nov 1, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/3383-zccache-stale-daemon

Conversation

@zackees

@zackees zackees commented Nov 1, 2026

Copy link
Copy Markdown
Member

Fixes #3383

RED 8c82e33: ci/test_docker_task_zccache.py runs the wrapper script against a fake cache dir. It covers a socket that refuses connects (a bound, then closed listener), a missing socket with a stale lock, spawn-failed marker and process record, a live listening socket, and the command's exit status. It also checks that run() wraps the command only when --env ZCCACHE_CACHE_DIR= is given. Against unchanged code it fails with 4 errors and 1 failure, because ZCCACHE_STALE_SCRIPT doesn't exist.

GREEN 07aaa1f: when a task passes ZCCACHE_CACHE_DIR, docker-task runs the command through a short sh prelude. For each v*/daemon-*.lock, it tries to connect to the daemon's socket (uv run --no-project --offline python, 1 s timeout). If the socket refuses or is missing, it removes the socket, the lock, the .spawn-failed cool-down marker and daemon.running-process.json, then execs the command. A daemon that still accepts connections, such as another container on the same volume, is left alone. Without uv in the image nothing is removed, because the socket can't be tested. The cache contents are never touched, and the command's exit status is kept.

Why: zccache identifies its daemon by pid plus boot_id. Containers share the host's boot_id but each starts a new PID namespace. On a persistent cache volume, the next container finds the old pid taken by another process, decides the daemon "exists but not accepting connections", enters a 60 s cool-down and fails every compile with exit 125.

Verified end to end (linux-validate image, persistent /build/zccache-3383): two consecutive docker_task.py run containers each print docker-task: cleared stale zccache daemon state in /build/zccache-3383/v1.15.5 and compile. Before this change, the second container in the same setup failed with daemon recovery already failed on this cache root and is in its cool-down (three times in a row on 2026-11-01, while working on #3191).

Upstream fix still to file on zccache: identify the daemon by PID-namespace inode plus pid, or by a socket connect.

Tests: ci/test_docker_task_zccache.py (6 cases, about 1 s) and ci/test_docker_task_prune.py pass, and ./lint passes. Python only; no Rust or C tiers apply.

@zackees
zackees enabled auto-merge November 1, 2026 07:26
@zackees
zackees added this pull request to the merge queue Nov 1, 2026
Merged via the queue into master with commit 63c4084 Nov 1, 2026
36 checks passed
@zackees
zackees deleted the fix/3383-zccache-stale-daemon branch November 1, 2026 07:35
@rdoupe rdoupe mentioned this pull request Nov 1, 2026
6 of 7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

build: zccache in a persistent Docker volume treats a reused PID from an earlier container as a live daemon

1 participant