Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8331F1337B5D for ; Tue, 8 Mar 2011 07:22:35 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 88681-03 for ; Tue, 8 Mar 2011 11:22:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og125.obsmtp.com (exprod7og125.obsmtp.com [64.18.2.28]) by mail.postgresql.org (Postfix) with ESMTP id 56DF7133798E for ; Tue, 8 Mar 2011 07:22:24 -0400 (AST) Received: from source ([209.85.215.182]) (using TLSv1) by exprod7ob125.postini.com ([64.18.6.12]) with SMTP ID DSNKTXYRb+erumZYJ3Pny40dbvToFnqPrHJg@postini.com; Tue, 08 Mar 2011 03:22:25 PST Received: by mail-ey0-f182.google.com with SMTP id 7so3369303eyg.27 for ; Tue, 08 Mar 2011 03:22:23 -0800 (PST) Received: by 10.213.19.11 with SMTP id y11mr3465648eba.97.1299583343433; Tue, 08 Mar 2011 03:22:23 -0800 (PST) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id t5sm537553eeh.14.2011.03.08.03.22.21 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Mar 2011 03:22:22 -0800 (PST) Message-ID: <4D76116C.5050506@enterprisedb.com> Date: Tue, 08 Mar 2011 13:22:20 +0200 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.1.16) Gecko/20101226 Icedove/3.0.11 MIME-Version: 1.0 To: YAMAMOTO Takashi CC: pgsql-bugs@postgresql.org, Kevin Grittner , Dan Ports Subject: Re: BUG #5918: SummarizeOldestCommittedSxact assertion failure References: <201103080037.p280be6k064829@wwwmaster.postgresql.org> In-Reply-To: <201103080037.p280be6k064829@wwwmaster.postgresql.org> Content-Type: multipart/mixed; boundary="------------010901000409060800030605" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201103/147 X-Sequence-Number: 29657 This is a multi-part message in MIME format. --------------010901000409060800030605 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 08.03.2011 02:37, YAMAMOTO Takashi wrote: > > The following bug has been logged online: > > Bug reference: 5918 > Logged by: YAMAMOTO Takashi > Email address: yamt@mwd.biglobe.ne.jp > PostgreSQL version: 9.1devel > Operating system: NetBSD > Description: SummarizeOldestCommittedSxact assertion failure > Details: > > running 05d93c38a791836eeceaf8edb0ea8cb19cdf2760 with my patch > in BUG #5915 applied, i got the following assertion failure. > given that availableList is not empty and SxactGlobalXminCount == 0, > i guess it was raced with ReleasePredicateLocks. Yeah, that's what it looks like. One backend calls RegisterSerializableTransaction() while all the serializablexact slots are in use. So it releases SerializableXactHashLock and calls SummarizeOldestCommittedSxact(). Before SummarizeOldestCommittedSxact() acquires SerializableFinishedListLock, another backend calls ReleasePredicateLocks(false), triggering cleanup of old predicate locks, and ClearOldPredicateLocks() clears all old locks. Now when SummarizeOldestCommittedSxact() finally gets the lock, it sees that there are no old transactions to summarize, and trips the assertion. I think we need to just treat an empty list as normal in SummarizeOldestcommittedSxact(), patch attached. Thanks for yet another excellent bug report! -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com --------------010901000409060800030605 Content-Type: text/x-diff; name="empty-list-is-ok-in-summarize.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="empty-list-is-ok-in-summarize.patch" diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 700c0db..a8af31e 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -1301,15 +1301,21 @@ SummarizeOldestCommittedSxact(void) LWLockAcquire(SerializableFinishedListLock, LW_EXCLUSIVE); -#ifdef TEST_OLDSERXID + /* + * This function is only called if there are no sxact slots available. + * Some of them must belong to old, already-finished transactions, so + * there should be something in FinishedSerializableTransactions list + * that we can summarize. However, there's a race condition: while we + * were not holding any locks, a transaction might have ended and cleaned + * up all the finished sxact entries already, freeing up their sxact + * slots. In that case, we have nothing to do here. The caller will find + * one of the slots released by the other backend when it retries. + */ if (SHMQueueEmpty(FinishedSerializableTransactions)) { LWLockRelease(SerializableFinishedListLock); return; } -#else - Assert(!SHMQueueEmpty(FinishedSerializableTransactions)); -#endif /* * Grab the first sxact off the finished list -- this will be the earliest --------------010901000409060800030605--