diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 6414291ef7abbef6b8fcfbea705fad9cd5d16a00..f4526a6c4d9902ccaa1f15f8d836328f93ea2f64 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -1650,11 +1650,15 @@ HandleNotifyInterrupt(void)
 
 		/*
 		 * We may be called while ImmediateInterruptOK is true; turn it off
-		 * while messing with the NOTIFY state.  (We would have to save and
-		 * restore it anyway, because PGSemaphore operations inside
-		 * ProcessIncomingNotify() might reset it.)
+		 * while messing with the NOTIFY state.  This prevents problems if
+		 * SIGINT or similar arrives while we're working.  Just to be real
+		 * sure, bump the interrupt holdoff counter as well.  That way, even
+		 * if something inside ProcessIncomingNotify() transiently sets
+		 * ImmediateInterruptOK (eg while waiting on a lock), we won't get
+		 * interrupted until we're done with the notify interrupt.
 		 */
 		ImmediateInterruptOK = false;
+		HOLD_INTERRUPTS();
 
 		/*
 		 * I'm not sure whether some flavors of Unix might allow another
@@ -1684,8 +1688,10 @@ HandleNotifyInterrupt(void)
 		}
 
 		/*
-		 * Restore ImmediateInterruptOK, and check for interrupts if needed.
+		 * Restore the holdoff level and ImmediateInterruptOK, and check for
+		 * interrupts if needed.
 		 */
+		RESUME_INTERRUPTS();
 		ImmediateInterruptOK = save_ImmediateInterruptOK;
 		if (save_ImmediateInterruptOK)
 			CHECK_FOR_INTERRUPTS();
diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c
index 5e48d0117883cd4cd992b748608639dab4e6e883..98eb814dc3d3eee21c40f56dabb7abd76c526559 100644
--- a/src/backend/storage/ipc/sinval.c
+++ b/src/backend/storage/ipc/sinval.c
@@ -180,11 +180,15 @@ HandleCatchupInterrupt(void)
 
 		/*
 		 * We may be called while ImmediateInterruptOK is true; turn it off
-		 * while messing with the catchup state.  (We would have to save and
-		 * restore it anyway, because PGSemaphore operations inside
-		 * ProcessCatchupEvent() might reset it.)
+		 * while messing with the catchup state.  This prevents problems if
+		 * SIGINT or similar arrives while we're working.  Just to be real
+		 * sure, bump the interrupt holdoff counter as well.  That way, even
+		 * if something inside ProcessCatchupEvent() transiently sets
+		 * ImmediateInterruptOK (eg while waiting on a lock), we won't get
+		 * interrupted until we're done with the catchup interrupt.
 		 */
 		ImmediateInterruptOK = false;
+		HOLD_INTERRUPTS();
 
 		/*
 		 * I'm not sure whether some flavors of Unix might allow another
@@ -208,8 +212,10 @@ HandleCatchupInterrupt(void)
 		}
 
 		/*
-		 * Restore ImmediateInterruptOK, and check for interrupts if needed.
+		 * Restore the holdoff level and ImmediateInterruptOK, and check for
+		 * interrupts if needed.
 		 */
+		RESUME_INTERRUPTS();
 		ImmediateInterruptOK = save_ImmediateInterruptOK;
 		if (save_ImmediateInterruptOK)
 			CHECK_FOR_INTERRUPTS();