Try every event database file on delete and say which was left (closes #275)
check / check (push) Successful in 3m31s
check / check (push) Successful in 3m31s
DeleteDB stopped at the first file it could not remove, and the webhook delete handler logged one message for every failure. Once the database file itself is gone, its events are lost, and telling the operator only that a file was left behind suggests otherwise. DeleteDB now tries the database file and both sidecars, and its error wraps ErrEventDBNotRemoved when the database file is still on disk, or ErrSidecarNotRemoved when only a -wal or -shm sidecar is left. The handler logs a different message for each. Model: opus-5-5
This commit is contained in:
@@ -762,13 +762,21 @@ func (h *Handlers) deleteWebhookResources(
|
||||
err = h.dbMgr.DeleteDB(webhook.ID)
|
||||
if err != nil {
|
||||
// The configuration is committed, so the webhook is gone,
|
||||
// but its event database file is still on disk with
|
||||
// but a file of its event database is still on disk with
|
||||
// nothing referencing it. Report the failure rather than
|
||||
// redirecting as though everything succeeded: the file
|
||||
// needs removing by hand, and the logged error names it.
|
||||
h.serverError(
|
||||
w, r, "failed to delete webhook event database", err,
|
||||
)
|
||||
// When only a sidecar is left, the events are already
|
||||
// gone, and the message must not suggest they survive.
|
||||
msg := "webhook deleted, but its event database file is " +
|
||||
"still on disk; remove it by hand"
|
||||
if errors.Is(err, database.ErrSidecarNotRemoved) {
|
||||
msg = "webhook deleted and its events are gone, but a " +
|
||||
"-wal or -shm sidecar of its event database is " +
|
||||
"still on disk; remove it by hand"
|
||||
}
|
||||
|
||||
h.serverError(w, r, msg, err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user