apache/seatunnel · warning

Failed to close catalog

Error message

Failed to close catalog

What it means

In DatabendSourceFactory.createSource()'s finally block, closing the Databend catalog throws and this warning is logged. The source has already been constructed, so job execution is unaffected — this only means the catalog's underlying connection may leak until GC. It is almost always a secondary symptom of a broken JDBC connection.

Source

Thrown at seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/source/DatabendSourceFactory.java:120

                        "Failed to get table schema from catalog, will try to infer schema from query",
                        e);
                TableSchema.Builder builder = TableSchema.builder();
                TableSchema tableSchema = builder.build();
                CatalogTable catalogTable =
                        CatalogTable.of(
                                TableIdentifier.of(catalogName, database, table),
                                tableSchema,
                                Collections.emptyMap(),
                                Collections.emptyList(),
                                "",
                                catalogName);
                return new DatabendSource(
                        catalogTable, sql, url, ssl, username, password, fetchSize);
            } finally {
                try {
                    catalog.close();
                } catch (Exception e) {
                    log.warn("Failed to close catalog", e);
                }
            }
        };
    }

    /** according to the options, build the SQL statement */
    private String buildSqlStatement(ReadonlyConfig options) {
        if (options.getOptional(DatabendSourceOptions.SQL).isPresent()) {
            return options.get(DatabendSourceOptions.SQL);
        }

        String query = options.getOptional(DatabendOptions.QUERY).orElse(null);
        if (query != null) {
            return query;
        }

        String database = options.getOptional(DATABASE).orElse(null);
        String table = options.getOptional(DatabendOptions.TABLE).orElse(null);

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Treat as a symptom: fix the underlying connection failure logged earlier
  2. Check for connection leaks/timeouts; tune JDBC connection parameters
  3. Ensure the catalog isn't closed twice elsewhere in custom code
  4. If warnings are noisy, safely ignore — the job result is not affected; consider upgrading the JDBC driver

Example fix

// before
} finally {
    try {
        catalog.close();
    } catch (Exception e) {
        log.warn("Failed to close catalog", e);
    }
}
// after
} finally {
    try {
        if (catalog != null) {
            catalog.close();
        }
    } catch (Exception e) {
        log.debug("Catalog close failed (likely connection already closed): {}", e.getMessage());
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

try (Connection c = DriverManager.getConnection(url, user, pass)) {
    if (!c.isValid(5)) throw new IllegalStateException("Databend connection invalid");
}

Type guard

boolean safelyClosable(AutoCloseable catalog) {
    return catalog != null; // close() exceptions are logged, never fatal
}

Try / catch

try {
    Source source = factory.createSource(context);
} catch (Exception e) {
    log.warn("createSource failed (catalog close warning may also appear)", e);
    // focus on the primary exception, not the close warning
}

Prevention

When it happens

Trigger: catalog.close() is called after source creation (success or failure) and the underlying connection is already dead/closed, making the driver's close() throw.

Common situations: Databend restarted or connection dropped during source initialization; factory error path where catalog creation half-failed; driver quirks closing an already-invalid connection.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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