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 <[email protected]> Author: vignesh C <[email protected]> Reviewed-by: shveta malik <[email protected]> Reviewed-by: Zhijie Hou <[email protected]> Reviewed-by: Andrey Borodin <[email protected]> Discussion: https://postgr.es/m/cam527d9ml-boofx-g7sp441va3y_fa_7jbh03m-zpduikn_...@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(-)
