pgsql: Fix sequence synchronization failure on a concurrent refresh. - Mailing list pgsql-committers

From Amit Kapila
Subject pgsql: Fix sequence synchronization failure on a concurrent refresh.
Date
Msg-id E1x9GAL-00000000sAM-1uel@gemulon.postgresql.org
Whole thread
List pgsql-committers
Fix sequence synchronization failure on a concurrent refresh.

A sequencesync worker builds its list of sequences and then processes them
in batches. If ALTER SUBSCRIPTION ... REFRESH PUBLICATION removes one of
those sequences in the meantime, the worker updated the local sequence and
then failed while marking it READY, because its catalog row was gone. That
rolled back the batch, and with disable_on_error the entire subscription
was disabled.

The worker now checks that the sequence is still part of the subscription
before updating it, and skips it if not. The check is done under the lock
on the subscription that the refresh also takes, so the row cannot go away
in between.

Reported-by: Nikolay Samokhvalov <nik@postgres.ai>
Author: vignesh C <vignesh21@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CAM527d9mL-bOofX-G7Sp441vA3Y_fa_7JBh03m-ZPduikn_XUg@mail.gmail.com
Backpatch-through: 19, where it was introduced

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/883da6d2c28aadbe07044386511e0d900c020cd8

Modified Files
--------------
src/backend/commands/subscriptioncmds.c        |  6 ++++
src/backend/replication/logical/sequencesync.c | 50 ++++++++++++++++++++++++--
2 files changed, 53 insertions(+), 3 deletions(-)


pgsql-committers by date:

Previous
From: Melanie Plageman
Date:
Subject: pgsql: Avoid replay cleanup locks for freeze-only and VM-only records
Next
From: Peter Eisentraut
Date:
Subject: pgsql: pgindent: Fix indentation of alignas() in struct members