[HACKERS] libpqrcv_PQexec() seems to violate latch protocol

Поиск
Список
Период
Сортировка
От Andres Freund
Тема [HACKERS] libpqrcv_PQexec() seems to violate latch protocol
Дата
Msg-id 20170606210405.sim3yl6vpudhmufo@alap3.anarazel.de
обсуждение исходный текст
Ответы Re: [HACKERS] libpqrcv_PQexec() seems to violate latch protocol  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

The function  in $subject does:       while (PQisBusy(streamConn))       {           int         rc;
           /*            * We don't need to break down the sleep into smaller increments,            * since we'll get
interruptedby signals and can either handle            * interrupts here or elog(FATAL) within SIGTERM signal handler
if           * the signal arrives in the middle of establishment of            * replication connection.            */
        ResetLatch(&MyProc->procLatch);           rc = WaitLatchOrSocket(&MyProc->procLatch,
     WL_POSTMASTER_DEATH | WL_SOCKET_READABLE |                                  WL_LATCH_SET,
       PQsocket(streamConn),                                  0,
WAIT_EVENT_LIBPQWALRECEIVER);          if (rc & WL_POSTMASTER_DEATH)               exit(1);           /* interrupted */
         if (rc & WL_LATCH_SET)           {               CHECK_FOR_INTERRUPTS();               continue;           }
 

Doing ResetLatch();WaitLatch() like that makes it possible to miss a the
latch being set, e.g. if it happens just after WaitLatchOrSocket()
returns.

Afaict, the ResetLatch() really should just instead be in the if (rc & WL_LATCH_SET)
block.

Unless somebody protests, I'll make it so.

Greetings,

Andres Freund



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

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: [HACKERS] PG10 transition tables, wCTEs and multiple operationson the same table
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] libpqrcv_PQexec() seems to violate latch protocol