diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2007-10-24 20:55:36 +0000 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2007-10-24 20:55:36 +0000 |
commit | 745c1b2c2ab8385c8392ff10383a64527e3150b7 (patch) | |
tree | 5131b38db8268f22d6202869e3e7c7ab4fc5056e /src/backend/commands/analyze.c | |
parent | 3ef18797b83b9b274218009802a5994b7f41c818 (diff) |
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.
Diffstat (limited to 'src/backend/commands/analyze.c')
-rw-r--r-- | src/backend/commands/analyze.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 418dbaa1084..51944c54c28 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -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); } /* |