diff options
Diffstat (limited to 'src/backend/storage')
-rw-r--r-- | src/backend/storage/buffer/bufmgr.c | 29 | ||||
-rw-r--r-- | src/backend/storage/ipc/shmem.c | 73 | ||||
-rw-r--r-- | src/backend/storage/lmgr/multi.c | 53 | ||||
-rw-r--r-- | src/backend/storage/lmgr/proc.c | 6 |
4 files changed, 77 insertions, 84 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 8d0a299e72c..04c1f4813d2 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.49 1999/02/21 03:49:21 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.50 1999/03/28 20:32:17 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -95,7 +95,7 @@ static BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum, static int FlushBuffer(Buffer buffer, bool release); static void BufferSync(void); static int BufferReplace(BufferDesc *bufHdr, bool bufferLockHeld); -static void PrintBufferDescs(void); +void PrintBufferDescs(void); /* not static but used by vacuum only ... */ int BlowawayRelationBuffers(Relation rel, BlockNumber block); @@ -1208,23 +1208,24 @@ int BufferPoolCheckLeak() { int i; - int error = 0; + int result = 0; for (i = 1; i <= NBuffers; i++) { if (BufferIsValid(i)) { + BufferDesc *buf = &(BufferDescriptors[i - 1]); + elog(NOTICE, - "buffer leak [%d] detected in BufferPoolCheckLeak()", i - 1); - error = 1; + "Buffer Leak: [%03d] (freeNext=%d, freePrev=%d, \ +relname=%s, blockNum=%d, flags=0x%x, refcount=%d %d)", + i - 1, buf->freeNext, buf->freePrev, + buf->sb_relname, buf->tag.blockNum, buf->flags, + buf->refcount, PrivateRefCount[i - 1]); + result = 1; } } - if (error) - { - PrintBufferDescs(); - return 1; - } - return 0; + return (result); } /* ------------------------------------------------ @@ -1465,7 +1466,7 @@ DropBuffers(Oid dbid) * use only. * ----------------------------------------------------------------- */ -static void +void PrintBufferDescs() { int i; @@ -1474,16 +1475,14 @@ PrintBufferDescs() if (IsUnderPostmaster) { SpinAcquire(BufMgrLock); -#ifdef NOT_USED for (i = 0; i < NBuffers; ++i, ++buf) { - elog(NOTICE, "[%02d] (freeNext=%d, freePrev=%d, relname=%s, \ + elog(DEBUG, "[%02d] (freeNext=%d, freePrev=%d, relname=%s, \ blockNum=%d, flags=0x%x, refcount=%d %d)", i, buf->freeNext, buf->freePrev, buf->sb_relname, buf->tag.blockNum, buf->flags, buf->refcount, PrivateRefCount[i]); } -#endif SpinRelease(BufMgrLock); } else diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index 3653e844ab6..55ecd857970 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.37 1999/02/22 06:16:48 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.38 1999/03/28 20:32:22 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -636,12 +636,13 @@ TransactionIdIsInProgress(TransactionId xid) Snapshot GetSnapshotData(bool serializable) { - Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData)); - ShmemIndexEnt *result; - PROC *proc; - TransactionId cid = GetCurrentTransactionId(); - uint32 count = 0; - uint32 have = 32; + Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData)); + ShmemIndexEnt *result; + PROC *proc; + TransactionId cid = GetCurrentTransactionId(); + TransactionId xid; + uint32 count = 0; + uint32 have = 32; Assert(ShmemIndex); @@ -669,19 +670,20 @@ GetSnapshotData(bool serializable) strncmp(result->key, "PID ", 4) != 0) continue; proc = (PROC *) MAKE_PTR(result->location); - if (proc == MyProc || proc->xid < FirstTransactionId) + xid = proc->xid; /* we don't use spin-locking in xact.c ! */ + if (proc == MyProc || xid < FirstTransactionId) continue; - if (proc->xid < snapshot->xmin) - snapshot->xmin = proc->xid; - else if (proc->xid > snapshot->xmax) - snapshot->xmax = proc->xid; + if (xid < snapshot->xmin) + snapshot->xmin = xid; + else if (xid > snapshot->xmax) + snapshot->xmax = xid; if (have == 0) { snapshot->xip = (TransactionId *) realloc(snapshot->xip, (count + 32) * sizeof(TransactionId)); have = 32; } - snapshot->xip[count] = proc->xid; + snapshot->xip[count] = xid; have--; count++; } @@ -692,3 +694,48 @@ GetSnapshotData(bool serializable) elog(ERROR, "GetSnapshotData: ShmemIndex corrupted"); return NULL; } + +/* + * GetXmaxRecent -- returns oldest transaction that was running + * when all current transaction was started. + * It's used by vacuum to decide what deleted + * tuples must be preserved in a table. + * + * And yet another strange func for this place... - vadim 03/18/99 + */ +void +GetXmaxRecent(TransactionId *XmaxRecent) +{ + ShmemIndexEnt *result; + PROC *proc; + TransactionId xmin; + + Assert(ShmemIndex); + + ReadNewTransactionId(XmaxRecent); + + SpinAcquire(ShmemIndexLock); + + hash_seq((HTAB *) NULL); + while ((result = (ShmemIndexEnt *) hash_seq(ShmemIndex)) != NULL) + { + if (result == (ShmemIndexEnt *) TRUE) + { + SpinRelease(ShmemIndexLock); + return; + } + if (result->location == INVALID_OFFSET || + strncmp(result->key, "PID ", 4) != 0) + continue; + proc = (PROC *) MAKE_PTR(result->location); + xmin = proc->xmin; /* we don't use spin-locking in xact.c ! */ + if (proc == MyProc || xmin < FirstTransactionId) + continue; + if (xmin < *XmaxRecent) + *XmaxRecent = xmin; + } + + SpinRelease(ShmemIndexLock); + elog(ERROR, "GetXmaxRecent: ShmemIndex corrupted"); + return NULL; +} diff --git a/src/backend/storage/lmgr/multi.c b/src/backend/storage/lmgr/multi.c index 6807e9d7cc0..38e2d194d65 100644 --- a/src/backend/storage/lmgr/multi.c +++ b/src/backend/storage/lmgr/multi.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.27 1999/02/13 23:18:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.28 1999/03/28 20:32:25 vadim Exp $ * * NOTES: * (1) The lock.c module assumes that the caller here is doing @@ -34,55 +34,6 @@ static bool MultiAcquire(LOCKMETHOD lockmethod, LOCKTAG *tag, static bool MultiRelease(LOCKMETHOD lockmethod, LOCKTAG *tag, LOCKMODE lockmode, PG_LOCK_LEVEL level); -#ifdef LowLevelLocking - -static MASK MultiConflicts[] = { - (int) NULL, - -/* RowShareLock */ - (1 << ExclusiveLock), - -/* RowExclusiveLock */ - (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) | (1 << ShareLock), - -/* ShareLock */ - (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) | - (1 << RowExclusiveLock), - -/* ShareRowExclusiveLock */ - (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) | - (1 << ShareLock) | (1 << RowExclusiveLock), - -/* ExclusiveLock */ - (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) | (1 << ShareLock) | - (1 << RowExclusiveLock) | (1 << RowShareLock), - -/* ObjShareLock */ - (1 << ObjExclusiveLock), - -/* ObjExclusiveLock */ - (1 << ObjExclusiveLock) | (1 << ObjShareLock), - -/* ExtendLock */ - (1 << ExtendLock) - -}; - -/* - * write locks have higher priority than read locks and extend locks. May - * want to treat INTENT locks differently. - */ -static int MultiPrios[] = { - (int) NULL, - 2, - 1, - 2, - 1, - 1 -}; - -#else - /* * INTENT indicates to higher level that a lower level lock has been * set. For example, a write lock on a tuple conflicts with a write @@ -121,8 +72,6 @@ static int MultiPrios[] = { 1 }; -#endif /* !LowLevelLocking */ - /* * Lock table identifier for this lock table. The multi-level * lock table is ONE lock table, not three. diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 2bb66c09d6a..cc5233b0764 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.51 1999/02/21 01:41:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.52 1999/03/28 20:32:26 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ * This is so that we can support more backends. (system-wide semaphore * sets run out pretty fast.) -ay 4/95 * - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.51 1999/02/21 01:41:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.52 1999/03/28 20:32:26 vadim Exp $ */ #include <sys/time.h> #include <unistd.h> @@ -300,9 +300,7 @@ InitProcess(IPCKey key) MyProc->pid = MyProcPid; MyProc->xid = InvalidTransactionId; -#ifdef LowLevelLocking MyProc->xmin = InvalidTransactionId; -#endif /* ---------------- * Start keeping spin lock stats from here on. Any botch before |