{"record":{"id":"905c93c2654a35a0","repo":"apache/seatunnel","slug":"failed-to-convert-timestamp-d-s-to-lsn-s","errorCode":null,"errorMessage":"Failed to convert timestamp %d (%s) to LSN: %s","messagePattern":"Failed to convert timestamp (.+?) \\((.+?)\\) to LSN: (.+?)","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/utils/SqlServerUtils.java","lineNumber":336,"sourceCode":"                        }\n                        byte[] lsnBytes = rs.getBytes(\"lsn\");\n                        if (lsnBytes == null) {\n                            throw new SQLException(\n                                    String.format(\n                                            \"LSN is null for timestamp %d (%s). \"\n                                                    + \"This may indicate that CDC is not enabled or the timestamp is too old.\",\n                                            timestampMs, new java.sql.Timestamp(timestampMs)));\n                        }\n                        Lsn lsn = Lsn.valueOf(lsnBytes);\n                        log.info(\n                                \"Converted timestamp {} ({}) to LSN: {}\",\n                                timestampMs,\n                                new Timestamp(timestampMs),\n                                lsn);\n                        return LsnOffset.timestampBoundary(lsn.toString());\n                    });\n        } catch (SQLException e) {\n            throw new SeaTunnelException(\n                    String.format(\n                            \"Failed to convert timestamp %d (%s) to LSN: %s\",\n                            timestampMs, new Timestamp(timestampMs), e.getMessage()),\n                    e);\n        }\n    }\n\n    /**\n     * Convert LSN string to LsnOffset.\n     *\n     * @param lsnString LSN string in format \"00000027:00000a80:0003\"\n     * @return LsnOffset\n     */\n    public static LsnOffset lsnStringToOffset(String lsnString) {\n        try {\n            // Validate LSN format\n            Lsn.valueOf(lsnString);\n            return LsnOffset.valueOf(lsnString);","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/utils/SqlServerUtils.java#L318-L354","documentation":"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.","triggerScenarios":"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.","commonSituations":"SQL Server connection lost mid-query; user lacks SELECT on cdc.lsn_time_mapping; transient network blip during incremental snapshot startup.","solutions":["Read the wrapped cause (e.getCause()) to identify the real SQL error","Verify connectivity and retry; transient network errors may succeed on retry","Grant the CDC user access to cdc schema tables and functions","Fix the root cause from 620/621 if the cause is a missing/null LSN"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return SqlServerUtils.timestampToLsn(conn, tsMs, tz);\n} catch (SeaTunnelException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof java.sql.SQLTransientException) {\n        // retry with backoff\n    }\n    throw e;\n}","preventionTips":["Use a resilient JDBC connection (keepalive/reconnect) for CDC metadata queries","Grant CDC read permissions to the connector user","Inspect getCause() to distinguish transient vs deterministic failures"],"tags":["sqlserver","cdc","lsn","sql-exception"],"backgroundTag":"sql-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}