{"record":{"id":"0ab6f6b08d378afd","repo":"apache/seatunnel","slug":"neither-confirmed-flush-lsn-nor-restart-lsn-could","errorCode":null,"errorMessage":"Neither confirmed_flush_lsn nor restart_lsn could be found","messagePattern":"Neither confirmed_flush_lsn nor restart_lsn could be found","errorType":"exception","errorClass":"ConnectException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-opengauss/src/main/java/io/debezium/connector/postgresql/connection/PostgresConnection.java","lineNumber":390,"sourceCode":"    /**\n     * Obtains the LSN to resume streaming from. On PG 9.5 there is no confirmed_flushed_lsn yet, so\n     * restart_lsn will be read instead. This may result in more records to be re-read after a\n     * restart.\n     */\n    private Lsn parseConfirmedFlushLsn(\n            String slotName, String pluginName, String database, ResultSet rs) {\n        Lsn confirmedFlushedLsn = null;\n\n        try {\n            confirmedFlushedLsn =\n                    tryParseLsn(slotName, pluginName, database, rs, \"confirmed_flush_lsn\");\n        } catch (SQLException e) {\n            LOGGER.info(\"unable to find confirmed_flushed_lsn, falling back to restart_lsn\");\n            try {\n                confirmedFlushedLsn =\n                        tryParseLsn(slotName, pluginName, database, rs, \"restart_lsn\");\n            } catch (SQLException e2) {\n                throw new ConnectException(\n                        \"Neither confirmed_flush_lsn nor restart_lsn could be found\");\n            }\n        }\n\n        return confirmedFlushedLsn;\n    }\n\n    private Lsn parseRestartLsn(String slotName, String pluginName, String database, ResultSet rs) {\n        Lsn restartLsn = null;\n        try {\n            restartLsn = tryParseLsn(slotName, pluginName, database, rs, \"restart_lsn\");\n        } catch (SQLException e) {\n            throw new ConnectException(\"restart_lsn could be found\");\n        }\n\n        return restartLsn;\n    }\n","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-opengauss/src/main/java/io/debezium/connector/postgresql/connection/PostgresConnection.java#L372-L408","documentation":"parseConfirmedFlushLsn reads confirmed_flush_lsn from pg_replication_slots; on SQLException it falls back to restart_lsn. If that fallback also throws SQLException, it throws this ConnectException because the connector cannot determine how far the slot has been flushed/restarted, which is required to compute the starting offset.","triggerScenarios":"The ResultSet for the slot lacks both the confirmed_flush_lsn and restart_lsn columns or throws when reading them — e.g. the row disappeared mid-query (slot dropped concurrently), the connected user lacks privileges on pg_replication_slots, or the server/pg_catalog version lacks these columns.","commonSituations":"Slot dropped by another process between listing and reading; connecting with an under-privileged monitoring user; connecting to an old OpenGauss/PostgreSQL variant with a reduced pg_replication_slots schema.","solutions":["Re-check the slot exists and is stable: SELECT slot_name, confirmed_flush_lsn, restart_lsn FROM pg_replication_slots; then restart the connector.","Grant sufficient privileges to the connector user (REPLICATION role or pg_monitor/pg_read_all_data).","Ensure the slot is not being dropped concurrently by other tooling (check pg_drop_replication_slot callers, monitoring agents with slot retention policies).","If the server does not expose these columns, upgrade to a version where pg_replication_slots reports LSNs."],"exampleFix":"-- before: connector user lacks visibility\nCREATE USER cdc_user WITH PASSWORD '...';\n-- after: grant replication privileges\nALTER USER cdc_user WITH REPLICATION;\nGRANT pg_read_all_data TO cdc_user; -- or SELECT on pg_catalog.pg_replication_slots","handlingStrategy":"validation","validationCode":"SELECT confirmed_flush_lsn, restart_lsn FROM pg_replication_slots WHERE slot_name = 'seatunnel_slot'; -- both columns must be readable and non-null","typeGuard":null,"tryCatchPattern":"try {\n    connection.readReplicationSlotInfo(slotName, pluginName);\n} catch (ConnectException e) {\n    // recreate slot and retry with fresh connection\n    dropSlot(slotName); createSlot(slotName, pluginName);\n}","preventionTips":["Run the connector with a REPLICATION-privileged user.","Prevent tooling from dropping slots while connectors are starting.","Check slot stability right before connector startup."],"tags":["cdc","postgres","replication-slot","lsn"],"backgroundTag":"database-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}