LW000
PostgreSQLERRORNotableLogical ReplicationHIGH confidence

fdw_error (logical replication / LW class)

Production Risk

High — logical replication stops applying changes; replication lag will grow until the issue is resolved.

What this means

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.

Why it happens
  1. 1Logical replication worker process encounters an unexpected error.
  2. 2Subscription receives a row change that cannot be applied (e.g. missing target table).
  3. 3Replication slot is invalidated or WAL is no longer available.
  4. 4Network failure between publisher and subscriber during streaming.
How to reproduce
trigger — this will error
trigger — this will error
-- 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

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

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

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.

What not to do

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

Version notes
10

Logical replication and the LW error class introduced in PostgreSQL 10

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All PostgreSQL errors