ITAGAKI Takahiro wrote:
> I found autovacuum can be canceled by blocked backends even if the vacuum
> is for preventing XID wraparound in 8.3.0 and HEAD. Autovacuum sets
> PROC_VACUUM_FOR_WRAPAROUND flag just before vacuum, but the flag will be
> cleared at the beginning of vacuum; PROC_VACUUM_FOR_WRAPAROUND is not set
> during the vacuum.
Rats.
How about this other patch?
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
*** src/backend/commands/vacuum.c 10 Mar 2008 02:04:08 -0000 1.366
--- src/backend/commands/vacuum.c 14 Mar 2008 12:54:14 -0000
***************
*** 1005,1011 ****
* which is probably Not Good.
*/
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
! MyProc->vacuumFlags |= PROC_IN_VACUUM;
LWLockRelease(ProcArrayLock);
}
--- 1005,1011 ----
* which is probably Not Good.
*/
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
! MyProc->vacuumFlags |= PROC_IN_VACUUM | AutovacuumWraparoundFlag;
LWLockRelease(ProcArrayLock);
}
*** src/backend/postmaster/autovacuum.c 20 Feb 2008 14:01:45 -0000 1.72
--- src/backend/postmaster/autovacuum.c 14 Mar 2008 12:53:22 -0000
***************
*** 254,259 ****
--- 254,263 ----
/* PID of launcher, valid only in worker while shutting down */
int AutovacuumLauncherPid = 0;
+ /* Mask for PGPROC->vacuumFlags */
+ uint8 AutovacuumWraparoundFlag = 0;
+
+
#ifdef EXEC_BACKEND
static pid_t avlauncher_forkexec(void);
static pid_t avworker_forkexec(void);
***************
*** 2095,2107 ****
/* clean up memory before each iteration */
MemoryContextResetAndDeleteChildren(PortalContext);
! /* set the "vacuum for wraparound" flag in PGPROC */
if (tab->at_wraparound)
! {
! LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
! MyProc->vacuumFlags |= PROC_VACUUM_FOR_WRAPAROUND;
! LWLockRelease(ProcArrayLock);
! }
/*
* Save the relation name for a possible error message, to avoid a
--- 2099,2107 ----
/* clean up memory before each iteration */
MemoryContextResetAndDeleteChildren(PortalContext);
! /* set the "vacuum for wraparound" flag, to be set in PGPROC later */
if (tab->at_wraparound)
! AutovacuumWraparoundFlag = PROC_VACUUM_FOR_WRAPAROUND;
/*
* Save the relation name for a possible error message, to avoid a
***************
*** 2151,2157 ****
datname, nspname, relname);
EmitErrorReport();
! /* this resets the PGPROC flags too */
AbortOutOfAnyTransaction();
FlushErrorState();
MemoryContextResetAndDeleteChildren(PortalContext);
--- 2151,2161 ----
datname, nspname, relname);
EmitErrorReport();
! /*
! * Aborting the transaction resets the PGPROC flags; we need to
! * reset our own here
! */
! AutovacuumWraparoundFlag = 0;
AbortOutOfAnyTransaction();
FlushErrorState();
MemoryContextResetAndDeleteChildren(PortalContext);
***************
*** 2162,2168 ****
}
PG_END_TRY();
! /* the PGPROC flags are reset at the next end of transaction */
/* be tidy */
pfree(tab);
--- 2166,2176 ----
}
PG_END_TRY();
! /*
! * The PGPROC flags are reset at the next end of transaction;
! * reset our own
! */
! AutovacuumWraparoundFlag = 0;
/* be tidy */
pfree(tab);
*** src/include/postmaster/autovacuum.h 1 Jan 2008 19:45:58 -0000 1.14
--- src/include/postmaster/autovacuum.h 14 Mar 2008 12:53:55 -0000
***************
*** 60,63 ****
--- 60,66 ----
extern Size AutoVacuumShmemSize(void);
extern void AutoVacuumShmemInit(void);
+ /* PGPROC flag */
+ extern uint8 AutovacuumWraparoundFlag;
+
#endif /* AUTOVACUUM_H */
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers