fix/static-sweep-periodic
Fix the recurring flagship disk-full outage from extracted static-site versions (2026-11-08 annie: cold wakes refused at 5.4 GiB free, floor 5.9 GiB; same cause as 10-25 and 11-06).
1. The edge sweeps the static cache while running, not only at start.
- A sweep runs after every swap a handler makes (a deploy or promote reaching the box, 30 s settle) and hourly.
- Each app keeps its
currenttree, the previous one (newest other tree by mtime;pointCurrentstamps the mtime when a tree becomes current), every tree a live handler serves (weak pointers), and every tree a request is still being answered from (pinned under the handler's lock). - An app directory where a handler is choosing a tree is skipped.
- Between processes: every edge holds the old shared flock plus a shared Linux OFD record lock on byte 0 of
.edge.lock. A running sweep converts the OFD lock to exclusive and back. Unlike flock, a refused OFD conversion leaves the shared lock in place. - Only an edge whose startup flock check found it alone sweeps while running. The first lock-aware start never does. Non-Linux: startup sweep only.
- The startup sweep now also keeps the previous tree.
2. Dedup / not fully extracting: considered, not done. The edge serves files straight from an extracted tree, and the tree is verified as a whole (manifest sha256, temp extract, rename). Hardlinking unchanged files across versions would mean hashing every file on each extraction and would couple two versions' trees, so a sweep could no longer remove a tree as one unit. With the sweep holding each app to two trees (about 5.2 GB for apt), the bound is fixed. The bigger lever is the apt site shipping its whole package pool every release (~2.6 GB). That belongs to the apt site build, not the edge.
3. The disk alert fires before the cold-wake floor. The box disk rule's line (default 90%) was the floor itself on any disk over 10 GiB (instancectl.DiskFloor = max(1 GiB, 10%)), so annie's alert and its refusals started together. The line is now min(configured, 1 - (floor + 2 × largest kept static tree) / total). On annie that means 11.1 GiB free (81%). On small disks it moves down to the 1 GiB floor. The edge publishes LargestStaticTree to the metrics loop, which runs in the same process (carlos agent). No copy changed. The rules page still says "Default: 90 percent", which is now the ceiling: a copy follow-up, not done here.
Tests: RED/GREEN by mutation (11 mutations, each caught). Astra review: round 1 NOT READY (2 P1 + 1 P2, all fixed), round 2 no P1 (one test-platform P2, fixed).
Discussions
- No discussions on this branch yet.
Tasks
- No tasks yet.
Activity
- paul@keymail.dev pushed 627e32c14 census: re-propose static-sweep-periodic on main's chain
- paul@keymail.dev pushed f58bbd43f Merge origin/main into fix/static-sweep-periodic
- paul@keymail.dev pushed 593cf0ef4 edge: keep sweepStaticCache and setAside as the census units; re-propose
- paul@keymail.dev pushed d21cdb52f census: static-sweep-periodic proposal
- paul@keymail.dev pushed 3952ac1a2 edge: running-sweep tests are Linux only
- paul@keymail.dev pushed b4a8cbbac edge: record lock for running sweeps, pin a request's tree, previous first
- paul@keymail.dev pushed 3fef5d63d host: fire the disk alert with room for two static trees above the floor
- paul@keymail.dev pushed 00910e3f4 edge: sweep the static cache while running, not only at start