diff options
author | Vadim B. Mikheev <vadim4o@yahoo.com> | 1999-06-03 13:33:13 +0000 |
---|---|---|
committer | Vadim B. Mikheev <vadim4o@yahoo.com> | 1999-06-03 13:33:13 +0000 |
commit | 5541abee0dd56669ef0e9a87121e449d905c3efd (patch) | |
tree | da8503c579bfc40595d1183f681ebd7901bfdab3 /src/backend/storage/ipc/shmem.c | |
parent | f103501286d8daf9073dc71a6f3ac2e532e6ef5b (diff) |
1. Additional fix against ERROR: Child itemid marked as unused
in CommitTransaction().
2. Changes in GetSnapshotData().
Diffstat (limited to 'src/backend/storage/ipc/shmem.c')
-rw-r--r-- | src/backend/storage/ipc/shmem.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index eafe53b0bb1..04cfa1a812e 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.40 1999/05/25 16:11:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.41 1999/06/03 13:33:13 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -593,6 +593,10 @@ ShmemInitStruct(char *name, unsigned long size, bool *foundPtr) * * Strange place for this func, but we have to lookup process data structures * for all running backends. - vadim 11/26/96 + * + * We should keep all PROC structs not in ShmemIndex - this is too + * general hash table... + * */ bool TransactionIdIsInProgress(TransactionId xid) @@ -648,10 +652,7 @@ GetSnapshotData(bool serializable) snapshot->xip = (TransactionId *) malloc(have * sizeof(TransactionId)); snapshot->xmin = cid; - if (serializable) - snapshot->xmax = cid; - else - ReadNewTransactionId(&(snapshot->xmax)); + ReadNewTransactionId(&(snapshot->xmax)); SpinAcquire(ShmemIndexLock); @@ -660,8 +661,10 @@ GetSnapshotData(bool serializable) { if (result == (ShmemIndexEnt *) TRUE) { - if (MyProc->xmin == InvalidTransactionId) + if (serializable) MyProc->xmin = snapshot->xmin; + /* Serializable snapshot must be computed before any other... */ + Assert(MyProc->xmin != InvalidTransactionId); SpinRelease(ShmemIndexLock); snapshot->xcnt = count; return snapshot; @@ -670,13 +673,24 @@ GetSnapshotData(bool serializable) strncmp(result->key, "PID ", 4) != 0) continue; proc = (PROC *) MAKE_PTR(result->location); - xid = proc->xid; /* we don't use spin-locking in xact.c ! */ - if (proc == MyProc || xid < FirstTransactionId) + /* + * We don't use spin-locking when changing proc->xid + * in GetNewTransactionId() and in AbortTransaction() !.. + */ + xid = proc->xid; + if (proc == MyProc || + xid < FirstTransactionId || xid >= snapshot->xmax) + { + /* + * Seems that there is no sense to store xid >= snapshot->xmax + * (what we got from ReadNewTransactionId above) in snapshot->xip + * - we just assume that all xacts with such xid-s are running + * and may be ignored. + */ continue; + } if (xid < snapshot->xmin) snapshot->xmin = xid; - else if (xid > snapshot->xmax) - snapshot->xmax = xid; if (have == 0) { snapshot->xip = (TransactionId *) realloc(snapshot->xip, @@ -712,7 +726,7 @@ GetXmaxRecent(TransactionId *XmaxRecent) Assert(ShmemIndex); - ReadNewTransactionId(XmaxRecent); + *XmaxRecent = GetCurrentTransactionId(); SpinAcquire(ShmemIndexLock); @@ -728,7 +742,7 @@ GetXmaxRecent(TransactionId *XmaxRecent) 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 ! */ + xmin = proc->xmin; /* we don't use spin-locking in AbortTransaction() ! */ if (proc == MyProc || xmin < FirstTransactionId) continue; if (xmin < *XmaxRecent) |