From: Alvaro Herrera <alvherre@2ndQuadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: Wood, Dan <hexpert@amazon.com>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: pgsql-committers@postgresql.org, "Wong, Yi Wen" <yiwong@amazon.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] [COMMITTERS] pgsql: Fix freezing of a dead HOT-updated tuple
Date: Wed, 6 Dec 2017 13:21:15 -0300
Message-ID: <20171206162115.kdsd2fnipyswonir@alvherre.pgsql> (raw)
In-Reply-To: <20171114030341.movhteyakqeqx5pm@alap3.anarazel.de>
I think you've done a stellar job of identifying what the actual problem
was. I like the new (simpler) coding of that portion of
HeapTupleSatisfiesVacuum.
freeze-the-dead is not listed in isolation_schedule; an easy fix.
I confirm that the test crashes with an assertion failure without the
code fix, and that it doesn't with it.
I think the comparison to OldestXmin should be reversed:
if (!TransactionIdPrecedes(xmax, OldestXmin))
return HEAPTUPLE_RECENTLY_DEAD;
return HEAPTUPLE_DEAD;
This way, an xmax that has exactly the OldestXmin value will return
RECENTLY_DEAD rather DEAD, which seems reasonable to me (since
OldestXmin value itself is supposed to be still possibly visible to
somebody). Also, this way it is consistent with the other comparison to
OldestXmin at the bottom of the function. There is no reason for the
"else" or the extra braces.
Put together, I propose the attached delta for 0001.
Your commit message does a poor job of acknowledging prior work on
diagnosing the problem starting from Dan's initial test case and patch.
I haven't looked at your 0002 yet.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:tweaks.patch (text/plain, 2.0K) downloaddiff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.cindex 8be2980116..aab03835d1 100644--- a/src/backend/utils/time/tqual.c+++ b/src/backend/utils/time/tqual.c@@ -1324,25 +1324,23 @@ HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin,
else if (TransactionIdDidCommit(xmax))
{
/*
- * The multixact might still be running due to lockers. If the- * updater is below the horizon we have to return DEAD regardless- * - otherwise we could end up with a tuple where the updater has- * to be removed due to the horizon, but is not pruned away. It's- * not a problem to prune that tuple because all the lockers will- * also be present in the newer tuple version.+ * The multixact might still be running due to lockers. If the+ * updater is below the xid horizon, we have to return DEAD+ * regardless -- otherwise we could end up with a tuple where the+ * updater has to be removed due to the horizon, but is not pruned+ * away. It's not a problem to prune that tuple, because any+ * remaining lockers will also be present in newer tuple versions.
*/
- if (TransactionIdPrecedes(xmax, OldestXmin))- {- return HEAPTUPLE_DEAD;- }- else+ if (!TransactionIdPrecedes(xmax, OldestXmin))
return HEAPTUPLE_RECENTLY_DEAD;
++ return HEAPTUPLE_DEAD;
}
else if (!MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), false))
{
/*
* Not in Progress, Not Committed, so either Aborted or crashed.
- * Remove the Xmax.+ * Mark the Xmax as invalid.
*/
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID, InvalidTransactionId);
}
diff --git a/src/test/isolation/isolation_schedule b/src/test/isolation/isolation_scheduleindex e41b9164cd..eb566ebb6c 100644--- a/src/test/isolation/isolation_schedule+++ b/src/test/isolation/isolation_schedule@@ -44,6 +44,7 @@ test: update-locked-tuple
test: propagate-lock-delete
test: tuplelock-conflict
test: tuplelock-update
+test: freeze-the-dead
test: nowait
test: nowait-2
test: nowait-3
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: alvherre@2ndQuadrant.com, andres@anarazel.de, hexpert@amazon.com, pg@bowt.ie, yiwong@amazon.com, michael.paquier@gmail.com, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] [COMMITTERS] pgsql: Fix freezing of a dead HOT-updated tuple
In-Reply-To: <20171206162115.kdsd2fnipyswonir@alvherre.pgsql>
References: <20171114030341.movhteyakqeqx5pm@alap3.anarazel.de> <20171206162115.kdsd2fnipyswonir@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox