Re: Invalidate the subscription worker in cases where a user loses their superuser status

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Invalidate the subscription worker in cases where a user loses their superuser status
Date: 2023-09-29 05:52:14
Message-ID: CALDaNm1gNXQxrjx2eYsfq4qF2n5f-B894hvBErP4kce3pK57VA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 29 Sept 2023 at 04:55, Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> Some minor review comments for v4-0001:
>
> ======
> src/backend/replication/logical/worker.c
>
> 1.
> + /*
> + * Exit if the owner of the subscription has changed from superuser to a
> + * non-superuser.
> + */
> + if (!newsub->isownersuperuser && MySubscription->isownersuperuser)
> + {
> + if (am_parallel_apply_worker())
> + ereport(LOG,
> + errmsg("logical replication parallel apply worker for subscription
> \"%s\" will stop because subscription owner has become non-superuser",
> + MySubscription->name));
> + else
> + ereport(LOG,
> + errmsg("logical replication worker for subscription \"%s\" will
> restart because subscription owner has become non-superuser",
> + MySubscription->name));
> +
> + apply_worker_exit();
> + }
> +
>
> /because subscription owner has become non-superuser/because the
> subscription owner has become a non-superuser/ (in 2 places)

Modified

> ======
> src/include/catalog/pg_subscription.h
>
> 2.
> char *origin; /* Only publish data originating from the
> * specified origin */
> + bool isownersuperuser; /* Is subscription owner superuser? */
> } Subscription;
>
> ~
>
> 2a.
> Would it be better to put this new field adjacent to the existing
> 'owner' field, since they kind of belong together?

Modified

> ~
>
> 2b.
> None of the other bool fields here has an 'is' prefix, so you could
> consider a shorter field name, like 'ownersuperuser' or
> 'superuserowner', etc.

Modified

The attached v5 version patch has the changes for the same.

Regards,
Vignesh

Attachment Content-Type Size
v5-0001-Restart-the-apply-worker-if-the-subscription-owne.patch text/x-patch 7.5 KB
v5-0001-Restart-the-apply-worker-if-the-subscription-owne_PG16.patch text/x-patch 7.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-09-29 06:19:47 Re: Add a new BGWORKER_BYPASS_ROLELOGINCHECK flag
Previous Message Amit Langote 2023-09-29 04:57:46 Re: remaining sql/json patches