Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 3C4E4633C5A for ; Wed, 30 Sep 2009 12:46:07 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 35076-06 for ; Wed, 30 Sep 2009 15:45:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og111.obsmtp.com (exprod7og111.obsmtp.com [64.18.2.175]) by mail.postgresql.org (Postfix) with SMTP id CF8BC63397A for ; Wed, 30 Sep 2009 12:45:55 -0300 (ADT) Received: from source ([209.85.219.209]) by exprod7ob111.postini.com ([64.18.6.12]) with SMTP ID DSNKSsN9Ms3YZqZX04iL76cRwCValCzcc6qP@postini.com; Wed, 30 Sep 2009 08:45:56 PDT Received: by ewy5 with SMTP id 5so500202ewy.12 for ; Wed, 30 Sep 2009 08:45:54 -0700 (PDT) Received: by 10.211.161.39 with SMTP id n39mr7043519ebo.29.1254325553698; Wed, 30 Sep 2009 08:45:53 -0700 (PDT) Received: from ?192.168.1.117? (dsl-hkibrasgw2-ff67c300-165.dhcp.inet.fi [88.195.103.165]) by mx.google.com with ESMTPS id 10sm202160eyz.18.2009.09.30.08.45.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 30 Sep 2009 08:45:51 -0700 (PDT) Message-ID: <4AC37D2D.9060400@enterprisedb.com> Date: Wed, 30 Sep 2009 18:45:49 +0300 From: Heikki Linnakangas Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Simon Riggs CC: pgsql-hackers Subject: Re: Hot Standby on git References: <1253958559.4449.833.camel@ebony.2ndQuadrant> In-Reply-To: <1253958559.4449.833.camel@ebony.2ndQuadrant> 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=-2.432 tagged_above=-10 required=5 tests=AWL=0.167, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/1942 X-Sequence-Number: 146748 Regarding this in InitStandbyDelayTimers: + /* + * If replication delay is enormously huge, just treat that as + * zero and work up from there. This prevents us from acting + * foolishly when replaying old log files. + */ + if (*currentDelay_ms < 0) + *currentDelay_ms = 0; + So we're treating restoring from an old backup the same as an up-to-date standby server. If you're restoring from say a month old base backup with WAL archive up to present day, and have max_standby_delay set to say 5 seconds, the server will wait for that 5 seconds on each conflicting query before killing it. Until it reaches the point in the archive where the delay is less than INT_MAX/1000 seconds old: at that point it switches into "oh my goodness, we've fallen badly behind, let's try to catch up ASAP and kill any queries that get into the way" mode. That's pretty surprising behavior, and not documented either. I propose we simply remove the above check (fixing the rest of the code so that you don't hit integer overflows), and always respect max_standby_delay. BTW, I wonder if should warn or something if we find that the timestamps in the archive are in the future? IOW, if either the master's or the standby's clock is not set correctly. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com