Heikki Linnakangas <heikki@enterprisedb.com> writes:
> I found one more subtle safety issue. The array and hash table for
> phantom command ids is dynamically grown when HeapTupleHeaderSetCmax is
> called. Unfortunately, since HeapTupleHeaderSetCmax is used inside a
> critical sections, running out of memory while trying to grow them would
> cause a PANIC. That's why I moved the SetXmax/SetCmax calls outside
> critical sections in heapam.c. I believe that's safe; if a backend
> aborts after setting the xmax/cmax, no-one is going to care about the
> xid of an aborted transaction in there.
I don't like that one bit; I think a saner solution is to refactor the
API of combocid.c so that we can obtain the required CID before
modifying the page. It'll mean it's not a drop-in replacement for
HeapTupleSetCmax, but all callers of that are going to need a close look
anyway.
regards, tom lane