Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 78FA3632D64 for ; Fri, 12 Feb 2010 01:38:49 -0400 (AST) 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 32601-02 for ; Fri, 12 Feb 2010 05:38:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yw0-f185.google.com (mail-yw0-f185.google.com [209.85.211.185]) by mail.postgresql.org (Postfix) with ESMTP id 7948C6327C0 for ; Fri, 12 Feb 2010 01:38:35 -0400 (AST) Received: by ywh15 with SMTP id 15so1975410ywh.5 for ; Thu, 11 Feb 2010 21:38:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=8x0R+CJkVnWFipc/DZ2U7veQ7mDoKW844iG3/PNLNfo=; b=tT14KFI1XnnWpt+uNNCigyNqYuNq52V7uEaV0acQmVQkqDAbyp1ylfilGsQNJdNfmg pEg8B4Znjh01/l8t3n7w0Fhe4y6cQJaRAKCJHBK+2BW8I9tFa04NciGZ1s6x+Pn9WE0S IynPxj21aLZ7vadqa2ZGs2fLbrgVYISHNXEy8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=tGjaJMBtTQVzx6v48Se/Q/OAJ6HYsOgh+rRsPrgP2Z69KCJuKGOYVwTn3kDiEJNWUp o99aSafOCs5S6fB5lsp+RofT01HvePYfrXAHyhAdTBO++wjIAot4rGNJJ7HC9N3EwvZr 6Z3192fwFM85phEVYbw+j5kINFZSBSzjbfzg8= MIME-Version: 1.0 Received: by 10.101.195.38 with SMTP id x38mr1327312anp.135.1265953114723; Thu, 11 Feb 2010 21:38:34 -0800 (PST) In-Reply-To: <4B7412BE.5030605@enterprisedb.com> References: <20100127152751.3B2047541B9@cvs.postgresql.org> <4B73F678.8070109@enterprisedb.com> <1265891248.7341.1346.camel@ebony> <4B73FB99.4080403@enterprisedb.com> <1265893599.7341.1454.camel@ebony> <877hqjc2kk.fsf@hi-media-techno.com> <1265896250.7341.1627.camel@ebony> <4B740C6C.3010607@enterprisedb.com> <1265897834.7341.1714.camel@ebony> <4B7412BE.5030605@enterprisedb.com> Date: Fri, 12 Feb 2010 14:38:32 +0900 Message-ID: <3f0b79eb1002112138n61a3258fg9986e50751d44ea0@mail.gmail.com> Subject: Re: Re: [COMMITTERS] pgsql: Make standby server continuously retry restoring the next WAL From: Fujii Masao To: Heikki Linnakangas Cc: Simon Riggs , Dimitri Fontaine , PostgreSQL-development Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.974 tagged_above=-10 required=5 tests=AWL=0.625, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/977 X-Sequence-Number: 157320 On Thu, Feb 11, 2010 at 11:22 PM, Heikki Linnakangas wrote: > Simon Riggs wrote: >> Might it not be simpler to add a parameter onto pg_standby? >> We send %s to tell pg_standby the standby_mode of the server which is >> calling it so it can decide how to act in each case. > > That would work too, but it doesn't seem any simpler to me. On the contrary. Agreed. There could be three kinds of SR configurations. Let's think of them separately. (1) SR without restore_command (2) SR with 'cp' (3) SR with pg_standby (1) is the straightforward configuration. In this case the standby replays only the WAL files in pg_xlog directory, and starts SR when it has found the invalid record or been able to find no more WAL file. Then if SR is terminated for some reasons, the standby would periodically try to connect to the primary and start SR again. If you choose this, you don't need to care about the problem discussed on the thread. In the (2) case the standby replays the WAL files in not only pg_xlog but also the archive, and starts SR when it has found the invalid record or been able to find no more WAL file. If the archive is shared between the primary and the standby, the standby might restore the partial WAL file being archived (copied) by the primary. This could happen because 'cp' is not an atomic operation. Currently when the standby finds the WAL file whose file size is less than 16MB, it emits the FATAL error. This is the problem that I presented upthread. That is undesirable behavior, so I proposed to just treat that case the same as if no more WAL file is found. If so, the standby can start SR instead of emitting the FATAL error. (2) is useful configuration as described in Heikki's commig message. http://archives.postgresql.org/pgsql-committers/2010-01/msg00395.php (3) was unexpected configuration (at least for me). This would work fine as a *file-based* log shipping but not SR. Since pg_standby doesn't return when no more WAL file is found in the archive (i.e., it waits until the next complete WAL file is available), SR will never start. OTOH, since pg_standby treats the partial file as "nonexistence", the problem discussed on this thread doesn't happen. Questions: (A) Is my proposal for (2) reasonable? For me, Yes. (B) Should we allow (3) to work as "streaming replication"? In fact, we should create the new mode that makes pg_standby return as soon as it doesn't find a complete WAL file in the archive? I agree with Heikki, i.e., don't think it's worth doing. Though pg_standby already has the capability to remove the old WAL files, we would still need the cron job that removes them periodically because pg_standby is not executed during SR is running normally. Regards, -- Fujii Masao NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center