From f7c629d17a01316a2fba613840689c5694badf31 Mon Sep 17 00:00:00 2001 From: Vignesh C Date: Fri, 24 Jul 2026 11:47:47 +0530 Subject: [PATCH v1] Avoid reporting permission-denied publisher sequences as missing When a sequence synchronization batch contained both a sequence that was dropped on the publisher and one for which the replication role lacked SELECT privilege, the latter was reported twice: once as having insufficient privileges on the publisher sequence and again as missing on the publisher. This happened because get_and_validate_seq_info() returned COPYSEQ_PUBLISHER_INSUFFICIENT_PERM before marking the sequence as found on the publisher. As a result, if another sequence in the batch was genuinely missing, the post-commit scan also classified the permission-denied sequence as missing. Fix this by marking the sequence as found on the publisher before returning COPYSEQ_PUBLISHER_INSUFFICIENT_PERM. Receiving a row from the publisher proves that the sequence exists there, so it should not also be reported as missing. --- .../replication/logical/sequencesync.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/backend/replication/logical/sequencesync.c b/src/backend/replication/logical/sequencesync.c index 28d4d011a84..12e339d7964 100644 --- a/src/backend/replication/logical/sequencesync.c +++ b/src/backend/replication/logical/sequencesync.c @@ -308,8 +308,23 @@ get_and_validate_seq_info(TupleTableSlot *slot, Relation *sequence_rel, */ datum = slot_getattr(slot, ++col, &isnull); if (isnull) - return remote_has_select_priv ? COPYSEQ_SKIPPED : - COPYSEQ_PUBLISHER_INSUFFICIENT_PERM; + { + /* + * The sequence was dropped concurrently after it was identified in + * the catalog snapshot. Treat it as skipped (and, since it no + * longer exists on the publisher, ultimately missing). + */ + if (remote_has_select_priv) + return COPYSEQ_SKIPPED; + + /* + * The publisher lacks the SELECT privilege required by + * pg_get_sequence_data(). Since we received a row for this sequence, + * mark it as found so it is not also reported as missing. + */ + seqinfo_local->found_on_pub = true; + return COPYSEQ_PUBLISHER_INSUFFICIENT_PERM; + } seqinfo_local->last_value = DatumGetInt64(datum); -- 2.50.1 (Apple Git-155)