apache/seatunnel · error · SeaTunnelException

Failed to convert timestamp %d (%s) to LSN: %s

Error message

Failed to convert timestamp %d (%s) to LSN: %s

What it means

timestampToLsn wraps any SQLException raised while querying the LSN for a timestamp into a SeaTunnelException with this message, preserving the original cause. It is a generic failure wrapper for the timestamp→LSN conversion query.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/utils/SqlServerUtils.java:336

                        }
                        byte[] lsnBytes = rs.getBytes("lsn");
                        if (lsnBytes == null) {
                            throw new SQLException(
                                    String.format(
                                            "LSN is null for timestamp %d (%s). "
                                                    + "This may indicate that CDC is not enabled or the timestamp is too old.",
                                            timestampMs, new java.sql.Timestamp(timestampMs)));
                        }
                        Lsn lsn = Lsn.valueOf(lsnBytes);
                        log.info(
                                "Converted timestamp {} ({}) to LSN: {}",
                                timestampMs,
                                new Timestamp(timestampMs),
                                lsn);
                        return LsnOffset.timestampBoundary(lsn.toString());
                    });
        } catch (SQLException e) {
            throw new SeaTunnelException(
                    String.format(
                            "Failed to convert timestamp %d (%s) to LSN: %s",
                            timestampMs, new Timestamp(timestampMs), e.getMessage()),
                    e);
        }
    }

    /**
     * Convert LSN string to LsnOffset.
     *
     * @param lsnString LSN string in format "00000027:00000a80:0003"
     * @return LsnOffset
     */
    public static LsnOffset lsnStringToOffset(String lsnString) {
        try {
            // Validate LSN format
            Lsn.valueOf(lsnString);
            return LsnOffset.valueOf(lsnString);

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Read the wrapped cause (e.getCause()) to identify the real SQL error
  2. Verify connectivity and retry; transient network errors may succeed on retry
  3. Grant the CDC user access to cdc schema tables and functions
  4. Fix the root cause from 620/621 if the cause is a missing/null LSN
Defensive patterns

Strategy: try-catch

Try / catch

try {
    return SqlServerUtils.timestampToLsn(conn, tsMs, tz);
} catch (SeaTunnelException e) {
    Throwable cause = e.getCause();
    if (cause instanceof java.sql.SQLTransientException) {
        // retry with backoff
    }
    throw e;
}

Prevention

When it happens

Trigger: SQLException from the underlying query: connection dropped, permissions denied on CDC functions, query timeout, or the inner 'No LSN found' / 'LSN is null' errors bubbling up.

Common situations: SQL Server connection lost mid-query; user lacks SELECT on cdc.lsn_time_mapping; transient network blip during incremental snapshot startup.

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