From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: Bossart, Nathan <bossartn@amazon.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: New vacuum option to do only freezing
Date: Thu, 2 May 2019 12:03:35 -0400
Message-ID: <20190502160335.GA17452@alvherre.pgsql> (raw)
In-Reply-To: <20190501153637.nyleiq67w4lvbo46@alap3.anarazel.de>
On 2019-May-01, Andres Freund wrote:
> Alvaro, could we perhaps clean this up a bit? This is pretty confusing
> looking. I think this probably could just be changed to
>
> bool xmin_frozen = false;
>
> xid = HeapTupleHeaderGetXmin(tuple);
>
> if (xid == FrozenTransactionId)
> xmin_frozen = true;
> else if (TransactionIdIsNormal(xid))
>
> or somesuch. There's no need to check for
> HeapTupleHeaderXminFrozen(tuple) etc, because HeapTupleHeaderGetXmin()
> already does so - and if it didn't, the issue Tom points out would be
> problematic.
Ah, yeah, that's simpler. I would like to introduce a couple of very
minor changes to the proposed style, per the attached.
* don't initialize xmin_frozen at all; rather, only set its value to the
correct one when we have determined what it is. Doing premature
initialization is what led to some of those old bugs, so I prefer not to
do it.
* Handle the BootstrapXid and InvalidXid cases explicitly, by setting
xmin_frozen to true when xmin is not normal. After all, those XID
values do not need any freezing.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:0001-heap_prepare_freeze_tuple-Simplify-coding.patch (text/x-diff, 1.4K) download
From 1cca0581655614703b020facbbf8d64b442f95be Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Thu, 2 May 2019 11:50:18 -0400
Subject: [PATCH] heap_prepare_freeze_tuple: Simplify coding
---
src/backend/access/heap/heapam.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.cindex a05b6a07ad0..d6ceb8fd4a4 100644--- a/src/backend/access/heap/heapam.c+++ b/src/backend/access/heap/heapam.c@@ -6108,9 +6108,9 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
/* Process xmin */
xid = HeapTupleHeaderGetXmin(tuple);
- xmin_frozen = ((xid == FrozenTransactionId) ||- HeapTupleHeaderXminFrozen(tuple));- if (TransactionIdIsNormal(xid))+ if (!TransactionIdIsNormal(xid))+ xmin_frozen = true;+ else
{
if (TransactionIdPrecedes(xid, relfrozenxid))
ereport(ERROR,
@@ -6118,7 +6118,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
errmsg_internal("found xmin %u from before relfrozenxid %u",
xid, relfrozenxid)));
- if (TransactionIdPrecedes(xid, cutoff_xid))+ xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);+ if (xmin_frozen)
{
if (!TransactionIdDidCommit(xid))
ereport(ERROR,
@@ -6128,7 +6129,6 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
- xmin_frozen = true;
}
}
--
2.17.1
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, andres@anarazel.de, tgl@sss.pgh.pa.us, robertmhaas@gmail.com, sawada.mshk@gmail.com, horiguchi.kyotaro@lab.ntt.co.jp, bossartn@amazon.com
Subject: Re: New vacuum option to do only freezing
In-Reply-To: <20190502160335.GA17452@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