aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2014-05-25 01:37:52 +0200
committerAndres Freund <andres@anarazel.de>2014-05-25 17:54:53 +0200
commit9fa93530c878a0e23147a65f7d9a62802b22a995 (patch)
treeb20f8cac22b06858dbe8bd64b5c0562b95dc31b5 /src
parent0564bbe7a1690f025f4424d5a12cb6af9d428c48 (diff)
downloadpostgresql-9fa93530c878a0e23147a65f7d9a62802b22a995.tar.gz
postgresql-9fa93530c878a0e23147a65f7d9a62802b22a995.zip
Don't allocate memory inside an Assert() iff in a critical section.
HeapTupleHeaderGetCmax() asserts that it is only used if the tuple has been updated by the current transaction. That check is correct and sensible but requires allocating memory if xmax is a multixact. When wal_level is set to logical cmax needs to be included in a wal record , generated inside a critical section, which can trigger the assertion added in 4a170ee9e. Reported-By: Steve Singer
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/time/combocid.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/utils/time/combocid.c b/src/backend/utils/time/combocid.c
index 52b612b15a1..a70c7542c92 100644
--- a/src/backend/utils/time/combocid.c
+++ b/src/backend/utils/time/combocid.c
@@ -41,6 +41,7 @@
#include "postgres.h"
+#include "miscadmin.h"
#include "access/htup_details.h"
#include "access/xact.h"
#include "utils/combocid.h"
@@ -119,7 +120,14 @@ HeapTupleHeaderGetCmax(HeapTupleHeader tup)
CommandId cid = HeapTupleHeaderGetRawCommandId(tup);
Assert(!(tup->t_infomask & HEAP_MOVED));
- Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetUpdateXid(tup)));
+ /*
+ * Because GetUpdateXid() performs memory allocations if xmax is a
+ * multixact we can't Assert() if we're inside a critical section. This
+ * weakens the check, but not using GetCmax() inside one would complicate
+ * things too much.
+ */
+ Assert(CritSectionCount > 0 ||
+ TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetUpdateXid(tup)));
if (tup->t_infomask & HEAP_COMBOCID)
return GetRealCmax(cid);