mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Rearrange vacuum-related bits in PGPROC as a bitmask, to better support
having several of them. Add two more flags: whether the process is executing an ANALYZE, and whether a vacuum is for Xid wraparound (which is obviously only set by autovacuum). Sneakily move the worker's recently-acquired PostAuthDelay to a more useful place.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.109 2007/09/24 03:12:23 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.110 2007/10/24 20:55:36 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -31,6 +31,7 @@
|
||||
#include "parser/parse_relation.h"
|
||||
#include "pgstat.h"
|
||||
#include "postmaster/autovacuum.h"
|
||||
#include "storage/proc.h"
|
||||
#include "utils/acl.h"
|
||||
#include "utils/datum.h"
|
||||
#include "utils/lsyscache.h"
|
||||
@ -201,6 +202,11 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
|
||||
return;
|
||||
}
|
||||
|
||||
/* let others know what I'm doing */
|
||||
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
|
||||
MyProc->vacuumFlags |= PROC_IN_ANALYZE;
|
||||
LWLockRelease(ProcArrayLock);
|
||||
|
||||
/* measure elapsed time iff autovacuum logging requires it */
|
||||
if (IsAutoVacuumWorkerProcess() && Log_autovacuum_min_duration >= 0)
|
||||
{
|
||||
@ -484,6 +490,14 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
|
||||
RelationGetRelationName(onerel),
|
||||
pg_rusage_show(&ru0))));
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset my PGPROC flag. Note: we need this here, and not in vacuum_rel,
|
||||
* because the vacuum flag is cleared by the end-of-xact code.
|
||||
*/
|
||||
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
|
||||
MyProc->vacuumFlags &= ~PROC_IN_ANALYZE;
|
||||
LWLockRelease(ProcArrayLock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user