Re: [HACKERS] libpqrcv_PQexec() seems to violate latch protocol

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: [HACKERS] libpqrcv_PQexec() seems to violate latch protocol
Дата
Msg-id 20170606211700.wesskykuw7k5r7cm@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: [HACKERS] libpqrcv_PQexec() seems to violate latch protocol  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [HACKERS] libpqrcv_PQexec() seems to violate latch protocol  (Petr Jelinek <petr.jelinek@2ndquadrant.com>)
Список pgsql-hackers
On 2017-06-06 17:14:59 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > The function  in $subject does:
> 
> >             ResetLatch(&MyProc->procLatch);
> >             rc = WaitLatchOrSocket(&MyProc->procLatch,
> >                                    WL_POSTMASTER_DEATH | WL_SOCKET_READABLE |
> >                                    WL_LATCH_SET,
> >                                    PQsocket(streamConn),
> >                                    0,
> >                                    WAIT_EVENT_LIBPQWALRECEIVER);
> 
> Yeah, this is certainly broken.
> 
> > Afaict, the ResetLatch() really should just instead be in the if (rc & WL_LATCH_SET) block.
> 
> And, to be specific, it should be before the CHECK_FOR_INTERRUPTS call,
> since that is the useful work that we want to be sure occurs after
> any latch-setting event.

Right.  I found a couple more instance of similarly iffy, although not
quite as broken, patterns in launcher.c.  It's easy to get this wrong,
but it's a lot easy if you do it differently everywhere you use a
latch.  It's not good if code in the same file, by the same author(s),
has different ways of using latches.

- Andres



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] libpqrcv_PQexec() seems to violate latch protocol
Следующее
От: Petr Jelinek
Дата:
Сообщение: Re: [HACKERS] logical replication - still unstable after all thesemonths