Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id ACCEC37BA28 for ; Wed, 8 Oct 2008 09:23:20 -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 20097-01 for ; Wed, 8 Oct 2008 09:23:11 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail136033.authsmtp.net (outmail136033.authsmtp.net [62.13.136.33]) by postgresql.org (Postfix) with ESMTP id 0791037B9FD for ; Wed, 8 Oct 2008 09:23:11 -0300 (ADT) Received: from mail-c193.authsmtp.com (mail-c193.authsmtp.com [62.13.128.118]) by punt3.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m98CMa4s007942; Wed, 8 Oct 2008 13:22:36 +0100 (BST) Received: from [192.168.0.3] (85-211-69-124.dyn.gotadsl.co.uk [85.211.69.124]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m98CMZDH052321; Wed, 8 Oct 2008 13:22:35 +0100 (BST) Subject: Re: [PATCHES] Infrastructure changes for recovery (v8) From: Simon Riggs To: Heikki Linnakangas Cc: pgsql-hackers In-Reply-To: <48EC9CC5.6060803@enterprisedb.com> References: <1222815151.4445.1397.camel@ebony.2ndQuadrant> <48EC9CC5.6060803@enterprisedb.com> Content-Type: text/plain Date: Wed, 08 Oct 2008 13:24:20 +0100 Message-Id: <1223468660.4747.294.camel@ebony.2ndQuadrant> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: ca2bc80e-9533-11dd-8a51-002264978518 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadBtFaA1bYlpF HGQLW1xEUV57W2F/ aA8fZQBDYEtPQQNj TklLRk1QEQdtHhxP WxcWIWQYA31GfXxz Z0csWnJTXQopJEQv EUZUQHAPYGRjdWEe BBRFf1JRcR5Kfh1H bFR2U3sIYG1JBC9q VzwLFgwaHRhkHWx0 RA8XJEkOW1sAAiMm SlgJHTwpEkAeDys0 NVQ8J1UbAksLIw1y LwtgMWVf X-Authentic-SMTP: 61633235383639.pelican.dmpriest.net.uk:1378/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: 200810/307 X-Sequence-Number: 125324 On Wed, 2008-10-08 at 14:43 +0300, Heikki Linnakangas wrote: > Simon Riggs wrote: > > * optional recovery_safe_start_location parameter now provided in > > recovery.conf, to allow a consistency point to be manually defined if a > > base backup was not taken using standard pg_start/stop backup functions > > Do we want to cater for that? It only seems safe if you have > full_page_writes turned on, and you perform a checkpoint first. But if > you do that, why don't you just use pg_start_backup()? I'm easy on that one. It is a supported backup method, so without this it would not be possible to utilise Hot Standby in conjunction with this backup technique. Not many people use it, but I guess some do. > > Other Changes > > * log_restartpoints removed, use log_checkpoints in postgresql.conf > > Is this something that would make sense regardless of the rest of the > patch? If so, we could apply that separately, which would make this > patch a little less overwhelming to review. Maybe, it's fairly minor. > > * additional function signature for pg_start_backup('label', true | > > false) to allow definition of immediate checkpoint/not > > Wouldn't this need a new entry in pg_proc.h? Again, perhaps we should do > this as a separate patch. That's concerning. I remember adding the entry and assigning a new oid, but it isn't in the patch. The multi-argument version was definitely tested, that's how I discovered the bug also fixed in the patch. > > * fixes bug discovered while other testing: if pg_stop_backup() is run > > when xlogswitch has just occurred then we do not switch log files, yet > > we return current filename even though nothing of value in it. If > > archive_timeout not enabled we would wait forever for pg_stop_backup() > > to return. OK, I'll strip all of the above out, for separate consideration. > > * Substantial comments throughout > > These comments on CheckPointLock seem contradictory: > > > --- 247,256 ---- > > * ControlFileLock: must be held to read/update control file or create > > * new log file. > > * > > ! * CheckpointLock: must be held to do a checkpoint or restartpoint, ensuring > > ! * we get just one of those at any time. In 8.4+ recovery, both startup and > > ! * bgwriter processes may take restartpoints, so this locking must be strict > > ! * to ensure there are no mistakes. > > * > > *---------- > > */ > > and > > > --- 5901,5916 ---- > > XLogRecPtr recptr; > > XLogCtlInsert *Insert = &XLogCtl->Insert; > > XLogRecData rdata; > > uint32 _logId; > > uint32 _logSeg; > > TransactionId *inCommitXids; > > int nInCommit; > > + bool leavingArchiveRecovery = false; > > > > /* > > * Acquire CheckpointLock to ensure only one checkpoint happens at a time. > > ! * That shouldn't be happening, but checkpoints are an important aspect > > ! * of our resilience, so we take no chances. > > */ > > LWLockAcquire(CheckpointLock, LW_EXCLUSIVE); > > > > If I've understood the patch correctly, only bgwriter does checkpoints > and restart points now? Tom requested that we retain the ability for Startup process to perform restartpoints up until the point that bgwriter spawns, then after that bgwriter performs them. The form is this PM_START startup process performs restartpoints transition when database is consistent state PM_RECOVERY bgwriter process performs restartpoints delicate transition between two states PM_RUN bgwriter process performs checkpoints > There's a trivial merge conflict in bgwriter.c, due to the FSM patch. OK, will look. Thanks for looking. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support