pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Andres Freund <andres@2ndquadrant.com>
Cc: Stephen Frost <sfrost@snowman.net>
Cc: pgsql-hackers@postgresql.org
Subject: Re: MultiXactId error after upgrade to 9.3.4
Date: Wed, 23 Apr 2014 15:01:02 -0300
Message-ID: <20140423180102.GP25695@eldon.alvh.no-ip.org> (raw)
In-Reply-To: <20140331115713.GA18358@alap3.anarazel.de>
References: <20140330040029.GY4582@tamriel.snowman.net>
	<20140330141135.GA4582@tamriel.snowman.net>
	<20140330185349.GD4582@tamriel.snowman.net>
	<20140331115452.GT9567@eldon.alvh.no-ip.org>
	<20140331115713.GA18358@alap3.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Andres Freund wrote:
> On 2014-03-31 08:54:53 -0300, Alvaro Herrera wrote:
> > My conclusion here is that some part of the code is failing to examine
> > XMAX_INVALID before looking at the value stored in xmax itself.  There
> > ought to be a short-circuit.  Fortunately, this bug should be pretty
> > harmless.
> > 
> > .. and after looking, I'm fairly sure the bug is in
> > heap_tuple_needs_freeze.
> 
> heap_tuple_needs_freeze() isn't *allowed* to look at
> XMAX_INVALID. Otherwise it could miss freezing something still visible
> on a standby or after an eventual crash.

I think what we should do here is that if we see that XMAX_INVALID is
set, we just reset everything to zero without checking the multixact
contents.  Something like the attached (warning: hand-edited, line
numbers might be bogus)

I still don't know under what circumstances this situation could arise.
This seems most strange to me.  I would wonder about this to be just
papering over a different bug elsewhere, except that we know this tuple
comes from a pg_upgraded table and so I think the only real solution is
to cope.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

  [text/x-diff] no-freeze-invalid-multi.patch (606B, ../20140423180102.GP25695@eldon.alvh.no-ip.org/2-no-freeze-invalid-multi.patch)
  download | inline diff:
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 9283b70..72602fd 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5585,7 +5602,12 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple, TransactionId cutoff_xid,
 	 */
 	xid = HeapTupleHeaderGetRawXmax(tuple);
 
-	if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
+	if ((tuple->t_infomask & HEAP_XMAX_IS_MULTI) &&
+		(tuple->t_infomask & HEAP_XMAX_INVALID))
+	{
+		freeze_xmax = true;
+	}
+	else if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
 	{
 		TransactionId newxmax;
 		uint16		flags;

view thread (40+ messages)  latest in thread

Message-ID: <20140423180102.GP25695@eldon.alvh.no-ip.org>
Permalink:  ../20140423180102.GP25695@eldon.alvh.no-ip.org/
Also on:    postgresql.org/message-id/20140423180102.GP25695@eldon.alvh.no-ip.org

 ·  · 

reply

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@2ndquadrant.com, sfrost@snowman.net
  Subject: Re: MultiXactId error after upgrade to 9.3.4
  In-Reply-To: <20140423180102.GP25695@eldon.alvh.no-ip.org>

* 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