fix: abort idempotent install on non-SQL errors instead of installing - #3196
Open
twiesing wants to merge 1 commit into
Open
fix: abort idempotent install on non-SQL errors instead of installing#3196twiesing wants to merge 1 commit into
twiesing wants to merge 1 commit into
Conversation
The --install --idempotent check only aborted on *pq.Error with a code other than 42P01. Connection-level failures (e.g. net.OpError while a DB container is still coming up) failed the type assertion and fell through to the destructive schema install, wiping a populated database. Use isTableNotExistErr() so that only a missing settings table (42P01) triggers installation and every other error aborts. Fixes knadh#3195
twiesing
force-pushed
the
fix/idempotent-install-error-check
branch
from
August 18, 2026 07:48
44be40b to
7b11878
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3195.
The
--install --idempotentcheck only aborted on*pq.Errorvalues with a code other than42P01. Errors of any other type — which is what connection-level failures surface as (e.g.*net.OpErrorafterdatabase/sqlexhausts itsErrBadConnretries, exactly the situation while a DB container is still coming up) — failed the type assertion, skipped theFatalf, and fell through toinstallSchema(). Sinceschema.sqldrops every table before recreating it, a transient connectivity blip during the check could wipe a populated database (see the issue for a real-world incident).This change reuses
isTableNotExistErr()fromcmd/upgrade.goso that only the positive "settings table does not exist" (42P01) signal triggers installation; every other error — SQL or otherwise — aborts before anything destructive runs.Behavior change: previously non-fatal check failures (network errors,
driver.ErrBadConn, context cancellation) now abort with an error. That is intentional — none of them proves the database is empty, and in a containerized setup the process simply restarts and re-checks.Verified with
go build ./cmd,go vet ./cmdandgofmt.