Re: Invalidate the subscription worker in cases where a user loses their superuser status - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: Invalidate the subscription worker in cases where a user loses their superuser status
Date
Msg-id CAA4eK1+Dw+0B9vb6rTcPmFWJHyksfu8LJwph1_01f8+C63+DnQ@mail.gmail.com
Whole thread Raw
In response to Invalidate the subscription worker in cases where a user loses their superuser status  (vignesh C <vignesh21@gmail.com>)
Responses Re: Invalidate the subscription worker in cases where a user loses their superuser status
List pgsql-hackers
On Sat, Sep 23, 2023 at 1:27 AM vignesh C <vignesh21@gmail.com> wrote:
>
>
> 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.
>

@@ -3952,7 +3953,9 @@ maybe_reread_subscription(void)
  newsub->passwordrequired != MySubscription->passwordrequired ||
  strcmp(newsub->origin, MySubscription->origin) != 0 ||
  newsub->owner != MySubscription->owner ||
- !equal(newsub->publications, MySubscription->publications))
+ !equal(newsub->publications, MySubscription->publications) ||
+ (!superuser_arg(MySubscription->owner) &&
+ MySubscription->isownersuperuser))
  {
  if (am_parallel_apply_worker())
  ereport(LOG,
@@ -4605,6 +4608,13 @@ InitializeLogRepWorker(void)
  proc_exit(0);
  }

+ /*
+ * Fetch subscription owner is a superuser. This value will be later
+ * checked to see when there is any change with this role and the worker
+ * will be restarted if required.
+ */
+ MySubscription->isownersuperuser = superuser_arg(MySubscription->owner);

Why didn't you filled this parameter in GetSubscription() like other
parameters? If we do that then the comparison of first change in your
patch will look similar to all other comparisons.

--
With Regards,
Amit Kapila.



pgsql-hackers by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: [PoC] pg_upgrade: allow to upgrade publisher node
Next
From: Ranier Vilela
Date:
Subject: Avoid a possible out-of-bounds access (src/backend/optimizer/util/relnode.c)