]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Avoid reporting permission-denied publisher sequences as missing
authorFujii Masao <fujii@postgresql.org>
Sat, 25 Jul 2026 01:30:30 +0000 (10:30 +0900)
committerFujii Masao <fujii@postgresql.org>
Sat, 25 Jul 2026 01:30:30 +0000 (10:30 +0900)
Previously, if a sequence synchronization batch contained both a sequence
that had been dropped on the publisher and another for which the
replication role lacked SELECT privilege, the latter was reported
twice: once as a permission failure and again as missing on the
publisher.

This happened because the permission-denied sequence was not marked as
found on the publisher. As a result, when another sequence in the batch
was genuinely missing, the later missing-sequence check incorrectly
classified the permission-denied sequence as missing as well.

Fix this by marking the permission-denied sequence as found before
reporting the permission failure, so it is not later reported as
missing.

Reported-by: Noah Misch <noah@leadboat.com>
Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CALDaNm3LsUjW7PahuCsbYAxajSF+S328tw5E9rF0erdh7dKOXw@mail.gmail.com
Backpatch-through: 19

src/backend/replication/logical/sequencesync.c

index 28d4d011a84e04b8901871ad0f90b11952867870..d0370056de311b9d89ec8f36662b5746f7f9bfda 100644 (file)
@@ -308,8 +308,24 @@ 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 has_sequence_privilege() returned
+                * false, not NULL, do not classify this sequence as missing on the
+                * publisher.
+                */
+               seqinfo_local->found_on_pub = true;
+               return COPYSEQ_PUBLISHER_INSUFFICIENT_PERM;
+       }
 
        seqinfo_local->last_value = DatumGetInt64(datum);