apache/seatunnel · error · java.lang.RuntimeException

Read the binlog offset error

Error message

Read the binlog offset error

What it means

LsnOffsetFactory.latest() reads the current LSN (log sequence number) from Db2 via Db2Utils.currentLsn() on a fresh JDBC connection and wraps any failure in RuntimeException("Read the binlog offset error"). It means the connector could not obtain the latest transaction-log position, so it cannot initialize the incremental (streaming) offset.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/source/offset/LsnOffsetFactory.java:58

        this.dialect = dialect;
    }

    @Override
    public Offset earliest() {
        return LsnOffset.INITIAL_OFFSET;
    }

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

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

    @Override
    public Offset specific(Map<String, String> offset) {
        return LsnOffset.valueOf(offset);
    }

    @Override
    public Offset specific(String filename, Long position) {
        throw new UnsupportedOperationException(
                "not supported create new Offset by filename and position.");
    }

    @Override
    public Offset timestamp(long timestamp) {
        throw new UnsupportedOperationException("not supported create new Offset by timestamp.");
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Inspect the cause chain (e.getCause()) for the actual JDBC/Db2 error.
  2. Test the same JDBC URL/credentials outside SeaTunnel to confirm connectivity and auth.
  3. Grant the CDC user permissions to read the log/current-LSN metadata (e.g. access to SYSIBM tables).
  4. Confirm the Db2 version supports the currentLsn query used by Db2Utils; upgrade driver/connector if on an old Db2 release.
  5. Retry after transient network issues; consider restarting the job with checkpointing so offsets recover.

Example fix

// before
Offset o = offsetFactory.latest();
// after
try {
    Offset o = offsetFactory.latest();
} catch (RuntimeException e) {
    LOG.error("Failed to read current LSN: {}", e.getCause() != null ? e.getCause().getMessage() : e.getMessage(), e);
    throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify connectivity + LSN readability before starting the streaming phase
try (JdbcConnection c = dialect.openJdbcConnection(sourceConfig)) {
    Db2Utils.currentLsn((Db2Connection) c); // throws early if perms/version unsupported
}

Try / catch

try {
    Offset o = offsetFactory.latest();
} catch (RuntimeException e) {
    Throwable c = e.getCause();
    LOG.error("LSN read failed: {}", c == null ? e.getMessage() : c.getMessage(), e);
    // decide: retry transient network errors, fail fast on auth/permission errors
    throw e;
}

Prevention

When it happens

Trigger: latest() is called (when starting/streaming from the current position) and either openJdbcConnection() fails or Db2Utils.currentLsn() throws — any Exception, including JDBC connection errors, permission errors reading the log metadata, or a Db2 API failure.

Common situations: Db2 unreachable or credentials wrong when the streaming phase starts; CDC user lacks permission to read log-control tables; Db2 version where the LSN query is unsupported; network interruption at split-start time.

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