Skip site navigation (1) Skip section navigation (2)

Re: heap_tuple_needs_freeze false positive

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: heap_tuple_needs_freeze false positive
Date: 2012-02-02 17:45:40
Message-ID: CA+TgmobdMPQHpc2Swz5giDCeQFNHpfdvyJ_qzcCvpw56LF=QUA@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Thu, Feb 2, 2012 at 11:27 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> I'm not convinced that it's a bug.  Suppose that xmax is set but is
>> hinted as invalid.
>
> XMAX_INVALID is not a "hint".  When it's set, the contents of the field
> must be presumed to be garbage.  Any code failing to adhere to that rule
> is broken.
>
>> We process the table and advanced relfrozenxid;
>> then, we crash.  After recovery, it's possible that the hint bit is
>> gone (after all, setting hint bits isn't WAL-logged).  Now we're in
>> big trouble, because the next CLOG lookup on that xmax value might not
>> happen until it's been reused, and we might get a different answer
>> than before.
>
> I believe we have adequate defenses against that, and even if we did
> not, that doesn't make the code in question less wrong.

I believe the adequate defense that we have is precisely the logic you
are proposing to change.  Regardless of whether you want to call
XMAX_INVALID a hint or, say, a giant tortoise, I am fairly sure that
we don't WAL-log setting it.  That means that a bit set before a crash
won't necessarily still be set after a crash.  But the corresponding
relfrozenxid advancement will be WAL-logged, leading to the problem
scenario I described.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

pgsql-hackers by date

Next:From: Gilles DaroldDate: 2012-02-02 17:47:35
Subject: Re: Patch pg_is_in_backup()
Previous:From: Pavel StehuleDate: 2012-02-02 17:20:26
Subject: Re: JSON output functions.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group