pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: levertond@googlemail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #8273: Assertion failure in 9.3 beta2 with serializable and savepoints
Date: Fri, 19 Jul 2013 13:46:44 -0400
Message-ID: <20130719174644.GE4130@eldon.alvh.no-ip.org> (raw)
In-Reply-To: <E1UtbZu-0007xx-MH@wrigleys.postgresql.org>
References: <E1UtbZu-0007xx-MH@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

levertond@googlemail.com wrote:

> START TRANSACTION ISOLATION LEVEL SERIALIZABLE;
> CREATE TABLE testing(
>   x INTEGER PRIMARY KEY
> );
> INSERT INTO testing VALUES(1);
> SELECT * FROM testing WHERE x = 1 FOR UPDATE;
> SAVEPOINT test;
> UPDATE testing SET x = 2 WHERE x = 1;
> ROLLBACK TO test;
> UPDATE testing SET x = 3 WHERE x = 1;
> ROLLBACK;

Thanks for the test case.  This one-liner patch fixes it:

inline patch 1: src/backend/utils/time/tqual.c (+1/-1 lines) download inline-1.patchdiff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index 55563ea..fa9c9d7 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -1287,7 +1287,7 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin, { if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */ return HEAPTUPLE_INSERT_IN_PROGRESS; - if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask)) + if (HeapTupleHeaderIsOnlyLocked(tuple)) return HEAPTUPLE_INSERT_IN_PROGRESS; /* inserted and then deleted by same xact */ return HEAPTUPLE_DELETE_IN_PROGRESS;
That is, I was taking a shortcut here by checking only the infomask bits about locking, and not resolving the MultiXact to see if the updater (sub)transaction was aborted; but this was wrong, because a tuple which was created here and updated by an aborted subxact needs to be seen as in-progress insertion, not an in-progress delete. This causes trouble to the predicate.c code because it tries to obtain the update XID for the tuple, but since the update has aborted, that returned zero, causing the assert failure. Sadly, this has performance implications, because what previously was just an in-place check of bit flags has now become a function call. Perhaps it'd be smart to optimize it a bit so that we first check the flags, and only call the function if that fails. Before pushing this patch, I'm going to examine the other users of HEAP_XMAX_IS_LOCKED_ONLY to ensure they don't also need the same change. I think some of them were prepared for the possibility that there were aborted updaters; but this was a late addition so perhaps I missed others that aren't. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs

view thread (7+ messages)  latest in thread

Message-ID: <20130719174644.GE4130@eldon.alvh.no-ip.org>
Permalink:  ../20130719174644.GE4130@eldon.alvh.no-ip.org/
Also on:    postgresql.org/message-id/20130719174644.GE4130@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 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-bugs@postgresql.org
  Cc: alvherre@2ndquadrant.com, levertond@googlemail.com
  Subject: Re: BUG #8273: Assertion failure in 9.3 beta2 with serializable and savepoints
  In-Reply-To: <20130719174644.GE4130@eldon.alvh.no-ip.org>
  References: <E1UtbZu-0007xx-MH@wrigleys.postgresql.org> <20130719174644.GE4130@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