Re: [COMMITTERS] pgsql: Fix freezing of a dead HOT-updated tuple

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: "Wong, Yi Wen" <yiwong(at)amazon(dot)com>, "Wood, Dan" <hexpert(at)amazon(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql: Fix freezing of a dead HOT-updated tuple
Date: 2017-10-05 16:24:03
Message-ID: 20171005162402.jahqflf3mekileqm@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

I think this is the patch for 9.3. I ran the test a few hundred times
(with some additional changes such as randomly having an update inside a
savepoint that's randomly aborted, randomly aborting the transaction,
randomly skipping the for key share lock, randomly sleeping at a few
points; and also adding filler columns, reducing fillfactor and using
5, 50, 180, 250, 500 sessions after verifying that it causes the tuples
to stay in the same page or migrate to later pages). The final REINDEX
has never complained again about failing to find the root tuple. I hope
it's good now.

The attached patch needs a few small tweaks, such as improving
commentary in the new function, maybe turn it into a macro (otherwise I
think it could be bad for performance; I'd like a static func but not
sure those are readily available in 9.3), change the XID comparison to
use the appropriate macro rather than ==, and such.

Regarding changes of xmin/xmax comparison, I also checked manually the
spots I thought should be modified and later double-checked against the
list that Michael posted. It's a match, except for rewriteheap.c which
I cannot make heads or tails about. (I think it's rather unfortunate
that it sticks a tuple's Xmax into a field that's called Xmin, but let's
put that aside). Maybe there's a problem here, maybe there isn't.

I'm now going to forward-port this to 9.4.

Álvaro Herrera
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Fix-bugs.patch text/plain 4.8 KB

In response to


Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2017-10-05 17:12:40 pgsql: Improve error message when skipping scan of default partition.
Previous Message Robert Haas 2017-10-05 15:43:48 pgsql: Allow DML commands that create tables to use parallel query.

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2017-10-05 17:02:53 Re: postgres_fdw super user checks
Previous Message Nico Williams 2017-10-05 15:52:14 Re: [PATCH] Add ALWAYS DEFERRED option for constraints