Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 88354650109 for ; Mon, 8 Sep 2008 15:02:07 -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 78789-02-3 for ; Mon, 8 Sep 2008 15:01:59 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail137186.authsmtp.net (outmail137186.authsmtp.net [62.13.137.186]) by postgresql.org (Postfix) with ESMTP id 8EF486500D5 for ; Mon, 8 Sep 2008 15:01:49 -0300 (ADT) Received: from punt9.authsmtp.com (punt9.authsmtp.com [62.13.128.70]) by punt5.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m88I1l2n058833 for ; Mon, 8 Sep 2008 19:01:47 +0100 (BST) Received: from mail-c187.authsmtp.com (mail-c187.authsmtp.com [62.13.128.33]) by punt9.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m88I1kwg077495; Mon, 8 Sep 2008 19:01:46 +0100 (BST) Received: from [192.168.0.2] (85-211-229-97.dyn.gotadsl.co.uk [85.211.229.97]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m88I1iAM078158; Mon, 8 Sep 2008 19:01:44 +0100 (BST) Subject: Re: [HACKERS] Infrastructure changes for recovery From: Simon Riggs To: Tom Lane Cc: List pgsql-patches In-Reply-To: <1905.1220895241@sss.pgh.pa.us> References: <1218109459.4549.423.camel@ebony.2ndQuadrant> <1220213074.4371.173.camel@ebony.2ndQuadrant> <1905.1220895241@sss.pgh.pa.us> Content-Type: text/plain Date: Mon, 08 Sep 2008 19:01:50 +0100 Message-Id: <1220896910.3913.242.camel@ebony.2ndQuadrant> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: 33021ae1-7dd0-11dd-8155-001185d377ca X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadBtFaA1bflxB HGQLW1xEUVR7WWJ/ bw8fZQBDYEtPQQdo WVZARU1QEQdtHhxP WxYWKxgrBnhGf3Zx YE4sWnJbWwp5dkZ/ Qx8BFHABMTNgdWEe BBRFfwJRdR5Kfh5E YlUrV3QKMjRJBC9q VzwLFgwaHRhkHWxm YigmDn8oenNDPzgy XRkZAS8yFlEYXSh7 JBwvLFERBw4fNV96 K1YqXkwVKQ56 X-Authentic-SMTP: 61633235383639.squirrel.dmpriest.net.uk:1186/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! 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/95 X-Sequence-Number: 7110 On Mon, 2008-09-08 at 13:34 -0400, Tom Lane wrote: > Simon Riggs writes: > > Included patch with the following changes: > > > * new postmaster mode known as consistent recovery, entered only when > > recovery passes safe/consistent point. InRedo is now set in all > > processes when started/connected in consistent recovery mode. > > I looked at this and didn't like the InRedo signaling at all. In the > first place, it looks like you're expecting the flag to be passed down > via fork(), but that won't work in EXEC_BACKEND mode. (Yes, easily > fixed, but it's wrong as-is.) OK, thanks. I didn't check that. > In the second place, the method of > signaling it to the bgwriter looks to have race conditions: in > principle, at least, I think the startup process could try to clear > the shared-memory InRedo flag before the bgwriter has gotten as far as > setting it. (This might work if the startup process can't exit redo > mode without the bgwriter having finished a checkpoint, but such a > dependency is too rube goldbergian for me.) We never interrupt what the bgwriter does. If it is in the middle of doing a checkpoint when recovery finishes, then Startup process just waits behind it and then issues a shutdown checkpoint. If there's loads of blocks to be written it doesn't matter who writes them. There's only one soup spoon, and it doesn't matter who stirs the soup. > ISTM that it would probably be better if there were exactly one InRedo > flag in shared memory, probably in xlog.c's shared state, with the > postmaster not being responsible for setting or clearing it; rather > the startup process should do those things. So replace InRedo with an IsInRedo() function that accesses XLogCtl? Sounds good > > * bgwriter and stats process starts in consistent recovery mode. > > bgwriter changes mode when startup process completes. > > I'm not sure about the interaction of this. In particular, what about > recovery restart points before we have reached the safe stop point? > I don't think we want to give up the capability of having those. Maybe. I felt it made the code cleaner to give that up. Realistically its a fairly short window of time. But shouldn't be too hard to put back. > Also, it seems pretty bogus to update the in-memory ControlFile > checkpoint values before the restart point is actually done. It looks > to me like what you have done is to try to use those fields as signaling > for the restart request in addition to their existing purposes, which > I think is confusing and probably dangerous. I'd rather there were a > different signaling path and ControlFile maintains its currrent > definition. OK > I found the changes in bgwriter.c unreadable. You've evidently > moved blocks of code around, but exactly what did you mean to > change? Why is there so much duplicated code now? The patch utility did that. Some code reuse confused it. It's real easy to read though if you apply the patch and then read the main loop. You'll see what I mean. > > I've kept the distinction between restartpoints and checkpoints in > > code, to avoid convoluted code. > > Hmm, I dunno, it seems like that might be a bad choice. Are you sure > it's not cleaner to just use the regular checkpoint code? When I tried to write it, it just looked to my eyes like every single line had a caveat which looked ugly and multiplied the testing. You're the code dude, always happy to structure things as you suggest. If you're sure, that is. Thanks for the review. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support