Commit 9fa93530 authored by Andres Freund's avatar Andres Freund

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 4a170ee9.

Reported-By: Steve Singer
parent 0564bbe7
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "postgres.h" #include "postgres.h"
#include "miscadmin.h"
#include "access/htup_details.h" #include "access/htup_details.h"
#include "access/xact.h" #include "access/xact.h"
#include "utils/combocid.h" #include "utils/combocid.h"
...@@ -119,7 +120,14 @@ HeapTupleHeaderGetCmax(HeapTupleHeader tup) ...@@ -119,7 +120,14 @@ HeapTupleHeaderGetCmax(HeapTupleHeader tup)
CommandId cid = HeapTupleHeaderGetRawCommandId(tup); CommandId cid = HeapTupleHeaderGetRawCommandId(tup);
Assert(!(tup->t_infomask & HEAP_MOVED)); 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) if (tup->t_infomask & HEAP_COMBOCID)
return GetRealCmax(cid); return GetRealCmax(cid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment