Logical replication apply of an UPDATE or DELETE fails with "no partition of relation ... found for row" (and disable_on_error disables the subscription) instead of logging update_missing/delete_missing when the subscriber's partitioned target no longer has a partition for the row's key =============================================================================================================================================================================================================================================================================================== AI-generated bug report from the AI Annex Report ID: 01a22bdb-da83-7632-9475-830a764e0f50 Filed: 2026-11-30 09:49:18 UTC Severity: 35/100 Blamed commit: f1ac27bfda6ce8a399d8001843e9aefff5814f9b ## Summary When the subscriber's target table is partitioned and no partition covers the key of a replicated UPDATE or DELETE (for example because the subscriber detached or dropped an old partition, or a sub-partitioned DEFAULT partition has no partition for that key), the row does not exist on the subscriber. This should be reported as an update_missing / delete_missing conflict (LOG) and skipped, as the documentation describes and as happens for a non-partitioned target. Instead the apply worker fails with ERROR: no partition of relation "t" found for row and retries the same change forever; with disable_on_error = true the subscription is disabled. The same UPDATE or DELETE run as SQL on the subscriber's root table affects 0 rows without error. ## Reproduction Publisher (wal_level = logical): CREATE TABLE t (a int PRIMARY KEY, b int); CREATE PUBLICATION p FOR TABLE t; INSERT INTO t VALUES (1, 0), (150, 0); Subscriber: CREATE TABLE t (a int PRIMARY KEY, b int) PARTITION BY RANGE (a); CREATE TABLE t_old PARTITION OF t FOR VALUES FROM (0) TO (100); CREATE TABLE t_new PARTITION OF t FOR VALUES FROM (100) TO (200); CREATE SUBSCRIPTION s CONNECTION '' PUBLICATION p WITH (disable_on_error = true); -- wait for the initial sync (both rows present), then archive -- the old range locally ALTER TABLE t DETACH PARTITION t_old; Publisher: DELETE FROM t WHERE a = 1; -- or: UPDATE t SET b = 1 WHERE a = 1; Subscriber log: ERROR: no partition of relation "t" found for row DETAIL: Partition key of the failing row contains (a) = (1). CONTEXT: processing remote data for replication origin "pg_NNNNN" during message type "DELETE" for replication target relation "public.t" in transaction NNN, finished at X/XXXXXXXX LOG: subscription "s" has been disabled because of an error SELECT subenabled FROM pg_subscription WHERE subname = 's'; -- f Without disable_on_error the worker exits and restarts with the same error in a loop, and no later change is applied. Expected: a delete_missing (or update_missing) conflict is logged and replication continues. For comparison, on the subscriber DELETE FROM t WHERE a = 1; UPDATE t SET b = 1 WHERE a = 1; complete with 0 rows, and with a non-partitioned subscriber table from which the row was removed locally the apply worker logs delete_missing / update_missing and continues. The same error occurs with DROP TABLE t_old instead of DETACH, and when the key falls into a DEFAULT partition that is itself partitioned and has no partition for the key, e.g. on the subscriber CREATE TABLE t (a int PRIMARY KEY, b int) PARTITION BY RANGE (a); CREATE TABLE t_lo PARTITION OF t FOR VALUES FROM (0) TO (100); CREATE TABLE t_def PARTITION OF t DEFAULT PARTITION BY RANGE (a); CREATE TABLE t_def_1 PARTITION OF t_def FOR VALUES FROM (100) TO (200); CREATE TABLE t_def_2 PARTITION OF t_def FOR VALUES FROM (200) TO (300); with rows 150 and 250 synced, then DROP TABLE t_def_2 on the subscriber and DELETE FROM t WHERE a = 250 on the publisher: ERROR: no partition of relation "t_def" found for row DETAIL: Partition key of the failing row contains (a) = (250). ## Analysis apply_handle_tuple_routing() (worker.c) locates the leaf partition for the remote "search" tuple of an UPDATE or DELETE with ExecFindPartition(), i.e. it uses INSERT tuple routing to find where an existing row would be. ExecFindPartition() (execPartition.c) raises ERRCODE_CHECK_VIOLATION "no partition of relation ... found for row" when get_partition_for_tuple() finds no partition at some level. For a new row that error is correct, but for the search tuple of an UPDATE or DELETE it only means that the row cannot exist in the target, which is exactly the update_missing / delete_missing case that apply_handle_update_internal() / apply_handle_delete_internal() report at LOG level and skip for a non-partitioned target or when the leaf is found but the row is not. Routing UPDATE/DELETE search tuples through ExecFindPartition() came with f1ac27bfda6 ("Add logical replication support to replicate into partitioned tables"). Related, different mechanism: 01a22b09-327c-7fa4-95ae-23374a16f329 (ExecFindPartition's default-partition recheck raising "violates partition constraint" for a search tuple under a concurrent ATTACH PARTITION). ## Notes - Tested on master ea39d58e4b8242ec5da211364b20ffd3d4000a51. - Reproduces with and without conflict_log_destination = 'table'; no conflict is recorded in either case. - A partition can disappear on the subscriber only through local DDL (DETACH / DROP of a partition, e.g. to archive old ranges); a publisher-side purge of the same old rows then stops replication. - Branches: master (reproduced at ea39d58e4b82); REL_14 through REL_19 likely by code inspection (the apply worker routes UPDATE/DELETE search tuples through ExecFindPartition() on all of them).