quarkusio/quarkus · error · IllegalStateException

Error starting Liquibase

Error message

Error starting Liquibase

What it means

LiquibaseSchemaProvider.resetDatabase (used by the Dev Services / dev mode database reset feature) resolves the LiquibaseFactory for the named database and calls doReset (dropAll). Any exception other than UnsatisfiedResolutionException (datasource not configured, which is ignored) is rethrown as IllegalStateException('Error starting Liquibase'). The wrapped cause holds the real failure, typically from dropping the schema.

Source

Thrown at extensions/liquibase/liquibase/runtime/src/main/java/io/quarkus/liquibase/runtime/LiquibaseSchemaProvider.java:22

import io.quarkus.arc.InstanceHandle;
import io.quarkus.datasource.runtime.DatabaseSchemaProvider;
import io.quarkus.liquibase.LiquibaseFactory;
import liquibase.Liquibase;
import liquibase.exception.LiquibaseException;

public class LiquibaseSchemaProvider implements DatabaseSchemaProvider {
    @Override
    public void resetDatabase(String dbName) {
        try {
            try {
                LiquibaseFactory liquibaseFactory = LiquibaseFactoryUtil.getLiquibaseFactory(dbName).get();
                doReset(liquibaseFactory);
            } catch (UnsatisfiedResolutionException e) {
                //ignore, the DS is not configured
            }
        } catch (Exception e) {
            throw new IllegalStateException("Error starting Liquibase", e);
        }
    }

    @Override
    public void resetAllDatabases() {
        try {
            for (InstanceHandle<LiquibaseFactory> liquibaseFactoryHandle : LiquibaseFactoryUtil.getActiveLiquibaseFactories()) {
                try {
                    LiquibaseFactory liquibaseFactory = liquibaseFactoryHandle.get();
                    doReset(liquibaseFactory);
                } catch (UnsatisfiedResolutionException e) {
                    //ignore, the DS is not configured
                }
            }
        } catch (Exception e) {
            throw new IllegalStateException("Error starting Liquibase", e);
        }
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Inspect the 'Caused by' LiquibaseException for which object failed to drop.
  2. Close other connections to the dev database (other apps, DB clients) before resetting.
  3. Grant the DB user sufficient privileges to drop its schema objects.
  4. Ensure the datasource for dbName is properly configured and reachable.
  5. As a workaround, drop and recreate the dev database/container instead of reset.

Example fix

# before: reset fails due to lingering connections
# after: terminate sessions first, e.g. for Postgres
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='mydb' AND pid <> pg_backend_pid();
# then trigger the reset again
Defensive patterns

Strategy: try-catch

Validate before calling

// Before resetting, ensure no other sessions hold the DB:
// SELECT COUNT(*) FROM pg_stat_activity WHERE datname = 'mydb';
// and that the user can drop objects:
// SELECT has_database_privilege(current_user, 'mydb', 'CREATE');

Try / catch

try {
    schemaProvider.resetDatabase("mydb");
} catch (IllegalStateException e) {
    if ("Error starting Liquibase".equals(e.getMessage())) {
        log.error("Reset of DB '{}' failed: {}", "mydb", e.getCause().getMessage());
    }
}

Prevention

When it happens

Trigger: Dev mode/database reset invokes resetDatabase(dbName); doReset's liquibase.dropAll() throws — active connections prevent dropping, insufficient DB privileges to DROP objects, or the changelog/datasource is misconfigured. UnsatisfiedResolutionException for an unconfigured DB is swallowed, everything else is wrapped.

Common situations: Resetting a dev database while other sessions/tables hold locks; DB user lacking DROP rights; dropping a schema with foreign keys/objects Liquibase can't remove; trying to reset a named datasource that exists but is misconfigured.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/1d35fcdf346b1706. Report an issue: GitHub.