apache/seatunnel · warning · CatalogException

Failed to close %s via JDBC.

Error message

Failed to close %s via JDBC.

What it means

CatalogException thrown by closeDatabaseConnection when Connection.close() raises a SQLException. This happens during catalog shutdown/cleanup when releasing the cached connection for a given database URL.

Source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java:585

            executeInternal(defaultUrl, getCreateDatabaseSql(databaseName));
        } catch (Exception e) {
            throw new CatalogException(
                    String.format(
                            "Failed creating database %s in catalog %s",
                            databaseName, this.catalogName),
                    e);
        }
    }

    protected void closeDatabaseConnection(String databaseName) {
        String dbUrl = getUrlFromDatabaseName(databaseName);
        try {
            Connection connection = connectionMap.remove(dbUrl);
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            throw new CatalogException(String.format("Failed to close %s via JDBC.", dbUrl), e);
        }
    }

    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)
            throws TableNotExistException, CatalogException {
        checkNotNull(tablePath, "Table path cannot be null");
        if (!tableExists(tablePath)) {
            if (ignoreIfNotExists) {
                return;
            }
            throw new TableNotExistException(catalogName, tablePath);
        }
        truncateTableInternal(tablePath);
    }

    @Override
    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)
            throws DatabaseNotExistException, CatalogException {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Inspect the wrapped SQLException; in most cases the connection is dead and can be safely discarded.
  2. Retry close once; if it still fails, remove the connection from the pool and continue shutdown.
  3. Enable connection keep-alive/validation queries to avoid stale connections.
  4. Upgrade the JDBC driver if close() errors are a known issue for your version.
  5. Treat as non-fatal during cleanup if all real work already completed.

Example fix

// before
catalog.close(); // throws on stale connection
// after
try {
    catalog.close();
} catch (CatalogException e) {
    LOG.warn("Ignoring error closing catalog connection: {}", e.getMessage());
}
Defensive patterns

Strategy: try-catch

Try / catch

try { catalog.close(); } catch (CatalogException e) { LOG.warn("Failed closing JDBC catalog connection (ignored): {}", e.getMessage()); }

Prevention

When it happens

Trigger: Calling catalog.close() (or internal closeDatabaseConnection) when the cached JDBC connection for dbUrl is already broken/aborted by the server, network was dropped, or the driver reports an error on close.

Common situations: Long-running job where the DB server reaped idle connections; firewall/NAT dropped the TCP session; driver bug or connection pool mismanagement; catalog closed after a prior connectivity failure.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/b41d61247f1bd3da. Report an issue: GitHub.