aft icon indicating copy to clipboard operation
aft copied to clipboard

Storage: four kinds of files that stay after an interrupted run (semantic temp, TypeScript temp, profiler sidecars, checkpoints)

Open iceteaSA opened this issue 1 week ago • 1 comments

Description

A source review of v0.68.0 found four kinds of files that stay in AFT storage after an interrupted run, because no cleanup step finds them. We saw item 1 on a live system. The other items are from source only.

1. Old semantic index temp files stay

The legacy writer creates semantic.bin.tmp.<pid>.<nanoseconds> (semantic_index.rs:8056-8062). It removes the file only when the write returns an error, not after the process stops abruptly. The normal v0.68.0 write path does not make these files, but nothing removes the files that older versions left. On one machine we saw 4.4 GB of these files from September in one project's semantic folder. The legacy prune removes full project folders, not only these files.

Possible repair: a cleanup step that removes only semantic.bin.tmp.* files that no process holds and that are older than a set age. It must keep the index that AFT can use again.

2. TypeScript server temp folders stay after a crash

Each TypeScript server gets a new random folder in lsp-tmp/ (lsp/manager.rs:9015-9022), and the code comment says that AFT does not use a path that is already there. Only Drop removes the folder (:9001-9005). If AFT stops abruptly, Drop does not run, and no other code removes the remaining typescript-* folders.

Possible repair: at start, remove each lsp-tmp/typescript-* folder when its owner process and its server stopped.

3. Profiler sidecar files are not pruned

A stall capture writes a .profiler file and a .stderr file adjacent to the .txt capture (subc/stall_watchdog.rs:535, :610). The finish step removes them (:642-643). But prune_captures selects only names that end in .txt (:664-681). If the capture does not finish, its sidecars stay with no limit.

Possible repair: let prune_captures also remove the sidecars of each capture it removes, and remove sidecars that have no .txt file and no active capture.

4. The 14-day checkpoint sweep does not remove an incomplete first checkpoint

A checkpoint writes its blobs into the checkpoint folder first (checkpoint.rs:1553) and meta.json last (:1598). The sweep does let Ok(bytes) = fs::read(&meta_path) else { continue; }; (:2256-2259), so a folder without meta.json never gets to the age check.

Possible repair: write into a temporary folder and rename it after AFT writes meta.json, or let the sweep remove a folder without meta.json when the folder is older than the retention time and no lock holds it.

Environment

  • AFT v0.68.0, Linux.
  • Found by source review. We saw item 1 on a live system, with files from an older version.

iceteaSA avatar Nov 26 '26 08:11 iceteaSA

Thanks, @iceteaSA. All four are confirmed. Each cleanup will remove only AFT's own files that are older than a set age and not in use:

  1. Old semantic.bin.tmp.* files from earlier versions.
  2. lsp-tmp/typescript-* folders whose server and owner are gone.
  3. Profiler .profiler and .stderr sidecars, removed with their capture or once orphaned. On Linux only .profiler can be left behind.
  4. A checkpoint folder without meta.json, once it's past the 14-day retention and not locked.

We'll post here when a release carries them.

aft-alfonso[bot] avatar Nov 26 '26 09:11 aft-alfonso[bot]