From 2746e5f21d4dce07ee55c58b2035ff631470577f Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Sat, 11 Sep 2010 15:48:04 +0000 Subject: Introduce latches. A latch is a boolean variable, with the capability to wait until it is set. Latches can be used to reliably wait until a signal arrives, which is hard otherwise because signals don't interrupt select() on some platforms, and even when they do, there's race conditions. On Unix, latches use the so called self-pipe trick under the covers to implement the sleep until the latch is set, without race conditions. On Windows, Windows events are used. Use the new latch abstraction to sleep in walsender, so that as soon as a transaction finishes, walsender is woken up to immediately send the WAL to the standby. This reduces the latency between master and standby, which is good. Preliminary work by Fujii Masao. The latch implementation is by me, with helpful comments from many people. --- src/backend/storage/ipc/ipci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/backend/storage/ipc/ipci.c') diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c index b4923d278a..881dae830c 100644 --- a/src/backend/storage/ipc/ipci.c +++ b/src/backend/storage/ipc/ipci.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.104 2010/02/16 22:34:50 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.105 2010/09/11 15:48:04 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -30,6 +30,7 @@ #include "replication/walsender.h" #include "storage/bufmgr.h" #include "storage/ipc.h" +#include "storage/latch.h" #include "storage/pg_shmem.h" #include "storage/pmsignal.h" #include "storage/procarray.h" @@ -117,6 +118,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int port) size = add_size(size, SInvalShmemSize()); size = add_size(size, PMSignalShmemSize()); size = add_size(size, ProcSignalShmemSize()); + size = add_size(size, LatchShmemSize()); size = add_size(size, BgWriterShmemSize()); size = add_size(size, AutoVacuumShmemSize()); size = add_size(size, WalSndShmemSize()); @@ -217,6 +219,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int port) */ PMSignalShmemInit(); ProcSignalShmemInit(); + LatchShmemInit(); BgWriterShmemInit(); AutoVacuumShmemInit(); WalSndShmemInit(); -- cgit v1.2.1