apache/seatunnel · error · ConnectException
Invalid LSN returned from database
Error message
Invalid LSN returned from database
What it means
After successfully parsing the LSN in tryParseLsn, the code calls lsn.isValid(); if the parsed LSN is not valid it throws this ConnectException. This guards against LSN objects that parse syntactically but represent impossible positions (e.g. Lsn.INVALID), preventing the connector from starting from a bogus WAL offset.
Source
Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-opengauss/src/main/java/io/debezium/connector/postgresql/connection/PostgresConnection.java:433
if (lsnStr == null) {
return null;
}
try {
lsn = Lsn.valueOf(lsnStr);
} catch (Exception e) {
throw new ConnectException(
"Value "
+ column
+ " in the pg_replication_slots table for slot = '"
+ slotName
+ "', plugin = '"
+ pluginName
+ "', database = '"
+ database
+ "' is not valid. This is an abnormal situation and the database status should be checked.");
}
if (!lsn.isValid()) {
throw new ConnectException("Invalid LSN returned from database");
}
return lsn;
}
/**
* Drops a replication slot that was created on the DB
*
* @param slotName the name of the replication slot, may not be null
* @return {@code true} if the slot was dropped, {@code false} otherwise
*/
public boolean dropReplicationSlot(String slotName) {
final int ATTEMPTS = 3;
for (int i = 0; i < ATTEMPTS; i++) {
try {
execute("select pg_drop_replication_slot('" + slotName + "')");
return true;
} catch (SQLException e) {
// slot is activeView on GitHub (pinned to cf67b549a7)
Solutions
- Query the slot LSNs directly and compare against pg_current_wal_lsn() to see if the value is a plausible position.
- Drop and recreate the replication slot so the server initializes confirmed_flush_lsn/restart_lsn to real WAL positions.
- Let the server advance the slot: run a short transaction with the connector's plugin so WAL positions are established, then restart the connector.
- Check database health/logs for corruption after unclean shutdowns and restart the instance if needed.
Example fix
-- before: slot reports an invalid sentinel LSN
SELECT pg_drop_replication_slot('seatunnel_slot');
-- after: recreate and prime the slot
SELECT pg_create_logical_replication_slot('seatunnel_slot', 'pgoutput');
BEGIN; INSERT INTO t VALUES (1); COMMIT; -- advance WAL, then start connector Defensive patterns
Strategy: validation
Validate before calling
SELECT restart_lsn, confirmed_flush_lsn, pg_current_wal_lsn() FROM pg_replication_slots WHERE slot_name = 'slot'; -- slot LSNs must be plausible relative to pg_current_wal_lsn()
Try / catch
try {
connection.getReplicationSlotState(slotName, pluginName);
} catch (ConnectException e) {
pgDropSlot(slotName); pgCreateSlot(slotName, pluginName);
} Prevention
- Prime a fresh slot with a small transaction so LSNs become valid.
- Verify database integrity after unclean shutdowns.
- Keep server and connector versions aligned.
When it happens
Trigger: The value in the given pg_replication_slots column parses via Lsn.valueOf but returns false from isValid() — typically the sentinel invalid LSN value or a numerically impossible position returned by the server.
Common situations: A freshly created slot whose LSN fields report an uninitialized/invalid sentinel on some server builds; a database fork (OpenGauss) returning non-standard sentinel values; catalog corruption after an unclean shutdown.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Neither confirmed_flush_lsn nor restart_lsn could be found
- restart_lsn could be found
- Interrupted while waiting for valid replication slot info
- Unable to obtain valid replication slot. Make sure there are
- Value <column> in the pg_replication_slots table for slot =
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/c9df329810b3026a.
Report an issue: GitHub.