{"record":{"id":"9912b4417ec014a9","repo":"apache/seatunnel","slug":"not-supported-create-new-offset-by-filename-and-po","errorCode":null,"errorMessage":"not supported create new Offset by filename and position.","messagePattern":"not supported create new Offset by filename and position\\.","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/source/offset/LsnOffsetFactory.java","lineNumber":69,"sourceCode":"    }\n\n    @Override\n    public Offset latest() {\n        try (JdbcConnection jdbcConnection = dialect.openJdbcConnection(sourceConfig)) {\n            return Db2Utils.currentLsn((Db2Connection) jdbcConnection);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Read the binlog offset error\", e);\n        }\n    }\n\n    @Override\n    public Offset specific(Map<String, String> offset) {\n        return LsnOffset.valueOf(offset);\n    }\n\n    @Override\n    public Offset specific(String filename, Long position) {\n        throw new UnsupportedOperationException(\n                \"not supported create new Offset by filename and position.\");\n    }\n\n    @Override\n    public Offset timestamp(long timestamp) {\n        throw new UnsupportedOperationException(\"not supported create new Offset by timestamp.\");\n    }\n}\n","sourceCodeStart":51,"sourceCodeEnd":78,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/source/offset/LsnOffsetFactory.java#L51-L78","documentation":"LsnOffsetFactory.specific(String filename, Long position) is an explicitly unsupported operation for Db2: unlike MySQL binlog offsets, Db2 offsets are LSN-based and cannot be constructed from a (filename, position) pair. Calling it always throws UnsupportedOperationException with this message. The same applies to the timestamp-based variant.","triggerScenarios":"Any code path that requests an offset from a specific filename and position — e.g. restoring a checkpoint that was captured with MySQL-style filename/position semantics, or caller code that assumes the generic OffsetFactory API supports file/position offsets for all databases.","commonSituations":"Migrating a job or restoring a checkpoint/savepoint produced by a different CDC connector (e.g. MySQL) into the Db2 source; generic framework code calling specific(filename, position) uniformly across dialects; hand-written code building an offset from a binlog-file style spec.","solutions":["Do not restore Db2 offsets from filename/position; use LsnOffsetFactory.specific(Map<String, String>) with LSN-based offset keys instead.","Obtain the offset via latest() and start streaming from the current LSN, or use a previously saved Db2 LSN offset from the connector's own checkpoint.","If migrating from another database's checkpoint, discard the old offsets and take a fresh snapshot with the Db2 source.","Avoid generic code paths that assume file/position offsets; branch on the dialect before constructing offsets."],"exampleFix":"// before\nOffset offset = offsetFactory.specific(\"log.bin\", 123L); // throws\n// after\nOffset offset = offsetFactory.specific(Map.of(\"lsn\", \"0000:0001:0002\"));\n// or start from current position:\nOffset offset = offsetFactory.latest();","handlingStrategy":"type-guard","validationCode":"// Only call specific(filename, position) for binlog-based dialects\nif (offsetFactory instanceof LsnOffsetFactory) {\n    offset = offsetFactory.specific(offsetMap); // LSN map\n} else {\n    offset = offsetFactory.specific(filename, position);\n}","typeGuard":"boolean supportsFilePositionOffsets(OffsetFactory f) {\n    return !(f instanceof LsnOffsetFactory);\n}","tryCatchPattern":"try {\n    offset = offsetFactory.specific(filename, position);\n} catch (UnsupportedOperationException e) {\n    offset = offsetFactory.latest(); // fall back to current LSN for LSN-based dialects\n}","preventionTips":["Never restore Db2 CDC jobs from MySQL-style filename/position checkpoints.","Persist and reuse Db2 LSN offsets captured by the Db2 source's own checkpoint mechanism.","Branch on dialect/OffsetFactory type before choosing an offset-construction API.","Use latest() or specific(Map) for Db2; treat specific(filename, position) as unsupported."],"tags":["db2","cdc","offset","unsupported-operation","lsn"],"backgroundTag":"unsupported-operation","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"}