From 8585ca764dc305164dbe6368d7ed505539f01a49 Mon Sep 17 00:00:00 2001 From: Craig Ringer Date: Fri, 18 Nov 2016 10:24:55 +0800 Subject: [PATCH 17/21] Allow walsender to exit on conflict with recovery Now that logical decoding on standby is supported, the walsender needs to be able to exit in response to conflict with recovery so that it can terminate to allow replay of a DROP DATABASE to proceed. Does not deal with recovery conflicts due to vacuum activity. WIP: * The comments on RecoveryConflictInterrupt() still say it's only called by normal user backends. * There's no safeguard to stop walsender from invoking other recovery conflict clauses that may be unsafe for it to call. * We'll try to clobber walsender sessions that conflict with recovery based on vacuum activity to non-catalog, non-user-catalog relations where it's safe to continue decoding. We need to treat decoding backends differently and only clobber them when we have to invalidate based on satisfying catalog requirements. * A logical decoding session in the walsender often won't have a vtxid or will change xids too fast for ResolveRecoveryConflictWithVirtualXIDs to do its job. We need to detect when catalog_xmin can't be satisfied when starting to process a new xact in walsender decoding. --- src/backend/replication/walsender.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 327dbb2..65b38a2 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -187,7 +187,6 @@ static XLogRecPtr logical_startptr = InvalidXLogRecPtr; /* Signal handlers */ static void WalSndSigHupHandler(SIGNAL_ARGS); -static void WalSndXLogSendHandler(SIGNAL_ARGS); static void WalSndLastCycleHandler(SIGNAL_ARGS); /* Prototypes for private functions */ @@ -2666,17 +2665,6 @@ WalSndSigHupHandler(SIGNAL_ARGS) errno = save_errno; } -/* SIGUSR1: set flag to send WAL records */ -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) @@ -2710,7 +2698,7 @@ WalSndSignals(void) pqsignal(SIGQUIT, quickdie); /* hard crash time */ InitializeTimeouts(); /* establishes SIGALRM handler */ pqsignal(SIGPIPE, SIG_IGN); - pqsignal(SIGUSR1, WalSndXLogSendHandler); /* request WAL sending */ + pqsignal(SIGUSR1, procsignal_sigusr1_handler); pqsignal(SIGUSR2, WalSndLastCycleHandler); /* request a last cycle and * shutdown */ -- 2.5.5