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

Commita115bfe

Browse files
committed
Fix failure to check for INVALID worker entry in the new autovacuum code, which
could happen when a worker took to long to start and was thus "aborted" by thelauncher. Noticed by lionfish buildfarm member.
1 parent88f1fd2 commita115bfe

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

‎src/backend/postmaster/autovacuum.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.42 2007/04/18 16:44:18 alvherre Exp $
13+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.43 2007/05/02 15:47:14 alvherre Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1407,25 +1407,36 @@ AutoVacWorkerMain(int argc, char *argv[])
14071407
* Get the info about the database we're going to work on.
14081408
*/
14091409
LWLockAcquire(AutovacuumLock,LW_EXCLUSIVE);
1410-
MyWorkerInfo= (WorkerInfo)MAKE_PTR(AutoVacuumShmem->av_startingWorker);
1411-
dbid=MyWorkerInfo->wi_dboid;
1412-
MyWorkerInfo->wi_workerpid=MyProcPid;
14131410

1414-
/* insert into the running list */
1415-
SHMQueueInsertBefore(&AutoVacuumShmem->av_runningWorkers,
1416-
&MyWorkerInfo->wi_links);
14171411
/*
1418-
*remove from the "starting" pointer, so that the launcher can start a new
1419-
*worker if required
1412+
*beware of startingWorker being INVALID; this could happen if the
1413+
*launcher thinks we've taking too long to start.
14201414
*/
1421-
AutoVacuumShmem->av_startingWorker=INVALID_OFFSET;
1422-
LWLockRelease(AutovacuumLock);
1415+
if (AutoVacuumShmem->av_startingWorker!=INVALID_OFFSET)
1416+
{
1417+
MyWorkerInfo= (WorkerInfo)MAKE_PTR(AutoVacuumShmem->av_startingWorker);
1418+
dbid=MyWorkerInfo->wi_dboid;
1419+
MyWorkerInfo->wi_workerpid=MyProcPid;
1420+
1421+
/* insert into the running list */
1422+
SHMQueueInsertBefore(&AutoVacuumShmem->av_runningWorkers,
1423+
&MyWorkerInfo->wi_links);
1424+
/*
1425+
* remove from the "starting" pointer, so that the launcher can start a new
1426+
* worker if required
1427+
*/
1428+
AutoVacuumShmem->av_startingWorker=INVALID_OFFSET;
1429+
LWLockRelease(AutovacuumLock);
14231430

1424-
on_shmem_exit(FreeWorkerInfo,0);
1431+
on_shmem_exit(FreeWorkerInfo,0);
14251432

1426-
/* wake up the launcher */
1427-
if (AutoVacuumShmem->av_launcherpid!=0)
1428-
kill(AutoVacuumShmem->av_launcherpid,SIGUSR1);
1433+
/* wake up the launcher */
1434+
if (AutoVacuumShmem->av_launcherpid!=0)
1435+
kill(AutoVacuumShmem->av_launcherpid,SIGUSR1);
1436+
}
1437+
else
1438+
/* no worker entry for me, go away */
1439+
LWLockRelease(AutovacuumLock);
14291440

14301441
if (OidIsValid(dbid))
14311442
{
@@ -1466,8 +1477,8 @@ AutoVacWorkerMain(int argc, char *argv[])
14661477
}
14671478

14681479
/*
1469-
*FIXME -- we need to notify the launcher when we are gone. But this
1470-
*should be done after our PGPROC is released, in ProcKill.
1480+
*The launcher will be notified of my death in ProcKill, *if* we managed
1481+
*to get a worker slot at all
14711482
*/
14721483

14731484
/* All done, go away */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp