Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 0F409B5DBE6 for ; Tue, 5 Jul 2011 15:01:33 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 20227-10 for ; Tue, 5 Jul 2011 18:01:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og101.obsmtp.com (exprod7og101.obsmtp.com [64.18.2.155]) by mail.postgresql.org (Postfix) with ESMTP id ACAACB5DBE2 for ; Tue, 5 Jul 2011 15:01:25 -0300 (ADT) Received: from mail-fx0-f54.google.com ([209.85.161.54]) (using TLSv1) by exprod7ob101.postini.com ([64.18.6.12]) with SMTP ID DSNKThNRdCrFv/yks3u7gO6oFoFPbAWWOp2y@postini.com; Tue, 05 Jul 2011 11:01:26 PDT Received: by fxe4 with SMTP id 4so6118577fxe.13 for ; Tue, 05 Jul 2011 11:01:22 -0700 (PDT) Received: by 10.223.21.219 with SMTP id k27mr5147733fab.54.1309888882737; Tue, 05 Jul 2011 11:01:22 -0700 (PDT) Received: from [90.190.247.247] (247.247.190.90.dyn.estpak.ee [90.190.247.247]) by mx.google.com with ESMTPS id h28sm5453102faj.29.2011.07.05.11.01.20 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jul 2011 11:01:21 -0700 (PDT) Message-ID: <4E13516F.50301@enterprisedb.com> Date: Tue, 05 Jul 2011 21:01:19 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.17) Gecko/20110606 Icedove/3.1.10 MIME-Version: 1.0 To: Kevin Grittner CC: pgsql-hackers@postgresql.org Subject: Re: SSI atomic commit References: <4E12FDA8020000250003EFC1@gw.wicourts.gov> In-Reply-To: <4E12FDA8020000250003EFC1@gw.wicourts.gov> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 201107/218 X-Sequence-Number: 191317 On 05.07.2011 20:03, Kevin Grittner wrote: > In reviewing the 2PC changes mentioned in a separate post, both Dan > and I realized that these were dependent on the assumption that > SSI's commitSeqNo is assigned in the order in which the transactions > became visible. There is a race condition such that this is not > necessarily true. It is a very narrow race condition, which would > come up very rarely in practice, but Murphy's Law being what it is, > I think we need to consider it a bug and fix it. > > We considered a fix which would be contained within predicate.c code > and operate by making pessimistic assumptions, so that no false > negatives occurred. The reason we didn't go that way is that the > code would be very convoluted and fragile. The attached patch just > makes it atomic in a very direct way, and adjusts the predicate.c > code to use the right tests in the right places. We were careful > not to add any LW locking to the path that a normal transaction > without an XID is terminating, since there had obviously been > significant work put into keeping locks out of that code path. Hmm, I think it would be simpler to decide that instead of SerializableXactHashLock, you must hold ProcArrayLock to access LastSxactCommitSeqNo, and move the assignment of commitSeqNo to ProcArrayTransaction(). It's probably easiest to move LastSxactCommitSeqno to ShmemVariableCache too. There's a few places that would then need to acquire ProcArrayLock to read LastSxactCommitSeqno, but I feel it might still be much simpler that way. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com