Cookbook recipe

Logical Replication: Table Sync Failure

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source
Estimated investigation4 min

Scenario

Scenario A new payments table is added to a logical replication publication. The subscriber never receives data from it. pg_stat_subscription shows no sync worker for that table. Investigation reveals payments has no primary key — UPDATE…

Investigation Path

Scenario

A new payments table is added to a logical replication publication. The subscriber never receives data from it. pg_stat_subscription shows no sync worker for that table. Investigation reveals payments has no primary key — UPDATE and DELETE statements on the publisher cannot be replicated.

How to Identify

Conditions:

  • New table not appearing on subscriber after REFRESH PUBLICATION
  • pg_stat_subscription_stats shows sync errors
  • Subscriber PostgreSQL logs contain constraint or schema errors during sync
  • Table missing primary key causes UPDATE/DELETE replication to fail

Analysis Steps

-- On PUBLISHER:
-- 1. Check what tables are in the publication
SELECT pubname, schemaname, tablename
FROM   pg_publication_tables
WHERE  pubname = 'my_publication';

-- 2. Check if table has primary key or replica identity
SELECT c.relname,
       CASE i.indisprimary WHEN true THEN 'PRIMARY KEY'
            ELSE 'NO PRIMARY KEY' END AS pk_status,
       c.relreplident  -- 'd'=default(pk), 'f'=full, 'n'=nothing, 'i'=index
FROM   pg_class c
LEFT JOIN pg_index i ON i.indrelid = c.oid AND i.indisprimary
WHERE  c.relname = 'payments';

-- On SUBSCRIBER:
-- 3. Check subscription worker status
SELECT subname, pid, relid::regclass, received_lsn, last_msg_send_time
FROM   pg_stat_subscription;

-- 4. Check for sync errors
SELECT subname, relid::regclass, last_error_msg, last_error_time
FROM   pg_stat_subscription_stats;

Pitfalls

  • Tables without a primary key can receive INSERT replication but cannot replicate UPDATE or DELETE — PostgreSQL cannot identify which row to update without a unique identifier.
  • Schema changes (ADD COLUMN, ALTER COLUMN) on the publisher are not automatically replicated — DDL must be applied manually to the subscriber before or after the publisher change.
  • REFRESH PUBLICATION is required on the subscriber every time a new table is added to the publication.
  • TRUNCATE replication requires PostgreSQL 11+.

Resolution Approach

Add a primary key to tables that need UPDATE/DELETE replication. If adding a primary key is not possible, use REPLICA IDENTITY FULL as a fallback (replicates full row for identity, less efficient). Then REFRESH PUBLICATION on the subscriber.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • Mitigation Actions
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes