| From: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com> |
| Subject: | [PG19] Sequence sync stops when the subscription owner can't SET ROLE to a sequence owner |
| Date: | 2026-10-16 17:18:38 |
| Message-ID: | CAN4CZFMGiyksxVD1M7cc7_5E+evfi51xmDxw4uqdmvoeH53Ugw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello
With run_as_owner = false, copy_sequence switches to the sequence
owner with SwitchToUntrustedUser before the UPDATE privilege check. If
the subscription owner can't SET ROLE to that owner, it raises an
ERROR and the whole batch is aborted.
Setup on the subscriber, with 4 sequences in a FOR ALL SEQUENCES publication:
CREATE ROLE subown LOGIN; CREATE ROLE other;
GRANT pg_create_subscription TO subown;
GRANT CREATE ON DATABASE postgres TO subown;
-- a1, a3, a4 owned by subown, a2 owned by other
CREATE SUBSCRIPTION ss ... WITH (password_required = false,
enabled = false);
ALTER SUBSCRIPTION ss OWNER TO subown;
ALTER SUBSCRIPTION ss ENABLE;
All 4 sequences stay in INIT, and the log only says:
ERROR: role "subown" cannot SET ROLE to "other"
which doesn't say which sequence is the problem.
a1 actually gets its value, it just never becomes READY.
Compare with the same setup and run_as_owner = true, where subown
simply lacks UPDATE on a2:
WARNING: insufficient privileges on subscriber sequence ("public.a2")
HINT: Grant UPDATE on the sequence to the subscription owner on
the subscriber.
ERROR: logical replication sequence synchronization failed for
subscription "ss"
and a1, a3, a4 are READY.
The comment in report_sequence_errors also seems to assume that with
run_as_owner = false the switch always succeeds, and only the owner's
UPDATE privilege can be missing.
The attached patch checks member_can_set_role before switching and
returns INSUFFICIENT_PERM if it fails. With it, the example above
gives the WARNING for a2, and a1, a3, a4 are READY.
The patch also extends 036_sequences.pl, the new check fails without the fix.
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-sequence-synchronization-when-the-sequence-ow.patch | application/octet-stream | 5.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bernd Reiß | 2026-10-16 17:21:54 | Re: Use instr_time for pg_stat_database block read/write time counters |
| Previous Message | Zsolt Parragi | 2026-10-16 17:05:23 | Re: pg_*_advice: tsv load failure, etc. |