fdw_error (logical replication / LW class)
Production Risk
High — logical replication stops applying changes; replication lag will grow until the issue is resolved.
A generic error raised in the logical replication subsystem (class LW). This is the catch-all code for logical replication worker errors that do not map to a more specific code.
- 1Logical replication worker process encounters an unexpected error.
- 2Subscription receives a row change that cannot be applied (e.g. missing target table).
- 3Replication slot is invalidated or WAL is no longer available.
- 4Network failure between publisher and subscriber during streaming.
-- On subscriber: CREATE SUBSCRIPTION mysub CONNECTION 'host=publisher dbname=mydb user=replicator' PUBLICATION mypub;
expected output
ERROR: LW000: could not connect to the publisher
Fix 1
Check pg_subscription_rel for failed table syncs
SELECT subname, srrelid::regclass, srsubstate FROM pg_subscription_rel JOIN pg_subscription ON pg_subscription.oid = pg_subscription_rel.srsubid WHERE srsubstate != 'r';
Why this works
Identifies which tables are not in the ready (r) state, indicating sync failures.
Fix 2
Check PostgreSQL logs on both publisher and subscriber
-- Review both sides: -- tail -f $PGDATA/log/postgresql.log
Why this works
Logical replication errors are always accompanied by detail messages in the server log.
Fix 3
Re-enable or recreate the subscription
ALTER SUBSCRIPTION mysub ENABLE; -- or if the slot was lost: DROP SUBSCRIPTION mysub; -- Recreate the subscription
Why this works
Resets the subscription state, allowing replication to restart from a clean point.
✕ Do not drop a replication slot on the publisher without first disabling the subscription
The subscriber will repeatedly fail trying to connect to a slot that no longer exists
Logical replication and the LW error class introduced in PostgreSQL 10
PostgreSQL 17 — LW000 logical replication error class
https://www.postgresql.org/docs/current/logical-replication.html ↗https://www.postgresql.org/docs/current/sql-createsubscription.html ↗Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev