Skip to content

ci(esp32): daemon background GC evicts warm esptool install mid-build — elf2image ENOENT #1341

Closed

Description

@zackees

Symptom

Nightly Platforms (2026-08-21, run 32466862619) and 5 board build-matrix jobs (ESP32-P4/H2/C5/C3/C6/C2) fail at the elf2image step:

build error: build failed: selected esptool executable could not be launched — cannot convert firmware.elf to firmware.bin.
  executable: /home/runner/.fbuild/prod/cache/toolchains/tasmota-esptool/8eef29399855b7a6/5.3.0/esptool-linux-amd64/esptool
Error: failed to spawn [...]: No such file or directory (os error 2)

The binary was verified runnable (esptool version spawn OK) during package resolution ~65 s earlier in the same build.

Root cause

PackageBase::staged_install early-returns when install_path.exists() without bumping the DiskCache LRU timestamp — unlike is_cached(), whose contract is explicitly "on a cache hit, bumps the LRU timestamp in the DiskCache index".

Esptool::ensure_installed (#954) takes exactly that path on a warm cache: remove_invalid_cached_install → staged_install → early return. So a cache-restored esptool install keeps the last_used_at from whenever it was originally installed.

Then the daemon's background GC (fbuild-daemon/src/main.rs: first pass 60 s after daemon start, then every 5 min) evicts LRU-first (lru_installed_entries orders by last_used_at ASC) once installed_bytes > installed_budget. Budgets auto-scale to disk: 5% of total disk per phase, so a GitHub runner (~72 GB) gets an ~3.6–4.2 GB installed budget. The Actions-restored toolchain cache plus the freshly extracted ~1.5 GB GCC toolchain exceeds it, and the stale-LRU esptool entry is the first thing deleted — mid-build, between provisioning and elf2image.

Timeline from run 96725838930 (ESP32-P4):

t event
09:25:02 build starts; daemon starts
09:25:12–22 GCC toolchain download+extract (~1.5 GB fresh install)
~09:25:15 esptool warm hit → selected + verified, no LRU touch
~09:26:05 daemon's first background GC pass fires (start+60 s); over budget → evicts esptool (oldest last_used_at)
09:26:28 firmware.elf linked
09:26:29 elf2image → ENOENT

Intermittent by nature: needs restored-cache-over-budget + GC firing inside the provision→elf2image window + esptool older than other entries.

Fix

Treat an existing-install hit in staged_install as a use: call the same LRU touch is_cached() performs on both early-return paths. That makes a warm esptool hit the last eviction candidate instead of the first. Regression test asserts last_used_at advances after a warm staged_install call.

Follow-ups (not required for this fix)

  • The GC doc comment says "skip pinned/leased" but run_gc never consults lease state, and nothing takes a lease for the duration of a build. A real pin/lease held while a build holds a validated path would close the whole class (including over-budget pressure evicting recently-touched entries).
  • reconcile() Phase 1 deletes indexed installs with missing .install_complete sentinels without any lease check either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions