Skip to content

Commit 2505ce0

Browse files
committed
Remove remnants of ImmediateInterruptOK handling.
Now that nothing sets ImmediateInterruptOK to true anymore, we can remove all the supporting code. Reviewed-By: Heikki Linnakangas
1 parent d069957 commit 2505ce0

File tree

7 files changed

+7
-99
lines changed

7 files changed

+7
-99
lines changed

src/backend/storage/ipc/ipc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ proc_exit_prepare(int code)
165165
InterruptPending = false;
166166
ProcDiePending = false;
167167
QueryCancelPending = false;
168-
/* And let's just make *sure* we're not interrupted ... */
169-
ImmediateInterruptOK = false;
170168
InterruptHoldoffCount = 1;
171169
CritSectionCount = 0;
172170

src/backend/tcop/postgres.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,13 +2648,6 @@ die(SIGNAL_ARGS)
26482648
{
26492649
InterruptPending = true;
26502650
ProcDiePending = true;
2651-
2652-
/*
2653-
* If we're waiting for input or a lock so that it's safe to
2654-
* interrupt, service the interrupt immediately
2655-
*/
2656-
if (ImmediateInterruptOK)
2657-
ProcessInterrupts();
26582651
}
26592652

26602653
/* If we're still here, waken anything waiting on the process latch */
@@ -2688,13 +2681,6 @@ StatementCancelHandler(SIGNAL_ARGS)
26882681
{
26892682
InterruptPending = true;
26902683
QueryCancelPending = true;
2691-
2692-
/*
2693-
* If we're waiting for input or a lock so that it's safe to
2694-
* interrupt, service the interrupt immediately
2695-
*/
2696-
if (ImmediateInterruptOK)
2697-
ProcessInterrupts();
26982684
}
26992685

27002686
/* If we're still here, waken anything waiting on the process latch */
@@ -2835,13 +2821,6 @@ RecoveryConflictInterrupt(ProcSignalReason reason)
28352821
*/
28362822
if (reason == PROCSIG_RECOVERY_CONFLICT_DATABASE)
28372823
RecoveryConflictRetryable = false;
2838-
2839-
/*
2840-
* If we're waiting for input or a lock so that it's safe to
2841-
* interrupt, service the interrupt immediately.
2842-
*/
2843-
if (ImmediateInterruptOK)
2844-
ProcessInterrupts();
28452824
}
28462825

