apache/seatunnel · error · RuntimeException

Read the binlog offset error

Error message

Read the binlog offset error

What it means

BinlogOffsetFactory.earliest() opens a JDBC connection to MySQL via the dialect to read the earliest available binlog offset (MySqlConnectionUtils.earliestBinlogOffset). Any failure opening the connection or querying binlog coordinates is rethrown as a RuntimeException('Read the binlog offset error').

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/offset/BinlogOffsetFactory.java:49

/** An offset factory class create {@link BinlogOffset} instance. */
public class BinlogOffsetFactory extends OffsetFactory {

    private final MySqlSourceConfig sourceConfig;

    private final JdbcDataSourceDialect dialect;

    public BinlogOffsetFactory(
            MySqlSourceConfigFactory configFactory, JdbcDataSourceDialect dialect) {
        this.sourceConfig = configFactory.create(0);
        this.dialect = dialect;
    }

    @Override
    public Offset earliest() {
        try (JdbcConnection jdbcConnection = dialect.openJdbcConnection(sourceConfig)) {
            return MySqlConnectionUtils.earliestBinlogOffset(jdbcConnection);
        } catch (Exception e) {
            throw new RuntimeException("Read the binlog offset error", e);
        }
    }

    @Override
    public Offset neverStop() {
        return BinlogOffset.NO_STOPPING_OFFSET;
    }

    @Override
    public Offset latest() {
        try (JdbcConnection jdbcConnection = dialect.openJdbcConnection(sourceConfig)) {
            return MySqlConnectionUtils.currentBinlogOffset(jdbcConnection);
        } catch (Exception e) {
            throw new RuntimeException("Read the binlog offset error", e);
        }
    }

    @Override

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Check the root cause ('Caused by') for connection vs. SQL errors and fix connectivity or credentials first
  2. Grant the CDC user REPLICATION CLIENT (and REPLICATION SLAVE) privileges and verify with a manual mysql client connection
  3. Confirm hostname/port/SSL settings and that MySQL is reachable from the SeaTunnel node
  4. Retry if the failure was a transient network blip — job submission can be re-run

Example fix

// before
url = "jdbc:mysql://localhost:3306"
// after (correct host, and a user with REPLICATION privileges)
url = "jdbc:mysql://mysql-prod:3306"
username = "sea_cdc"
password = "***"
Defensive patterns

Strategy: retry

Validate before calling

// before submitting, verify connectivity and privileges
try (Connection c = DriverManager.getConnection(url, user, pass)) {
    try (Statement s = c.createStatement(); ResultSet r = s.executeQuery("SHOW MASTER STATUS")) {
        if (!r.next()) throw new IllegalStateException("CDC user cannot read binlog status");
    }
}

Try / catch

try {
    offsetFactory.earliest();
} catch (RuntimeException e) {
    LOG.error("Failed to read binlog offset (check JDBC config/privileges): {}", e.getCause(), e);
    throw e;
}

Prevention

When it happens

Trigger: startup.mode='earliest' triggering BinlogOffsetFactory.earliest(); underlying cause typically SQLException/SQLTimeout from openJdbcConnection or the binlog coordinate query.

Common situations: Wrong hostname/port or credentials in the source config; MySQL user lacking REPLICATION CLIENT/SLAVE privileges; network/firewall blocking 3306; server binlogs purged so earliest coordinates can't be computed; MySQL down.

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/f8ea19dbdd2a3654. Report an issue: GitHub.