Commit a115bfe3 authored by Alvaro Herrera's avatar Alvaro Herrera

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 the
launcher.  Noticed by lionfish buildfarm member.
parent 88f1fd29
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.42 2007/04/18 16:44:18 alvherre Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.43 2007/05/02 15:47:14 alvherre Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1407,6 +1407,13 @@ AutoVacWorkerMain(int argc, char *argv[]) ...@@ -1407,6 +1407,13 @@ AutoVacWorkerMain(int argc, char *argv[])
* Get the info about the database we're going to work on. * Get the info about the database we're going to work on.
*/ */
LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE); LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE);
/*
* beware of startingWorker being INVALID; this could happen if the
* launcher thinks we've taking too long to start.
*/
if (AutoVacuumShmem->av_startingWorker != INVALID_OFFSET)
{
MyWorkerInfo = (WorkerInfo) MAKE_PTR(AutoVacuumShmem->av_startingWorker); MyWorkerInfo = (WorkerInfo) MAKE_PTR(AutoVacuumShmem->av_startingWorker);
dbid = MyWorkerInfo->wi_dboid; dbid = MyWorkerInfo->wi_dboid;
MyWorkerInfo->wi_workerpid = MyProcPid; MyWorkerInfo->wi_workerpid = MyProcPid;
...@@ -1426,6 +1433,10 @@ AutoVacWorkerMain(int argc, char *argv[]) ...@@ -1426,6 +1433,10 @@ AutoVacWorkerMain(int argc, char *argv[])
/* wake up the launcher */ /* wake up the launcher */
if (AutoVacuumShmem->av_launcherpid != 0) if (AutoVacuumShmem->av_launcherpid != 0)
kill(AutoVacuumShmem->av_launcherpid, SIGUSR1); kill(AutoVacuumShmem->av_launcherpid, SIGUSR1);
}
else
/* no worker entry for me, go away */
LWLockRelease(AutovacuumLock);
if (OidIsValid(dbid)) if (OidIsValid(dbid))
{ {
...@@ -1466,8 +1477,8 @@ AutoVacWorkerMain(int argc, char *argv[]) ...@@ -1466,8 +1477,8 @@ AutoVacWorkerMain(int argc, char *argv[])
} }
/* /*
* FIXME -- we need to notify the launcher when we are gone. But this * The launcher will be notified of my death in ProcKill, *if* we managed
* should be done after our PGPROC is released, in ProcKill. * to get a worker slot at all
*/ */
/* All done, go away */ /* All done, go away */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment