From: | vignesh C <vignesh21(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Invalidate the subscription worker in cases where a user loses their superuser status |
Date: | 2023-09-22 18:52:00 |
Message-ID: | CALDaNm2Dxmhq08nr4P6G+24QvdBo_GAVyZ_Q1TcGYK+8NHs9xw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
The subscription worker was not getting invalidated when the
subscription owner changed from superuser to non-superuser. Here is a
test case for the same:
Publisher:
CREATE USER repl REPLICATION PASSWORD 'secret';
CREATE TABLE t(i INT);
INSERT INTO t VALUES(1);
GRANT SELECT ON t TO repl;
CREATE PUBLICATION p1 FOR TABLE t;
Subscriber (has a PGPASSFILE for user "repl"):
CREATE USER u1 SUPERUSER;
CREATE TABLE t(i INT);
ALTER TABLE t OWNER TO u1;
-- no password specified
CREATE SUBSCRIPTION s1
CONNECTION 'dbname=postgres host=127.0.0.1 port=5432 user=repl'
PUBLICATION p1;
ALTER USER u1 NOSUPERUSER: -- Change u1 user to non-superuser
Publisher:
INSERT INTO t VALUES(1);
Subscriber:
SELECT COUNT(*) FROM t; -- should have been 1 but is 2, the apply
worker has not exited after changing from superuser to non-superuser.
Fixed this issue by checking if the subscription owner has changed
from superuser to non-superuser in case the pg_authid rows changes.
The attached patch has the changes for the same.
Thanks to Jeff Davis for identifying this issue and reporting it at [1].
[1] - https://www.postgresql.org/message-id/5dff4caf26f45ce224a33a5e18e110b93a351b2f.camel%40j-davis.com
Regards,
Vignesh
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Restart-the-apply-worker-if-the-subscription-owne.patch | text/x-patch | 5.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2023-09-22 19:58:55 | Re: Questions about the new subscription parameter: password_required |
Previous Message | Matthias van de Meent | 2023-09-22 15:50:08 | Re: GenBKI emits useless open;close for catalogs without rows |