Archive sweep repeats open/prune/close once per database target instead of once per webhook #101
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Surfaced during the independent review of PR #95 (#89) and confirmed by the implementer. Out of scope for #89, so filing it here — it is currently recorded only in that PR's body, which disappears on merge.
Problem
ArchiveSweeper.sweepiterates targets, not webhooks. A webhook has exactly one archive file (archive-{webhookID}.db), but it may have more than onedatabasetarget, and each target carries its ownexpiryin its config JSON.So a webhook with two positive-expiry
databasetargets has its single archive file opened, pruned, and closed twice per tick — once per target. With N such targets it is N times per tick. The work is redundant: the second pass prunes an archive the first pass just pruned.Why it is not urgent
databasetargets on one webhook is an unusual configuration.RETENTION_SWEEP_INTERVAL, default one hour).It is still wasted file I/O on a path whose whole design goal is to bound file churn, and it makes the close/reopen debounce accounting harder to reason about than it should be.
Second-order oddity worth deciding on
Because the sweep is per-target, two
databasetargets on the same webhook with different expiry values both prune the same file. The shorter expiry effectively wins, since whichever pass runs with the tighter cutoff deletes the most rows. Nothing documents that, and it is not obviously the intended semantics — arguably a webhook's archive should have one retention policy, not one per target.Definition of done
databasetargets with differing expiry values (longest wins, shortest wins, or reject the configuration at target-creation time). Whichever is chosen, state it in the README next to the existing archive documentation.databasetargets on one webhook asserting the archive is opened once per tick, and a test pinning the chosen multi-expiry rule.make checkgreen via the repo's own entrypoints;.golangci.ymluntouched.