Re: pg_replication_origin_drop API potential race condition

Поиск
Список
Период
Сортировка
От Amit Kapila
Тема Re: pg_replication_origin_drop API potential race condition
Дата
Msg-id CAA4eK1JVcnGnfY8rF8pWXpvsuv960d0KFErdustoEViieFcUUw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: pg_replication_origin_drop API potential race condition  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Ответы Re: pg_replication_origin_drop API potential race condition
Список pgsql-hackers
On Mon, Feb 8, 2021 at 11:30 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
>
> > +void
> > +replorigin_drop_by_name(char *name, bool missing_ok, bool nowait)
> > +{
> > +     RepOriginId roident;
> > +     Relation        rel;
> > +
> > +     Assert(IsTransactionState());
> > +
> > +     /*
> > +      * To interlock against concurrent drops, we hold ExclusiveLock on
> > +      * pg_replication_origin throughout this function.
> > +      */
>
> This comment is now wrong though; should s/throughout.*/till xact commit/
> to reflect the new reality.
>

Right, I'll fix in the next version.

> I do wonder if this is going to be painful in some way, since the lock
> is now going to be much longer-lived.  My impression is that it's okay,
> since dropping an origin is not a very frequent occurrence.  It is going
> to block pg_replication_origin_advance() with *any* origin, which
> acquires RowExclusiveLock on the same relation.  If this is a problem,
> then we could use LockSharedObject() in both places (and make it last
> till end of xact for the case of deletion), instead of holding this
> catalog-level lock till end of transaction.
>

IIUC, you are suggesting to use lock for the particular origin instead
of locking the corresponding catalog table in functions
pg_replication_origin_advance and replorigin_drop_by_name. If so, I
don't see any problem with the same but please note that we do take
catalog-level lock in replorigin_create() which would have earlier
prevented create and drop to run concurrently. Having said that, I
don't see any problem with it because I think till the drop is
committed, the create will see the corresponding row as visible and we
won't generate the wrong origin_id. What do you think?

-- 
With Regards,
Amit Kapila.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Yugo NAGATA
Дата:
Сообщение: Re: Is Recovery actually paused?
Следующее
От: Greg Nancarrow
Дата:
Сообщение: Re: Parallel INSERT (INTO ... SELECT ...)