Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id EE215633A1F for ; Mon, 19 Apr 2010 11:44:44 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 58756-02-4 for ; Mon, 19 Apr 2010 14:44:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og118.obsmtp.com (exprod7og118.obsmtp.com [64.18.2.8]) by mail.postgresql.org (Postfix) with SMTP id ACCAA633D7B for ; Mon, 19 Apr 2010 11:44:17 -0300 (ADT) Received: from source ([209.85.218.221]) by exprod7ob118.postini.com ([64.18.6.12]) with SMTP ID DSNKS8xsOzIwOZX+BrjxeDKNh1AblLH7laFB@postini.com; Mon, 19 Apr 2010 07:44:16 PDT Received: by mail-bw0-f221.google.com with SMTP id 21so4375732bwz.35 for ; Mon, 19 Apr 2010 07:44:11 -0700 (PDT) Received: by 10.87.9.11 with SMTP id m11mr4183407fgi.73.1271688251298; Mon, 19 Apr 2010 07:44:11 -0700 (PDT) Received: from [192.168.1.105] (cs78239129.pp.htv.fi [62.78.239.129]) by mx.google.com with ESMTPS id 12sm4520564fgg.4.2010.04.19.07.44.08 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 19 Apr 2010 07:44:10 -0700 (PDT) Message-ID: <4BCC6C37.9090703@enterprisedb.com> Date: Mon, 19 Apr 2010 17:44:07 +0300 From: Heikki Linnakangas Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706) MIME-Version: 1.0 To: Simon Riggs CC: Tom Lane , Robert Haas , pgsql-hackers@postgresql.org Subject: Re: Re: [COMMITTERS] pgsql: Tune GetSnapshotData() during Hot Standby by avoiding loop References: <20100418180608.16F067541D1@cvs.postgresql.org> <4BCC07F1.6040405@enterprisedb.com> <1271664332.8305.17430.camel@ebony> <4BCC1644.70008@enterprisedb.com> <1271667922.8305.17650.camel@ebony> <13439.1271687068@sss.pgh.pa.us> <1271687489.8305.18879.camel@ebony> In-Reply-To: <1271687489.8305.18879.camel@ebony> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201004/810 X-Sequence-Number: 160922 Simon Riggs wrote: > On Mon, 2010-04-19 at 10:24 -0400, Tom Lane wrote: >> Robert Haas writes: >>> On Mon, Apr 19, 2010 at 5:05 AM, Simon Riggs wrote: >>>> It doesn't seem to be something we should place highly on the list of >>>> events we need protection from, does it? >>> Since when do we not protect against race-conditions just because >>> they're low likelihood? >> Murphy's law says that the probability of any race condition happening >> in the field is orders of magnitude higher than you think. This has >> been proven true many times ... Right. And some future code changes elsewhere could make it more likely, by the time we've forgotten all about this. > Choices are > > 1. Check RecoveryInProgress() once outside of lock, plus wild rumour of > Murphy > > 2. Check RecoveryInProgress() before and after holding lock > > 3. Check RecoveryInProgress() while holding lock 4. Check RecoveryInProgress() once outside of lock, and scan the ProcArray anyway, just in case. That's what we did before this patch. Document that takenDuringRecovery == true means that the snapshot was most likely taken during recovery, but there is some race conditions where takenDuringRecovery is true even though the snapshot was taken just after recovery finished. AFAICS all of the other current uses of takenDuringRecovery work fine with that. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com