apache/seatunnel · error · DebeziumException

Error reading default database charsets:

Error message

Error reading default database charsets: 

What it means

readDatabaseCollations() queries information_schema.schemata for each database's default character set and collation; any SQLException is rethrown as a DebeziumException with this message and the server's error text appended. It means the connector could not read default charsets while preparing the snapshot schema. The query target (information_schema) exists on all supported servers, so this is almost always a privilege, connection, or server availability problem.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/MySqlConnection.java:544

                    rs -> {
                        final Map<String, DatabaseLocales> charsets = new HashMap<>();
                        while (rs.next()) {
                            String dbName = rs.getString(1);
                            String charset = rs.getString(2);
                            String collation = rs.getString(3);
                            if (dbName != null && (charset != null || collation != null)) {
                                charsets.put(dbName, new DatabaseLocales(charset, collation));
                                LOGGER.debug(
                                        "\t{} = {}, {}",
                                        Strings.pad(dbName, 45, ' '),
                                        Strings.pad(charset, 45, ' '),
                                        Strings.pad(collation, 45, ' '));
                            }
                        }
                        return charsets;
                    });
        } catch (SQLException e) {
            throw new DebeziumException(
                    "Error reading default database charsets: " + e.getMessage(), e);
        }
    }

    public MySqlConnectionConfiguration connectionConfig() {
        return connectionConfig;
    }

    public String connectionString() {
        return connectionString(URL_PATTERN);
    }

    public static String getJavaEncodingForMysqlCharSet(String mysqlCharsetName) {
        return CharsetMappingWrapper.getJavaEncodingForMysqlCharSet(mysqlCharsetName);
    }

    /** Helper to gain access to protected method */
    private static final class CharsetMappingWrapper extends CharsetMapping {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Read the appended `e.getMessage()` for the actual MySQL error and address that specific cause.
  2. Check/reestablish connectivity to MySQL; raise wait_timeout or ensure the connection is fresh at snapshot start.
  3. Grant the CDC user broad SELECT access: GRANT SELECT ON *.* TO 'user'@'%'; so information_schema.schemata is readable.
  4. If partial_revokes restricts access, remove the offending revocations or capture fewer databases.
  5. Retry the job — a transient drop during snapshot is typically recoverable on a fresh connection.

Example fix

-- before: user restricted to one DB on MySQL 8 with partial_revokes
REVOKE SELECT ON `otherdb`.* FROM 'stuser'@'%';
-- after: allow full catalog visibility for CDC snapshot
GRANT SELECT ON *.* TO 'stuser'@'%';
Defensive patterns

Strategy: retry

Validate before calling

// Validate access and connection stability beforehand:
// mysql -u stuser -p -h <host> -e "SELECT schema_name FROM information_schema.schemata LIMIT 1;"
// Also confirm wait_timeout is not aggressively low for the job's connection.

Try / catch

try {
    runSnapshot(); // internally calls readDatabaseCollations()
} catch (DebeziumException e) {
    if (e.getMessage().contains("Error reading default database charsets")) {
        // transient connection drop is the usual cause: wait and retry the job
        Thread.sleep(5000);
        retryWithBackoff(3);
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling MySqlConnection.readDatabaseCollations() (from snapshot schema reading) when the JDBC connection is broken, when the error message says the user is denied (rare information_schema restrictions / partial_revokes), or when the server drops the connection mid-query on large information_schema scans.

Common situations: Network interruption or MySQL wait_timeout killing an idle connection during snapshot; revoked SELECT on information_schema via partial_revokes; connection terminated by a proxy or by server restart mid-snapshot; extremely many schemas causing query timeout.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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