pgsql: Use latch instead of select() in walreceiver
Use latch instead of select() in walreceiver
Replace use of poll()/select() by WaitLatchOrSocket(), which is more
portable and flexible.
Also change walreceiver to use its procLatch instead of a custom latch.
From: Petr Jelinek <petr@2ndquadrant.com>
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/597a87ccc9a6fa8af7f3cf280b1e24e41807d555
Modified Files
--------------
src/backend/postmaster/pgstat.c | 3 +
.../libpqwalreceiver/libpqwalreceiver.c | 101 +++++----------------
src/backend/replication/walreceiver.c | 18 ++--
src/backend/replication/walreceiverfuncs.c | 6 +-
src/include/pgstat.h | 1 +
src/include/replication/walreceiver.h | 3 +-
6 files changed, 43 insertions(+), 89 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
On Fri, Dec 2, 2016 at 10:29 AM, Peter Eisentraut <peter_e@gmx.net> wrote:
Use latch instead of select() in walreceiver
Replace use of poll()/select() by WaitLatchOrSocket(), which is more
portable and flexible.Also change walreceiver to use its procLatch instead of a custom latch.
From: Petr Jelinek <petr@2ndquadrant.com>
+ ResetLatch(&MyProc->procLatch);
+ rc = WaitLatchOrSocket(&MyProc->procLatch,
+ WL_POSTMASTER_DEATH | WL_SOCKET_READABLE |
+ WL_LATCH_SET,
+ PQsocket(streamConn),
+ 0,
+ WAIT_EVENT_LIBPQWALRECEIVER_READ);
+ if (rc & WL_POSTMASTER_DEATH)
+ exit(1);
Hmm. We have always been very careful about not leaving immediately
from libpqwalreceiver.c which is an independent shared library so as
the WAL receiver can take cleanup actions. See here for more details:
https://www.postgresql.org/message-id/CAEepm=0hg_FX7kdUhosTpJ_kPsUZw6k-7nuQNy-dGAOaetn_tA@mail.gmail.com
--
Michael
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
On 12/1/16 8:50 PM, Michael Paquier wrote:
+ if (rc & WL_POSTMASTER_DEATH) + exit(1); Hmm. We have always been very careful about not leaving immediately from libpqwalreceiver.c which is an independent shared library so as the WAL receiver can take cleanup actions. See here for more details: https://www.postgresql.org/message-id/CAEepm=0hg_FX7kdUhosTpJ_kPsUZw6k-7nuQNy-dGAOaetn_tA@mail.gmail.com
walreceiver.c does the same thing. The message you pointed out is not
exactly clear why that would be wrong.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers