apache/seatunnel · error · RuntimeException

Read the binlog offset error

Error message

Read the binlog offset error

What it means

Thrown by LsnOffsetFactory.latest() when opening the JDBC connection or computing SqlServerUtils.currentLsn() fails; the startup offset cannot be determined so the RuntimeException aborts the reader. It masks the underlying cause, so inspect the wrapped exception.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/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 SqlServerUtils.currentLsn((SqlServerConnection) 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) {
        try (JdbcConnection jdbcConnection = dialect.openJdbcConnection(sourceConfig)) {
            return SqlServerUtils.timestampToLsn(

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Check the wrapped 'e' cause — usually connection or permission failure
  2. Verify credentials/host/port and that the database is reachable from the job
  3. Grant the login permission to query the current LSN (VIEW DATABASE STATE, CDC access)
  4. Retry the job after any AG failover completes
  5. Confirm the database has CDC enabled (is_cdc_enabled = 1)

Example fix

// before
} catch (Exception e) {
    throw new RuntimeException("Read the binlog offset error", e);
}
// after
} catch (Exception e) {
    LOG.error("Failed to read current LSN; check connectivity and CDC permissions", e);
    throw new RuntimeException("Read the binlog offset error: " + e.getMessage(), e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight before job start
try (Connection c = DriverManager.getConnection(url, user, pass)) {
    ResultSet rs = c.createStatement().executeQuery(
        "SELECT is_cdc_enabled FROM sys.databases WHERE name = DB_NAME()");
    rs.next();
    if (rs.getInt(1) != 1) throw new IllegalStateException("CDC not enabled on database");
}

Try / catch

try {
    Offset o = offsetFactory.latest();
} catch (RuntimeException e) {
    Throwable cause = e.getCause();
    LOG.error("Cannot determine current LSN; cause=" + (cause == null ? "?" : cause.getMessage()));
    throw e;
}

Prevention

When it happens

Trigger: Calling latest() when the SQL Server connection fails (bad credentials, unreachable host) or currentLsn() fails (permission denied on sys.dm/db catalog, query error, CDC not enabled on the database).

Common situations: Wrong username/password in config; login lacking VIEW DATABASE STATE / CDC access; AG failover mid-read; firewall dropping the connection during job start.

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