Skip to content

SegmentCache.init's stale-session sweep deletes a concurrent >1h session's directory — the age check has no liveness half #451

Description

@cmcpherson274

A code-read finding, disclosed before we have reproduced the failure end-to-end — filing it because concurrent engines make it reachable and the sweep's own comment says it was designed for a world without them.

The read

SegmentCache.init sweeps sibling session directories under <tmp>/aether-segments/ (Video/SegmentCache.swift:107–124 at 6.56.3): every entry that is not the current session and whose directory creation date is nil or older than one hour is removed. The comment above the baseDir says the prefix "lets sweepStaleSessionDirs() find sibling dirs from crashed sessions" — with one engine per process at a time, the sibling is always dead, and the sweep is exactly right.

With two engines alive in one process the same predicate reads differently: the directory's creation date is the session's start time, so any session older than one hour is indistinguishable from a crashed one. A viewer an hour into a film (or a long live timeshift hold) whose host then constructs a second engine — a preview tile, a second surface, even a quick failed tune that gets as far as init — has their segment directory deleted underneath the running session.

What we have not done

We have not run the two-engine >1 h scenario to observe the failure mode (whether store() fails soft, whether an .alwaysMapped read faults, whether playback just re-fetches). Our surfaces tear engines down well inside an hour today, so this is ahead of us rather than behind us — but the N-surface direction (the preview tile shipped today, per the other issue) makes it a matter of time.

The ask

A liveness check next to the age check. In-process is enough: a process-global registry of live session IDs (the sweep already knows its own), so the predicate becomes "not mine, not live, and older than an hour". A crashed sibling still sweeps exactly as today.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions