diff --git a/libpod/sqlite_state.go b/libpod/sqlite_state.go index 6f48d698d4..f3f6d7c307 100644 --- a/libpod/sqlite_state.go +++ b/libpod/sqlite_state.go @@ -378,10 +378,6 @@ func (s *SQLiteState) ValidateDBConfig(runtime *Runtime) (defErr error) { return fmt.Errorf("retrieving DB config: %w", err) } - if err := tx.Commit(); err != nil { - return fmt.Errorf("committing database validation row: %w", err) - } - checkField := func(fieldName, dbVal, ourVal string) error { if dbVal != ourVal { return fmt.Errorf("database %s %q does not match our %s %q: %w", fieldName, dbVal, fieldName, ourVal, define.ErrDBBadConfig) @@ -412,6 +408,12 @@ func (s *SQLiteState) ValidateDBConfig(runtime *Runtime) (defErr error) { return err } + if err := tx.Commit(); err != nil { + return fmt.Errorf("committing database validation row: %w", err) + } + // Do not return any error after the commit call because the defer will + // try to roll back the transaction which results in an logged error. + return nil }