summaryrefslogtreecommitdiff
path: root/src/backend/replication
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/replication')
-rw-r--r--src/backend/replication/syncrep.c17
-rw-r--r--src/backend/replication/walreceiver.c4
-rw-r--r--src/backend/replication/walsender.c16
3 files changed, 25 insertions, 12 deletions
diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c
index 8713b9700dc..6463420cd85 100644
--- a/src/backend/replication/syncrep.c
+++ b/src/backend/replication/syncrep.c
@@ -111,9 +111,6 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN)
Assert(SHMQueueIsDetached(&(MyProc->syncRepLinks)));
Assert(WalSndCtl != NULL);
- /* Reset the latch before adding ourselves to the queue. */
- ResetLatch(&MyProc->waitLatch);
-
LWLockAcquire(SyncRepLock, LW_EXCLUSIVE);
Assert(MyProc->syncRepState == SYNC_REP_NOT_WAITING);
@@ -167,7 +164,7 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN)
int syncRepState;
/* Must reset the latch before testing state. */
- ResetLatch(&MyProc->waitLatch);
+ ResetLatch(&MyProc->procLatch);
/*
* Try checking the state without the lock first. There's no
@@ -247,11 +244,11 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN)
}
/*
- * Wait on latch for up to 60 seconds. This allows us to check for
+ * Wait on latch for up to 10 seconds. This allows us to check for
* cancel/die signal or postmaster death regularly while waiting. Note
* that timeout here does not necessarily release from loop.
*/
- WaitLatch(&MyProc->waitLatch, 60000L);
+ WaitLatch(&MyProc->procLatch, 10000L);
}
/*
@@ -322,7 +319,7 @@ SyncRepCancelWait(void)
}
void
-SyncRepCleanupAtProcExit(int code, Datum arg)
+SyncRepCleanupAtProcExit(void)
{
if (!SHMQueueIsDetached(&(MyProc->syncRepLinks)))
{
@@ -330,8 +327,6 @@ SyncRepCleanupAtProcExit(int code, Datum arg)
SHMQueueDelete(&(MyProc->syncRepLinks));
LWLockRelease(SyncRepLock);
}
-
- DisownLatch(&MyProc->waitLatch);
}
/*
@@ -560,9 +555,7 @@ SyncRepWakeQueue(bool all)
/*
* Wake only when we have set state and removed from queue.
*/
- Assert(SHMQueueIsDetached(&(thisproc->syncRepLinks)));
- Assert(thisproc->syncRepState == SYNC_REP_WAIT_COMPLETE);
- SetLatch(&(thisproc->waitLatch));
+ SetLatch(&(thisproc->procLatch));
numprocs++;
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 471c844ab2a..18b4727fa81 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -373,11 +373,15 @@ WalRcvSigHupHandler(SIGNAL_ARGS)
static void
WalRcvShutdownHandler(SIGNAL_ARGS)
{
+ int save_errno = errno;
+
got_SIGTERM = true;
/* Don't joggle the elbow of proc_exit */
if (!proc_exit_inprogress && WalRcvImmediateInterruptOK)
ProcessWalRcvInterrupts();
+
+ errno = save_errno;
}
/*
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index aaa048525b4..bc7b3146b7b 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -1188,18 +1188,26 @@ XLogSend(char *msgbuf, bool *caughtup)
static void
WalSndSigHupHandler(SIGNAL_ARGS)
{
+ int save_errno = errno;
+
got_SIGHUP = true;
if (MyWalSnd)
SetLatch(&MyWalSnd->latch);
+
+ errno = save_errno;
}
/* SIGTERM: set flag to shut down */
static void
WalSndShutdownHandler(SIGNAL_ARGS)
{
+ int save_errno = errno;
+
walsender_shutdown_requested = true;
if (MyWalSnd)
SetLatch(&MyWalSnd->latch);
+
+ errno = save_errno;
}
/*
@@ -1238,16 +1246,24 @@ WalSndQuickDieHandler(SIGNAL_ARGS)
static void
WalSndXLogSendHandler(SIGNAL_ARGS)
{
+ int save_errno = errno;
+
latch_sigusr1_handler();
+
+ errno = save_errno;
}
/* SIGUSR2: set flag to do a last cycle and shut down afterwards */
static void
WalSndLastCycleHandler(SIGNAL_ARGS)
{
+ int save_errno = errno;
+
walsender_ready_to_stop = true;
if (MyWalSnd)
SetLatch(&MyWalSnd->latch);
+
+ errno = save_errno;
}
/* Set up signal handlers */