static void ProcessClientWaitTimeout(void) { bool notify_enabled; bool catchup_enabled; /* Must prevent SIGUSR2 interrupt while I am running */ notify_enabled = DisableNotifyInterrupt(); catchup_enabled = DisableCatchupInterrupt(); clientWaitTimeoutInterruptOccurred = 0; HandleClientWaitTimeout(); if (notify_enabled) EnableNotifyInterrupt(); if (catchup_enabled) EnableCatchupInterrupt(); }
/* * ProcessCatchupEvent * * Respond to a catchup event (SIGUSR1) from another backend. * * This is called either directly from the SIGUSR1 signal handler, * or the next time control reaches the outer idle loop (assuming * there's still anything to do by then). */ static void ProcessCatchupEvent(void) { bool notify_enabled; /* Must prevent SIGUSR2 interrupt while I am running */ notify_enabled = DisableNotifyInterrupt(); /* * What we need to do here is cause ReceiveSharedInvalidMessages() to run, * which will do the necessary work and also reset the * catchupInterruptOccurred flag. If we are inside a transaction we can * just call AcceptInvalidationMessages() to do this. If we aren't, we * start and immediately end a transaction; the call to * AcceptInvalidationMessages() happens down inside transaction start. * * It is awfully tempting to just call AcceptInvalidationMessages() * without the rest of the xact start/stop overhead, and I think that * would actually work in the normal case; but I am not sure that things * would clean up nicely if we got an error partway through. */ if (IsTransactionOrTransactionBlock()) { elog(DEBUG4, "ProcessCatchupEvent inside transaction"); AcceptInvalidationMessages(); } else { elog(DEBUG4, "ProcessCatchupEvent outside transaction"); StartTransactionCommand(); CommitTransactionCommand(); } if (notify_enabled) EnableNotifyInterrupt(); }
/* * ProcessCatchupEvent * * Respond to a catchup event (PROCSIG_CATCHUP_INTERRUPT) from another * backend. * * This is called either directly from the PROCSIG_CATCHUP_INTERRUPT * signal handler, or the next time control reaches the outer idle loop * (assuming there's still anything to do by then). */ static void ProcessCatchupEvent(void) { bool notify_enabled; bool client_wait_timeout_enabled; DtxContext saveDistributedTransactionContext; /* * Funny indentation to keep the code inside identical to upstream * while at the same time supporting CMockery which has problems with * multiple bracing on column 1. */ PG_TRY(); { in_process_catchup_event = 1; /* Must prevent SIGUSR2 and SIGALRM(for IdleSessionGangTimeout) interrupt while I am running */ notify_enabled = DisableNotifyInterrupt(); client_wait_timeout_enabled = DisableClientWaitTimeoutInterrupt(); /* * What we need to do here is cause ReceiveSharedInvalidMessages() to run, * which will do the necessary work and also reset the * catchupInterruptOccurred flag. If we are inside a transaction we can * just call AcceptInvalidationMessages() to do this. If we aren't, we * start and immediately end a transaction; the call to * AcceptInvalidationMessages() happens down inside transaction start. * * It is awfully tempting to just call AcceptInvalidationMessages() * without the rest of the xact start/stop overhead, and I think that * would actually work in the normal case; but I am not sure that things * would clean up nicely if we got an error partway through. */ if (IsTransactionOrTransactionBlock()) { elog(DEBUG1, "ProcessCatchupEvent inside transaction"); AcceptInvalidationMessages(); } else { elog(DEBUG1, "ProcessCatchupEvent outside transaction"); /* * Save distributed transaction context first. */ saveDistributedTransactionContext = DistributedTransactionContext; DistributedTransactionContext = DTX_CONTEXT_LOCAL_ONLY; StartTransactionCommand(); CommitTransactionCommand(); DistributedTransactionContext = saveDistributedTransactionContext; } if (notify_enabled) EnableNotifyInterrupt(); if (client_wait_timeout_enabled) EnableClientWaitTimeoutInterrupt(); in_process_catchup_event = 0; } PG_CATCH(); { in_process_catchup_event = 0; PG_RE_THROW(); } PG_END_TRY(); }