28472826
/*
@@ -2875,7 +2854,6 @@ ProcessInterrupts(void)
28752854
{
28762855
ProcDiePending = false;
28772856
QueryCancelPending = false; /* ProcDie trumps QueryCancel */
2878-
ImmediateInterruptOK = false; /* not idle anymore */
28792857
LockErrorCleanup();
28802858
/* As in quickdie, don't risk sending to client during auth */
28812859
if (ClientAuthInProgress && whereToSendOutput == DestRemote)
@@ -2914,7 +2892,6 @@ ProcessInterrupts(void)
29142892
if (ClientConnectionLost)
29152893
{
29162894
QueryCancelPending = false; /* lost connection trumps QueryCancel */
2917-
ImmediateInterruptOK = false; /* not idle anymore */
29182895
LockErrorCleanup();
29192896
/* don't send to client, we already know the connection to be dead. */
29202897
whereToSendOutput = DestNone;
@@ -2932,7 +2909,6 @@ ProcessInterrupts(void)
29322909
if (RecoveryConflictPending && DoingCommandRead)
29332910
{
29342911
QueryCancelPending = false; /* this trumps QueryCancel */
2935-
ImmediateInterruptOK = false; /* not idle anymore */
29362912
RecoveryConflictPending = false;
29372913
LockErrorCleanup();
29382914
pgstat_report_recovery_conflict(RecoveryConflictReason);
@@ -2970,7 +2946,6 @@ ProcessInterrupts(void)
29702946
*/
29712947
if (get_timeout_indicator(LOCK_TIMEOUT, true))
29722948
{
2973-
ImmediateInterruptOK = false; /* not idle anymore */
29742949
(void) get_timeout_indicator(STATEMENT_TIMEOUT, true);
29752950
LockErrorCleanup();
29762951
ereport(ERROR,
@@ -2979,23 +2954,20 @@ ProcessInterrupts(void)
29792954
}
29802955
if (get_timeout_indicator(STATEMENT_TIMEOUT, true))
29812956
{
2982-
ImmediateInterruptOK = false; /* not idle anymore */
29832957
LockErrorCleanup();
29842958
ereport(ERROR,
29852959
(errcode(ERRCODE_QUERY_CANCELED),
29862960
errmsg("canceling statement due to statement timeout")));
29872961
}
29882962
if (IsAutoVacuumWorkerProcess())
29892963
{
2990-
ImmediateInterruptOK = false; /* not idle anymore */
29912964
LockErrorCleanup();
29922965
ereport(ERROR,
29932966
(errcode(ERRCODE_QUERY_CANCELED),
29942967
errmsg("canceling autovacuum task")));
29952968
}
29962969
if (RecoveryConflictPending)
29972970
{
2998-
ImmediateInterruptOK = false; /* not idle anymore */
29992971
RecoveryConflictPending = false;
30002972
LockErrorCleanup();
30012973
pgstat_report_recovery_conflict(RecoveryConflictReason);
@@ -3012,7 +2984,6 @@ ProcessInterrupts(void)
30122984
*/
30132985
if (!DoingCommandRead)
30142986
{
3015-
ImmediateInterruptOK = false; /* not idle anymore */
30162987
LockErrorCleanup();
30172988
ereport(ERROR,
30182989
(errcode(ERRCODE_QUERY_CANCELED),

src/backend/utils/error/elog.c

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -412,26 +412,13 @@ errfinish(int dummy,...)
412412
{
413413
ErrorData *edata = &errordata[errordata_stack_depth];
414414
int elevel;
415-
bool save_ImmediateInterruptOK;
416415
MemoryContext oldcontext;
417416
ErrorContextCallback *econtext;
418417

419418
recursion_depth++;
420419
CHECK_STACK_DEPTH();
421420
elevel = edata->elevel;
422421

423-
/*
424-
* Ensure we can't get interrupted while performing error reporting. This
425-
* is needed to prevent recursive entry to functions like syslog(), which
426-
* may not be re-entrant.
427-
*
428-
* Note: other places that save-and-clear ImmediateInterruptOK also do
429-
* HOLD_INTERRUPTS(), but that should not be necessary here since we don't
430-
* call anything that could turn on ImmediateInterruptOK.
431-
*/
432-
save_ImmediateInterruptOK = ImmediateInterruptOK;
433-
ImmediateInterruptOK = false;
434-
435422
/*
436423
* Do processing in ErrorContext, which we hope has enough reserved space
437424
* to report an error.
@@ -463,10 +450,6 @@ errfinish(int dummy,...)
463450
* itself be inside a holdoff section. If necessary, such a handler
464451
* could save and restore InterruptHoldoffCount for itself, but this
465452
* should make life easier for most.)
466-
*
467-
* Note that we intentionally don't restore ImmediateInterruptOK here,
468-
* even if it was set at entry. We definitely don't want that on
469-
* while doing error cleanup.
470453
*/
471454
InterruptHoldoffCount = 0;
472455
QueryCancelHoldoffCount = 0;
@@ -573,15 +556,9 @@ errfinish(int dummy,...)
573556
}
574557

575558
/*
576-
* We reach here if elevel <= WARNING. OK to return to caller, so restore
577-
* caller's setting of ImmediateInterruptOK.
578-
*/
579-
ImmediateInterruptOK = save_ImmediateInterruptOK;
580-
581-
/*
582-
* But check for cancel/die interrupt first --- this is so that the user
583-
* can stop a query emitting tons of notice or warning messages, even if
584-
* it's in a loop that otherwise fails to check for interrupts.
559+
* Check for cancel/die interrupt first --- this is so that the user can
560+
* stop a query emitting tons of notice or warning messages, even if it's
561+
* in a loop that otherwise fails to check for interrupts.
585562
*/
586563
CHECK_FOR_INTERRUPTS();
587564
}

src/backend/utils/init/globals.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ volatile bool InterruptPending = false;
3030
volatile bool QueryCancelPending = false;
3131
volatile bool ProcDiePending = false;
3232
volatile bool ClientConnectionLost = false;
33-
volatile bool ImmediateInterruptOK = false;
3433
volatile uint32 InterruptHoldoffCount = 0;
3534
volatile uint32 QueryCancelHoldoffCount = 0;
3635
volatile uint32 CritSectionCount = 0;

src/backend/utils/misc/timeout.c

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -259,27 +259,12 @@ static void
259259
handle_sig_alarm(SIGNAL_ARGS)
260260
{
261261
int save_errno = errno;
262-
bool save_ImmediateInterruptOK = ImmediateInterruptOK;
263262

264263
/*
265-
* We may be executing while ImmediateInterruptOK is true (e.g., when
266-
* mainline is waiting for a lock). If SIGINT or similar arrives while
267-
* this code is running, we'd lose control and perhaps leave our data
268-
* structures in an inconsistent state. Disable immediate interrupts, and
269-
* just to be real sure, bump the holdoff counter as well. (The reason
270-
* for this belt-and-suspenders-too approach is to make sure that nothing
271-
* bad happens if a timeout handler calls code that manipulates
272-
* ImmediateInterruptOK.)
273-
*
274-
* Note: it's possible for a SIGINT to interrupt handle_sig_alarm before
275-
* we manage to do this; the net effect would be as if the SIGALRM event
276-
* had been silently lost. Therefore error recovery must include some
277-
* action that will allow any lost interrupt to be rescheduled. Disabling
278-
* some or all timeouts is sufficient, or if that's not appropriate,
279-
* reschedule_timeouts() can be called. Also, the signal blocking hazard
280-
* described below applies here too.
264+
* Bump the holdoff counter, to make sure nothing we call will process
265+
* interrupts directly. No timeout handler should do that, but these
266+
* failures are hard to debug, so better be sure.
281267
*/
282-
ImmediateInterruptOK = false;
283268
HOLD_INTERRUPTS();
284269

285270
/*
@@ -332,24 +317,7 @@ handle_sig_alarm(SIGNAL_ARGS)
332317
}
333318
}
334319

335-
/*
336-
* Re-allow query cancel, and then try to service any cancel request that
337-
* arrived meanwhile (this might in particular include a cancel request
338-
* fired by one of the timeout handlers). Since we are in a signal
339-
* handler, we mustn't call ProcessInterrupts unless ImmediateInterruptOK
340-
* is set; if it isn't, the cancel will happen at the next mainline
341-
* CHECK_FOR_INTERRUPTS.
342-
*
343-
* Note: a longjmp from here is safe so far as our own data structures are
344-
* concerned; but on platforms that block a signal before calling the
345-
* handler and then un-block it on return, longjmping out of the signal
346-
* handler leaves SIGALRM still blocked. Error cleanup is responsible for
347-
* unblocking any blocked signals.
348-
*/
349320
RESUME_INTERRUPTS();
350-
ImmediateInterruptOK = save_ImmediateInterruptOK;
351-
if (save_ImmediateInterruptOK)
352-
CHECK_FOR_INTERRUPTS();
353321

354322
errno = save_errno;
355323
}

src/include/miscadmin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ extern PGDLLIMPORT volatile bool ProcDiePending;
8484
extern volatile bool ClientConnectionLost;
8585

8686
/* these are marked volatile because they are examined by signal handlers: */
87-
extern PGDLLIMPORT volatile bool ImmediateInterruptOK;
8887
extern PGDLLIMPORT volatile uint32 InterruptHoldoffCount;
8988
extern PGDLLIMPORT volatile uint32 QueryCancelHoldoffCount;
9089
extern PGDLLIMPORT volatile uint32 CritSectionCount;

src/test/modules/test_shm_mq/worker.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ test_shm_mq_main(Datum main_arg)
6060
*
6161
* We want CHECK_FOR_INTERRUPTS() to kill off this worker process just as
6262
* it would a normal user backend. To make that happen, we establish a
63-
* signal handler that is a stripped-down version of die(). We don't have
64-
* any equivalent of the backend's command-read loop, where interrupts can
65-
* be processed immediately, so make sure ImmediateInterruptOK is turned
66-
* off.
63+
* signal handler that is a stripped-down version of die().
6764
*/
6865
pqsignal(SIGTERM, handle_sigterm);
69-
ImmediateInterruptOK = false;
7066
BackgroundWorkerUnblockSignals();
7167

7268
/*

0 commit comments

Comments
 (0)