Dear Amit,
Thanks for giving comments. I hope all comments have been addressed.
PSA new version.
> > Actually, earlier version (-v3) did not have a mechanism but they sometimes got
> > assertion failures in maybe_reread_subscription(). This was because the
> survived
> > workers read pg_subscription catalog and failed below assertion:
> >
> > ```
> > /* two-phase cannot be altered while the worker exists */
> > Assert(newsub->twophasestate ==
> MySubscription->twophasestate);
> > ```
> >
>
> But that is not a good reason for this operation to stop workers
> first. Instead, we should prohibit this operation if any worker is
> present. The reason is that there is always a chance that if any
> worker is alive, it can prepare a new transaction after we have
> checked for the presence of any prepared transactions.
I used the function because it internally waits until all workers are exited.
But OK, I modified like you suggested (logicalrep_workers_find() is used).
Best Regards,
Hayato Kuroda
FUJITSU LIMITED
https://www.fujitsu.com/