Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 1441637BA28; Sun, 28 Sep 2008 22:16:21 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 83330-07; Sun, 28 Sep 2008 22:16:17 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 29C6E37B9B3; Sun, 28 Sep 2008 22:16:18 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m8T1G15m022857; Sun, 28 Sep 2008 21:16:01 -0400 (EDT) To: Simon Riggs cc: List pgsql-patches , pgsql-hackers Subject: Re: [PATCHES] Infrastructure changes for recovery In-reply-to: <1222649659.4445.1061.camel@ebony.2ndQuadrant> References: <1218109459.4549.423.camel@ebony.2ndQuadrant> <1220213074.4371.173.camel@ebony.2ndQuadrant> <1905.1220895241@sss.pgh.pa.us> <1221080797.3913.768.camel@ebony.2ndQuadrant> <15776.1221594318@sss.pgh.pa.us> <1221725145.3913.2315.camel@ebony.2ndQuadrant> <16992.1221743196@sss.pgh.pa.us> <1221745847.3913.2408.camel@ebony.2ndQuadrant> <18549.1221746983@sss.pgh.pa.us> <1222121161.4445.248.camel@ebony.2ndQuadrant> <1222184541.4445.400.camel@ebony.2ndQuadrant> <28973.1222381719@sss.pgh.pa.us> <1222424415.4445.917.camel@ebony.2ndQuadrant> <9794.1222624945@sss.pgh.pa.us> <1222649659.4445.1061.camel@ebony.2ndQuadrant> Comments: In-reply-to Simon Riggs message dated "Mon, 29 Sep 2008 01:54:19 +0100" Date: Sun, 28 Sep 2008 21:16:01 -0400 Message-ID: <22856.1222650961@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/1777 X-Sequence-Number: 124906 Simon Riggs writes: >> It does nothing AFAICS for the >> problem that when restarting archive recovery from a restartpoint, >> it's not clear when it is safe to start letting in backends. You need >> to get past the highest LSN that has made it out to disk, and there is >> no good way to know what that is. > AFAICS when we set minRecoveryLoc we *never* unset it. It's recorded in > the controlfile, so whenever we restart we can see that it has been set > previously and now we are beyond it. Right ... > So if we crash during recovery and > then restart *after* we reached minRecoveryLoc then we resume in safe > mode almost immediately. Wrong. What minRecoveryLoc is is an upper bound for the LSNs that might be on-disk in the filesystem backup that an archive recovery starts from. (Defined as such, it never changes during a restartpoint crash/restart.) Once you pass that, the on-disk state as modified by any dirty buffers inside the recovery process represents a consistent database state. However, the on-disk state alone is not guaranteed consistent. As you flush some (not all) of your shared buffers you enter other not-certainly-consistent on-disk states. If we crash in such a state, we know how to use the last restartpoint plus WAL replay to recover to another state in which disk + dirty buffers are consistent. However, we reach such a state only when we have read WAL to beyond the highest LSN that has reached disk --- and in recovery mode there is no clean way to determine what that was. Perhaps a solution is to make XLogFLush not be a no-op in recovery mode, but have it scribble a highest-LSN somewhere on stable storage (maybe scribble on pg_control itself, or maybe better someplace else). I'm not totally sure about that. But I am sure that doing nothing will be unreliable. regards, tom lane