Skip to content

fix(restore): a commit that fails is a restore that failed - #671

Merged
EVWorth merged 1 commit into
mainfrom
fix/restore-commit-check
Sep 12, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/restore-commit-check

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 12, 2026

Copy link
Copy Markdown
Owner

From the full-project review — a sweep for discarded Results, which found one in code this same release added. Stacked on #669.

The restore's transaction outcome was thrown away:

let _ = sqlx::raw_sql(AssertSqlSafe(statement.to_string())).execute(&mut *conn).await;

So:

  • a failed COMMIT meant reporting "Restore complete — 400 statements in 12s" with nothing committed
  • a failed ROLLBACK meant reporting "Rolled back — the database is as it was" when it may not be

Now a failed COMMIT is its own error in the summary — "The statements ran but could not be committed, so none of them took effect" — and a failed ROLLBACK clears rolledBack and sets partiallyApplied, because a rollback that did not happen cannot be claimed to have undone anything.

The backup's snapshot COMMIT only closes a read transaction and cannot lose data, but it is logged rather than discarded: a connection going back to the pool inside a transaction is exactly what #658 was.

+1 unit test on the summary shape, +1 live-server test that cuts the session mid-restore and asserts a clean summary is never reported over a database that received nothing. Both servers green.

@EVWorth
EVWorth changed the base branch from fix/session-save-reporting to main September 12, 2026 13:04
The transaction's own outcome was discarded — `let _ = COMMIT`. So a
restore could report "complete — 400 statements" with nothing committed,
and a rollback that itself failed was still reported as "rolled back —
the database is as it was".

Now: a failed COMMIT is its own error in the summary, saying that the
statements ran and none of them took effect; a failed ROLLBACK clears
`rolledBack` and sets `partiallyApplied`, because a rollback that did
not happen cannot be claimed to have undone anything.

The backup's snapshot COMMIT is only closing a read transaction, so it
cannot lose data — but it is logged rather than discarded, since a
connection going back to the pool inside a transaction is what #658 was.

Found by the review sweep for discarded Results, in code this same
release added.
@EVWorth
EVWorth force-pushed the fix/restore-commit-check branch from 514a2f0 to c833a8a Compare September 12, 2026 13:04
@EVWorth
EVWorth merged commit 28344fd into main Sep 12, 2026
12 checks passed
@EVWorth
EVWorth deleted the fix/restore-commit-check branch September 12, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant