TransactionId *subxid);
static void KnownAssignedXidsRemove(TransactionId xid, bool report_error);
static void KnownAssignedXidsRemoveMany(TransactionId xid);
+static bool KnownAssignedXidsFind(TransactionId xid);
static void KnownAssignedXidsDisplay(int trace_level);
/*
TransactionId topxid;
int i,
j;
+ bool found;
/*
* Don't bother checking a transaction older than RecentXmin; it could not
xids[nxids++] = pxid;
}
+ /*
+ * Check if the transaction id known assigned or whether it is
+ * completed.
+ */
+ if (RecoveryInProgress())
+ {
+ found = FindKnownAssignedTransactionId(xid);
+
+ if (found)
+ {
+ LWLockRelease(ProcArrayLock);
+ xc_by_main_xid_inc(); /* we don't know whether its child or main */
+ return true;
+ }
+ }
+
LWLockRelease(ProcArrayLock);
/*
* held ProcArrayLock).
*/
topxid = SubTransGetTopmostTransaction(xid);
- Assert(TransactionIdIsValid(topxid));
- if (!TransactionIdEquals(topxid, xid))
+ if (!RecoveryInProgress())
{
- for (i = 0; i < nxids; i++)
+ Assert(TransactionIdIsValid(topxid));
+ if (!TransactionIdEquals(topxid, xid))
{
- if (TransactionIdEquals(xids[i], topxid))
- return true;
+ for (i = 0; i < nxids; i++)
+ {
+ if (TransactionIdEquals(xids[i], topxid))
+ return true;
+ }
}
+
+ return false;
}
+ else
+ {
+ /*
+ * We weren't sure which xids were top-level or not, so
+ * we don't have space to record them in the work area.
+ * So we must re-acquire lock and re-check KnownAssignedXids.
+ */
+ LWLockAcquire(ProcArrayLock, LW_SHARED);
+ found = FindKnownAssignedTransactionId(xid);
+ LWLockRelease(ProcArrayLock);
- return false;
+ return found;
+ }
}
/*
LWLockRelease(ProcArrayLock);
}
+bool
+FindKnownAssignedTransactionId(TransactionId xid)
+{
+ return KnownAssignedXidsFind(xid);
+}
+
/*
* Get an array of KnownAssignedXids, not necessarily in sorted order.
*
}
}
+static bool
+KnownAssignedXidsFind(TransactionId xid)
+{
+ bool found;
+
+ (void) hash_search(KnownAssignedXidsHash, &xid, HASH_FIND, &found);
+
+ return found;
+}
+
/*
* xidComparator
* qsort comparison function for XIDs