Fix multiple crasher bugs in partitioned-table replication logic.
Tom Lane <tgl@sss.pgh.pa.us>
Fix multiple crasher bugs in partitioned-table replication logic. apply_handle_tuple_routing(), having detected and reported that the tuple it needed to update didn't exist, tried to update that tuple anyway, leading to a null-pointer dereference. logicalrep_partition_open() failed to ensure that the LogicalRepPartMapEntry it built for a partition was fully independent of that for the partition root, leading to trouble if the root entry was later freed or rebuilt. Meanwhile, on the publisher's side, pgoutput_change() sometimes attempted to apply execute_attr_map_tuple() to a NULL tuple. The first of these was reported by Sergey Bernikov in bug #17055; I found the other two while developing some test cases for this sadly under-tested code. Diagnosis and patch for the first issue by Amit Langote; patches for the others by me; new test cases by me. Back-patch to v13 where this logic came in. Discussion: https://postgr.es/m/17055-9ba800ec8522668b@postgresql.org
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/replication/logical/relation.c | modified | +10 −3 |
| src/backend/replication/logical/worker.c | modified | +27 −21 |
| src/backend/replication/pgoutput/pgoutput.c | modified | +5 −2 |
| src/test/subscription/t/001_rep_changes.pl | modified | +34 −2 |
| src/test/subscription/t/013_partition.pl | modified | +70 −1 |
Discussion
- BUG #17055: Logical replication worker crashes when applying update of row that dose not exist in target partiti 17 messages · 2021-06-10 → 2021-06-12