Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdea81a6

Browse files
committed
Revert SIGUSR1 multiplexing patch, per Tom's objection.
1 parent7b05b3f commitdea81a6

File tree

10 files changed

+45
-143
lines changed

10 files changed

+45
-143
lines changed

‎src/backend/access/transam/twophase.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
*$PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.49 2008/12/0914:28:20 heikki Exp $
10+
*$PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.50 2008/12/0915:59:39 heikki Exp $
1111
*
1212
* NOTES
1313
*Each global transaction is associated with a global transaction
@@ -287,7 +287,6 @@ MarkAsPreparing(TransactionId xid, const char *gid,
287287
gxact->proc.databaseId=databaseid;
288288
gxact->proc.roleId=owner;
289289
gxact->proc.inCommit= false;
290-
MemSet(gxact->proc.signalFlags,0,NUM_PROCSIGNALS*sizeof(sig_atomic_t));
291290
gxact->proc.vacuumFlags=0;
292291
gxact->proc.lwWaiting= false;
293292
gxact->proc.lwExclusive= false;

‎src/backend/commands/async.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.143 2008/12/0914:28:20 heikki Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.144 2008/12/0915:59:39 heikki Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -915,10 +915,9 @@ EnableNotifyInterrupt(void)
915915
*a frontend command. Signal handler execution of inbound notifies
916916
*is disabled until the next EnableNotifyInterrupt call.
917917
*
918-
*This also needs to be called when SIGUSR1 with
919-
*PROCSIG_CATCHUP_INTERRUPT is received, so as to prevent conflicts
920-
*if one signal interrupts the other. So we must return the previous
921-
*state of the flag.
918+
*The SIGUSR1 signal handler also needs to call this, so as to
919+
*prevent conflicts if one signal interrupts the other. So we
920+
*must return the previous state of the flag.
922921
*/
923922
bool
924923
DisableNotifyInterrupt(void)
@@ -955,7 +954,7 @@ ProcessIncomingNotify(void)
955954
nulls[Natts_pg_listener];
956955
boolcatchup_enabled;
957956

958-
/* Must preventcatchup interrupt while I am running */
957+
/* Must preventSIGUSR1 interrupt while I am running */
959958
catchup_enabled=DisableCatchupInterrupt();
960959

961960
if (Trace_notify)

‎src/backend/postmaster/autovacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
*
5757
* IDENTIFICATION
58-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.89 2008/12/0914:28:20 heikki Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.90 2008/12/0915:59:39 heikki Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -1477,7 +1477,7 @@ AutoVacWorkerMain(int argc, char *argv[])
14771477
pqsignal(SIGALRM,handle_sig_alarm);
14781478

14791479
pqsignal(SIGPIPE,SIG_IGN);
1480-
pqsignal(SIGUSR1,proc_sigusr1_handler);
1480+
pqsignal(SIGUSR1,CatchupInterruptHandler);
14811481
/* We don't listen for async notifies */
14821482
pqsignal(SIGUSR2,SIG_IGN);
14831483
pqsignal(SIGFPE,FloatExceptionHandler);

‎src/backend/storage/ipc/sinval.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/ipc/sinval.c,v 1.87 2008/12/0914:28:20 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/ipc/sinval.c,v 1.88 2008/12/0915:59:39 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -26,8 +26,8 @@
2626
* Because backends sitting idle will not be reading sinval events, we
2727
* need a way to give an idle backend a swift kick in the rear and make
2828
* it catch up before the sinval queue overflows and forces it to go
29-
* through a cache reset exercise.This is done by sending
30-
*PROCSIG_CATCHUP_INTERRUPTto any backend that gets too far behind.
29+
* through a cache reset exercise.This is done by sending SIGUSR1
30+
* to any backend that gets too far behind.
3131
*
3232
* State for catchup events consists of two flags: one saying whether
3333
* the signal handler is currently allowed to call ProcessCatchupEvent
@@ -144,9 +144,9 @@ ReceiveSharedInvalidMessages(
144144

145145

146146
/*
147-
*HandleCatchupInterrupt
147+
*CatchupInterruptHandler
148148
*
149-
* This iscalled when PROCSIG_CATCHUP_INTERRUPTsignalis received.
149+
* This isthesignalhandler for SIGUSR1.
150150
*
151151
* If we are idle (catchupInterruptEnabled is set), we can safely
152152
* invoke ProcessCatchupEvent directly. Otherwise, just set a flag
@@ -156,11 +156,13 @@ ReceiveSharedInvalidMessages(
156156
* since there's no longer any reason to do anything.)
157157
*/
158158
void
159-
HandleCatchupInterrupt(void)
159+
CatchupInterruptHandler(SIGNAL_ARGS)
160160
{
161+
intsave_errno=errno;
162+
161163
/*
162-
* Note: this iscalled bya SIGNAL HANDLER.
163-
*You must be very wary what you dohere.
164+
* Note: this is a SIGNAL HANDLER.You must be very wary what you do
165+
* here.
164166
*/
165167

166168
/* Don't joggle the elbow of proc_exit */
@@ -214,6 +216,8 @@ HandleCatchupInterrupt(void)
214216
*/
215217
catchupInterruptOccurred=1;
216218
}
219+
220+
errno=save_errno;
217221
}
218222

219223
/*
@@ -285,8 +289,7 @@ DisableCatchupInterrupt(void)
285289
/*
286290
* ProcessCatchupEvent
287291
*
288-
* Respond to a catchup event (PROCSIG_CATCHUP_INTERRUPT) from another
289-
* backend.
292+
* Respond to a catchup event (SIGUSR1) from another backend.
290293
*
291294
* This is called either directly from the SIGUSR1 signal handler,
292295
* or the next time control reaches the outer idle loop (assuming

‎src/backend/storage/ipc/sinvaladt.c

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.75 2008/12/0914:28:20 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.76 2008/12/0915:59:39 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -21,7 +21,6 @@
2121
#include"storage/backendid.h"
2222
#include"storage/ipc.h"
2323
#include"storage/proc.h"
24-
#include"storage/procarray.h"
2524
#include"storage/shmem.h"
2625
#include"storage/sinvaladt.h"
2726
#include"storage/spin.h"
@@ -137,9 +136,9 @@
137136
/* Per-backend state in shared invalidation structure */
138137
typedefstructProcState
139138
{
140-
/*proc isNULL in an inactive ProcState array entry. */
141-
PGPROC*proc;/*PGPROC entry of backend, for signaling */
142-
/* nextMsgNum is meaningless ifproc ==NULL or resetState is true. */
139+
/*procPid iszero in an inactive ProcState array entry. */
140+
pid_tprocPid;/*PID of backend, for signaling */
141+
/* nextMsgNum is meaningless ifprocPid ==0 or resetState is true. */
143142
intnextMsgNum;/* next message number to read */
144143
boolresetState;/* backend needs to reset its state */
145144
boolsignaled;/* backend has been sent catchup signal */
@@ -236,7 +235,7 @@ CreateSharedInvalidationState(void)
236235
/* Mark all backends inactive, and initialize nextLXID */
237236
for (i=0;i<shmInvalBuffer->maxBackends;i++)
238237
{
239-
shmInvalBuffer->procState[i].proc=NULL;/* inactive */
238+
shmInvalBuffer->procState[i].procPid=0;/* inactive */
240239
shmInvalBuffer->procState[i].nextMsgNum=0;/* meaningless */
241240
shmInvalBuffer->procState[i].resetState= false;
242241
shmInvalBuffer->procState[i].signaled= false;
@@ -267,7 +266,7 @@ SharedInvalBackendInit(void)
267266
/* Look for a free entry in the procState array */
268267
for (index=0;index<segP->lastBackend;index++)
269268
{
270-
if (segP->procState[index].proc==NULL)/* inactive slot? */
269+
if (segP->procState[index].procPid==0)/* inactive slot? */
271270
{
272271
stateP=&segP->procState[index];
273272
break;
@@ -279,7 +278,7 @@ SharedInvalBackendInit(void)
279278
if (segP->lastBackend<segP->maxBackends)
280279
{
281280
stateP=&segP->procState[segP->lastBackend];
282-
Assert(stateP->proc==NULL);
281+
Assert(stateP->procPid==0);
283282
segP->lastBackend++;
284283
}
285284
else
@@ -304,7 +303,7 @@ SharedInvalBackendInit(void)
304303
nextLocalTransactionId=stateP->nextLXID;
305304

306305
/* mark myself active, with all extant messages already read */
307-
stateP->proc=MyProc;
306+
stateP->procPid=MyProcPid;
308307
stateP->nextMsgNum=segP->maxMsgNum;
309308
stateP->resetState= false;
310309
stateP->signaled= false;
@@ -342,15 +341,15 @@ CleanupInvalidationState(int status, Datum arg)
342341
stateP->nextLXID=nextLocalTransactionId;
343342

344343
/* Mark myself inactive */
345-
stateP->proc=NULL;
344+
stateP->procPid=0;
346345
stateP->nextMsgNum=0;
347346
stateP->resetState= false;
348347
stateP->signaled= false;
349348

350349
/* Recompute index of last active backend */
351350
for (i=segP->lastBackend;i>0;i--)
352351
{
353-
if (segP->procState[i-1].proc!=NULL)
352+
if (segP->procState[i-1].procPid!=0)
354353
break;
355354
}
356355
segP->lastBackend=i;
@@ -375,7 +374,7 @@ BackendIdIsActive(int backendID)
375374
{
376375
ProcState*stateP=&segP->procState[backendID-1];
377376

378-
result= (stateP->proc!=NULL);
377+
result= (stateP->procPid!=0);
379378
}
380379
else
381380
result= false;
@@ -591,7 +590,7 @@ SICleanupQueue(bool callerHasWriteLock, int minFree)
591590
intn=stateP->nextMsgNum;
592591

593592
/* Ignore if inactive or already in reset state */
594-
if (stateP->proc==NULL||stateP->resetState)
593+
if (stateP->procPid==0||stateP->resetState)
595594
continue;
596595

597596
/*
@@ -645,20 +644,18 @@ SICleanupQueue(bool callerHasWriteLock, int minFree)
645644
segP->nextThreshold= (numMsgs /CLEANUP_QUANTUM+1)*CLEANUP_QUANTUM;
646645

647646
/*
648-
* Lastly, signal anyone who needs a catchup interrupt. Since
649-
* SendProcSignal() might not be fast, we don't want to hold locks while
650-
* executing it.
647+
* Lastly, signal anyone who needs a catchup interrupt. Since kill()
648+
* might not be fast, we don't want to hold locks while executing it.
651649
*/
652650
if (needSig)
653651
{
654-
PGPROC*his_proc=needSig->proc;
652+
pid_this_pid=needSig->procPid;
655653

656654
needSig->signaled= true;
657655
LWLockRelease(SInvalReadLock);
658656
LWLockRelease(SInvalWriteLock);
659-
elog(DEBUG4,"sending sinval catchup signal to PID %d",
660-
(int)his_proc->pid);
661-
SendProcSignal(his_proc,PROCSIG_CATCHUP_INTERRUPT);
657+
elog(DEBUG4,"sending sinval catchup signal to PID %d", (int)his_pid);
658+
kill(his_pid,SIGUSR1);
662659
if (callerHasWriteLock)
663660
LWLockAcquire(SInvalWriteLock,LW_EXCLUSIVE);
664661
}

‎src/backend/storage/lmgr/proc.c

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.203 2008/12/0914:28:20 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.204 2008/12/0915:59:39 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -289,7 +289,6 @@ InitProcess(void)
289289
MyProc->databaseId=InvalidOid;
290290
MyProc->roleId=InvalidOid;
291291
MyProc->inCommit= false;
292-
MemSet(MyProc->signalFlags,0,NUM_PROCSIGNALS*sizeof(sig_atomic_t));
293292
MyProc->vacuumFlags=0;
294293
if (IsAutoVacuumWorkerProcess())
295294
MyProc->vacuumFlags |=PROC_IS_AUTOVACUUM;
@@ -429,7 +428,6 @@ InitAuxiliaryProcess(void)
429428
MyProc->databaseId=InvalidOid;
430429
MyProc->roleId=InvalidOid;
431430
MyProc->inCommit= false;
432-
MemSet(MyProc->signalFlags,0,NUM_PROCSIGNALS*sizeof(sig_atomic_t));
433431
/* we don't set the "is autovacuum" flag in the launcher */
434432
MyProc->vacuumFlags=0;
435433
MyProc->lwWaiting= false;
@@ -1279,54 +1277,6 @@ ProcSendSignal(int pid)
12791277
PGSemaphoreUnlock(&proc->sem);
12801278
}
12811279

1282-
/*
1283-
* SendProcSignal - send the signal with the reason to a process.
1284-
*
1285-
* The process can be a backend or an auxiliary process that has a PGPROC
1286-
* entry, like an autovacuum worker.
1287-
*/
1288-
void
1289-
SendProcSignal(PGPROC*proc,ProcSignalReasonreason)
1290-
{
1291-
pid_tpid;
1292-
1293-
/*
1294-
* If the process is gone, do nothing.
1295-
*
1296-
* Since there's no locking, it's possible that the process detaches
1297-
* from shared memory and exits right after this test, before we set
1298-
* the flag and send signal. And the PGPROC entry might even be recycled
1299-
* by a new process, so it's remotely possible that we signal a wrong
1300-
* process. That's OK, all the signals are such that no harm is done.
1301-
*/
1302-
pid=proc->pid;
1303-
if (pid==0)
1304-
return;
1305-
1306-
/* Atomically set the proper flag */
1307-
proc->signalFlags[reason]= true;
1308-
/* Send SIGUSR1 to the process */
1309-
kill(pid,SIGUSR1);
1310-
}
1311-
1312-
/*
1313-
* CheckProcSignal - check to see if the particular reason has been
1314-
* signaled, and clear the signal flag. Should be called after
1315-
* receiving SIGUSR1.
1316-
*/
1317-
bool
1318-
CheckProcSignal(ProcSignalReasonreason)
1319-
{
1320-
/* Careful here --- don't clear flag if we haven't seen it set */
1321-
if (MyProc->signalFlags[reason])
1322-
{
1323-
MyProc->signalFlags[reason]= false;
1324-
return true;
1325-
}
1326-
1327-
return false;
1328-
}
1329-
13301280

13311281
/*****************************************************************************
13321282
* SIGALRM interrupt support

‎src/backend/tcop/postgres.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.559 2008/12/0914:28:20 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.560 2008/12/0915:59:39 heikki Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -2436,23 +2436,6 @@ drop_unnamed_stmt(void)
24362436
* --------------------------------
24372437
*/
24382438

2439-
/*
2440-
* proc_sigusr1_handler - handle SIGUSR1 signal.
2441-
*
2442-
* SIGUSR1 is multiplexed to handle multiple different events. The signalFlags
2443-
* array in PGPROC indicates which events have been signaled.
2444-
*/
2445-
void
2446-
proc_sigusr1_handler(SIGNAL_ARGS)
2447-
{
2448-
intsave_errno=errno;
2449-
2450-
if (CheckProcSignal(PROCSIG_CATCHUP_INTERRUPT))
2451-
HandleCatchupInterrupt();
2452-
2453-
errno=save_errno;
2454-
}
2455-
24562439
/*
24572440
* quickdie() occurs when signalled SIGQUIT by the postmaster.
24582441
*
@@ -3197,7 +3180,7 @@ PostgresMain(int argc, char *argv[], const char *username)
31973180
* of output during who-knows-what operation...
31983181
*/
31993182
pqsignal(SIGPIPE,SIG_IGN);
3200-
pqsignal(SIGUSR1,proc_sigusr1_handler);
3183+
pqsignal(SIGUSR1,CatchupInterruptHandler);
32013184
pqsignal(SIGUSR2,NotifyInterruptHandler);
32023185
pqsignal(SIGFPE,FloatExceptionHandler);
32033186

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp