aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/ipc/sinvaladt.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-07-01 02:09:34 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-07-01 02:09:34 +0000
commit5b965bf08bfb4aa8928bafaed20e42b89de02a5c (patch)
tree5e8098d46cda226eb35aa38229d97a2258674b24 /src/backend/storage/ipc/sinvaladt.c
parent92d1cc89738e70a01e7c095f2315e80b9c4ef900 (diff)
downloadpostgresql-5b965bf08bfb4aa8928bafaed20e42b89de02a5c.tar.gz
postgresql-5b965bf08bfb4aa8928bafaed20e42b89de02a5c.zip
Teach autovacuum how to determine whether a temp table belongs to a crashed
backend. If so, send a LOG message to the postmaster log, and if the table is beyond the vacuum-for-wraparound horizon, forcibly drop it. Per recent discussions. Perhaps we ought to back-patch this, but it probably needs to age a bit in HEAD first.
Diffstat (limited to 'src/backend/storage/ipc/sinvaladt.c')
-rw-r--r--src/backend/storage/ipc/sinvaladt.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/backend/storage/ipc/sinvaladt.c b/src/backend/storage/ipc/sinvaladt.c
index e414e4a5071..8aa4ec836b5 100644
--- a/src/backend/storage/ipc/sinvaladt.c
+++ b/src/backend/storage/ipc/sinvaladt.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.72 2008/06/20 00:24:53 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.73 2008/07/01 02:09:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -358,6 +358,33 @@ CleanupInvalidationState(int status, Datum arg)
}
/*
+ * BackendIdIsActive
+ * Test if the given backend ID is currently assigned to a process.
+ */
+bool
+BackendIdIsActive(int backendID)
+{
+ bool result;
+ SISeg *segP = shmInvalBuffer;
+
+ /* Need to lock out additions/removals of backends */
+ LWLockAcquire(SInvalWriteLock, LW_SHARED);
+
+ if (backendID > 0 && backendID <= segP->lastBackend)
+ {
+ ProcState *stateP = &segP->procState[backendID - 1];
+
+ result = (stateP->procPid != 0);
+ }
+ else
+ result = false;
+
+ LWLockRelease(SInvalWriteLock);
+
+ return result;
+}
+
+/*
* SIInsertDataEntries
* Add new invalidation message(s) to the buffer.
*/