criccomini
11/09/2025, 12:30 AM// Tracks the most recent SST in the WAL that has been flushed on the last L0 is compacted. When an Immutable
// Memtable (IMM) is flushed to L0, we record the recent flushed WAL ID as `replay_after_wal_id`. During recovery,
// we use `replay_after_wal_id + 1` as the starting point for WAL replay, and skip the WAL entries with
// smaller `seq` than `last_l0_seq`.
replay_after_wal_id: ulong;
// The most recent SST in the WAL at the time manifest was updated.
wal_id_last_seen: ulong;criccomini
11/09/2025, 12:35 AM• Short answer: they’re likely pinned by a checkpoint.
Why WAL 4 and 5 linger
- Active checkpoint pins a WAL ID window: (replay_after_wal_id, next_wal_sst_id). WAL GC skips any file whose ID falls in that open interval for any active manifest/
checkpoint. See slatedb/src/manifest/mod.rs:208 and slatedb/src/garbage_collector/wal_gc.rs:62.
- DbReader creates/refreshes a checkpoint by default (10‑minute lifetime). If a reader was opened when 4–5 were the “in‑flight” WALs, that checkpoint will keep exactly
those IDs alive until it expires or is replaced; newer IDs (6–12) outside that window can be deleted. Reader behavior: slatedb/src/config.rs:845 (10m), slatedb/src/
db_reader.rs:212, 220–236, 476–485.
- GC only considers WALs with ID < replay_after_wal_id (the last WAL fully covered by an L0 flush) and that aren’t referenced by any active manifest/checkpoint: slatedb/src/
garbage_collector/wal_gc.rs:81. It also keeps the WAL whose ID == replay_after_wal_id (exclusive bound), so one “oldest” file often remains even without checkpoints.
- Default WAL GC min_age is 24h unless you override it when running/scheduling GC, so recent files won’t be deleted otherwise: slatedb/src/garbage_collector.rs:27. If you saw
6–12 disappear, you likely ran GC with a smaller min_age; 4–5 remained because of the checkpoint pin.criccomini
11/09/2025, 12:36 AMPierre
11/09/2025, 6:30 AM