DeleteDB returns on the first failing suffix, so it can report a leftover file when the history is already destroyed #275
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?
Found during the review of #273. Pre-existing, not introduced there.
DeleteDB(internal/database/webhook_db_manager.go) unlinks the suffixes{"", "-wal", "-shm"}in a loop and returns on the FIRST failure. So if the main.dbunlink succeeds and the-walunlink then fails, the caller receives an error and — since #273 — correctly reports it to the operator as "the event database file was left behind, remove it by hand".That message is wrong in exactly that case. The main database is already gone; the history is destroyed. What is left behind is a
-walfragment, not the data. An operator told to clean up a leftover file will delete it and believe nothing was lost.Why this is worth filing now rather than later
It is currently close to unreachable, because the databases open in rollback-journal mode and no
-walor-shmsidecars normally exist. #263 switches every handle to WAL, at which point those sidecars exist routinely and this path becomes genuinely reachable.So the severity of this issue changes the moment that PR lands. Filing it while the connection is visible rather than rediscovering it later.
Still narrow — it needs
os.Removeto fail on a sidecar after succeeding on the main file, which means a permissions or filesystem problem — and the consequence is a misleading message rather than additional data loss. Not milestoned.Definition of done
DeleteDBattempts every suffix rather than returning on the first failure, and reports what actually happened: which files were removed and which were not.deleteWebhookResourcessurfaces that distinction rather than flattening it.Note the interaction: once WAL lands, verify a normal delete removes all three files cleanly, since that is the common path and it currently has no coverage against sidecars existing at all.