Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gcTR9-0001gC-HE for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Dec 2018 11:02:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gcTR8-0000BV-6k for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Dec 2018 11:02:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gcTR7-0000BO-4d for pgsql-hackers@lists.postgresql.org; Thu, 27 Dec 2018 11:02:46 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gcTR1-0005nq-Je for pgsql-hackers@postgresql.org; Thu, 27 Dec 2018 11:02:44 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id B4B5F221DB; Thu, 27 Dec 2018 06:02:37 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Thu, 27 Dec 2018 06:02:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=evb2WB Jx84u1f9FHyMEN/VEO4oA7XZ6v5KMGVOZfHZ0=; b=YxPgEAUhktl8ydDZoV+l8U oXK4SdjtRCep4c8pRViU9r+MhPLVLS0dJDO5hnpslYzAXT9jCNsXz0G0aYtOi+r0 8pdfueCboRlurhsBiIc4V3QN01K5TSb+0ZHCKUbTZMZCxGttuskMB6E0Ep6UHZ2o pzjiM5iN53aXdb0LFtxMneZuHGFD+P2Tay6miZGWojpwc6+B8cdtdPAusBQ/nc9c gAqHsAYIds167hi4TJE6HZvBRbv4AYvqn383VJpGEe4rY1Kly0g7LZ3z82wWjnlO Ea/g2+t4XZHyxelfsegHIsfl0K1svPRuENGAnzWO6zlFz1qL9H0Y7bxiJW74+5Rg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrtddvgddvfeculddtuddrgedtkedrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhohfkffgfgggjtgesmhdtreertdefheenucfhrhhomheprfgvthgv rhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdrvghishgvnhhtrhgruhhtsedvnhguqh hurggurhgrnhhtrdgtohhmqeenucffohhmrghinhepvdhnughquhgrughrrghnthdrtgho mhenucfkphepleefrddvgeefrdduudelrddvfeelnecurfgrrhgrmhepmhgrihhlfhhroh hmpehpvghtvghrrdgvihhsvghnthhrrghuthesvdhnughquhgrughrrghnthdrtghomhen ucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from april.pezone.net (p5df377ef.dip0.t-ipconnect.de [93.243.119.239]) by mail.messagingengine.com (Postfix) with ESMTPA id 3EEC2E4596; Thu, 27 Dec 2018 06:02:35 -0500 (EST) Subject: Re: could recovery_target_timeline=latest be the default in standby mode? To: Michael Paquier , Sergei Kornilov References: <6dd2c23a-4162-8469-410f-bfe146e28c0c@2ndquadrant.com> <7495701545389660@sas1-87f9feb8d943.qloud-c.yandex.net> <20181221233819.GE1948@paquier.xyz> Cc: pgsql-hackers From: Peter Eisentraut Openpgp: preference=signencrypt Autocrypt: addr=peter.eisentraut@2ndquadrant.com; prefer-encrypt=mutual; keydata= xsFNBFUUt6kBEADZd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V8ueSznXBG5+dyfOsZFRPxceA0wA2rSWZSjxLdKxvyGTj9vsCjaDu13rABEBAAHCwV8E GAEIAAkFAlUUt6kCGwwACgkQoZ8SQ+xBJp+HJhAAxmSTsC5y7p9Zu+nnLpucv/h88oEx985e qWeXzQiwM3pfRZS+PdTH9TyzHK0KOgKoAiubk0vt+BrT91D9d0G5kVQaTctAErGBoMkTaZJT XVEcNphiPzysdSqvprjojMp1y7rG8AP+Xd6m0rE1LRnkRRm8HyI8vdXsuLQPITGWXDLMjaNq AOV3BUnzkgtjMuIYw7SCr+12ZOb5dEKvaG4kjC4kaJ/TLbuBhVANcXkC90yp0AOZLs/cB1Dj OAXno/RUUruJ3r27a+pFv768UAi9QWcdw58yPxreMNMLqAgsS9oTHwHfGNWcB2dJ4UW+GMLJ hTf9TjQ2f+N/sIx5XMQ9pYw6CAJMK29qPx6/ZayrPxf22EXf0D3zTwIEZgwfSkynFVwV25L7 awQq60fifdMYheSxq7GbhpsixmcD+e161cCmLIt75YDt5bQ0B1yf7EmxG8n7pGZAOM6LoNsU fkSldba5XVwh8LuN5mK0nQBELGW6Os4TDq4REggLpfcvFC215zpuo0iCGnmE/Bns4nowqUSP u4tkWL+nxW4qgv8wo8HJ52jd79EJ8iqfIBoidBfy9AIUiEUApGQzWPu6yWcI8fY0rN5D+tc+ Yw1Zt6Mm+huYJpgCRsTcfzEcahnBn521CWcWvhW1ff3KFileFMtNmnBBhMncmRKHphtTKEpN 3jI= Organization: 2ndQuadrant Message-ID: <249bd41d-0385-3038-4394-a42f00e1a045@2ndquadrant.com> Date: Thu, 27 Dec 2018 12:02:34 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181221233819.GE1948@paquier.xyz> Content-Type: multipart/mixed; boundary="------------343E56B921573CAF60FBD37F" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------343E56B921573CAF60FBD37F Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 22/12/2018 00:38, Michael Paquier wrote: > On Fri, Dec 21, 2018 at 01:54:20PM +0300, Sergei Kornilov wrote: >> I am +1 for recovery_target_timeline=latest by default. This is >> common case in my opinion. > > I agree also that switching to the latest timeline should be the > default. People get confused because of the current default. How about this patch then? -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --------------343E56B921573CAF60FBD37F Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="0001-Always-use-latest-timeline-in-standby-mode.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Always-use-latest-timeline-in-standby-mode.patch" From 5fd266a61c63104d8f3f4cd3e19bfc99fd22ba21 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 27 Dec 2018 11:49:47 +0100 Subject: [PATCH] Always use latest timeline in standby mode In standby mode, ignore the setting of recovery_target_timeline and always behave as if 'latest' was specified. --- doc/src/sgml/config.sgml | 15 ++++++++++++--- doc/src/sgml/high-availability.sgml | 8 ++------ src/backend/access/transam/xlog.c | 7 +++++++ src/bin/pg_rewind/RewindTest.pm | 2 -- src/test/recovery/t/004_timeline_switch.pl | 1 - src/test/recovery/t/009_twophase.pl | 12 ------------ src/test/recovery/t/012_subtransactions.pl | 12 ------------ 7 files changed, 21 insertions(+), 36 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index e94b305add..76a83246ee 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3352,13 +3352,22 @@ Recovery Target Specifies recovering into a particular timeline. The default is to recover along the same timeline that was current when the - base backup was taken. Setting this to latest recovers - to the latest timeline found in the archive, which is useful in - a standby server. Other than that you only need to set this parameter + base backup was taken. Setting this to latest recovers + to the latest timeline found in the archive. + + + + You only need to set this parameter in complex re-recovery situations, where you need to return to a state that itself was reached after a point-in-time recovery. See for discussion. + + + In standby mode, this parameter is ignored and the latest timeline is + always used. This allows a standby to follow timeline changes in + upstream servers. + diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml index d8fd195da0..47a93aef5b 100644 --- a/doc/src/sgml/high-availability.sgml +++ b/doc/src/sgml/high-availability.sgml @@ -689,10 +689,7 @@ Setting Up a Standby Server server (see ). Create a file standby.signal in the standby's cluster data directory. Set to a simple command to copy files from - the WAL archive. If you plan to have multiple standby servers for high - availability purposes, set recovery_target_timeline to - latest, to make the standby server follow the timeline change - that occurs at failover to another standby. + the WAL archive. @@ -1023,8 +1020,7 @@ Cascading Replication If an upstream standby server is promoted to become new master, downstream - servers will continue to stream from the new master if - recovery_target_timeline is set to 'latest'. + servers will continue to stream from the new master. diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5729867879..315fff48c7 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5420,6 +5420,13 @@ validateRecoveryParameters(void) !EnableHotStandby) recoveryTargetAction = RECOVERY_TARGET_ACTION_SHUTDOWN; + /* + * In standby mode, always use latest timeline, ignoring + * recovery_target_timeline setting. + */ + if (StandbyModeRequested) + recoveryTargetTimeLineGoal = RECOVERY_TARGET_TIMELINE_LATEST; + /* * If user specified recovery_target_timeline, validate it or compute the * "latest" value. We can't do this until after we've gotten the restore diff --git a/src/bin/pg_rewind/RewindTest.pm b/src/bin/pg_rewind/RewindTest.pm index 3d07da5d94..85cae7e47b 100644 --- a/src/bin/pg_rewind/RewindTest.pm +++ b/src/bin/pg_rewind/RewindTest.pm @@ -161,7 +161,6 @@ sub create_standby $node_standby->append_conf( "postgresql.conf", qq( primary_conninfo='$connstr_master application_name=rewind_standby' -recovery_target_timeline='latest' )); $node_standby->set_standby_mode(); @@ -273,7 +272,6 @@ sub run_pg_rewind $node_master->append_conf( 'postgresql.conf', qq( primary_conninfo='port=$port_standby' -recovery_target_timeline='latest' )); $node_master->set_standby_mode(); diff --git a/src/test/recovery/t/004_timeline_switch.pl b/src/test/recovery/t/004_timeline_switch.pl index 79cbffb827..2b315854bc 100644 --- a/src/test/recovery/t/004_timeline_switch.pl +++ b/src/test/recovery/t/004_timeline_switch.pl @@ -51,7 +51,6 @@ $node_standby_2->append_conf( 'postgresql.conf', qq( primary_conninfo='$connstr_1 application_name=@{[$node_standby_2->name]}' -recovery_target_timeline='latest' )); $node_standby_2->restart; diff --git a/src/test/recovery/t/009_twophase.pl b/src/test/recovery/t/009_twophase.pl index dac2d4ec0d..2be1afcd8b 100644 --- a/src/test/recovery/t/009_twophase.pl +++ b/src/test/recovery/t/009_twophase.pl @@ -229,10 +229,6 @@ sub configure_and_reload # restart old master as new standby $cur_standby->enable_streaming($cur_master); -$cur_standby->append_conf( - 'postgresql.conf', qq( -recovery_target_timeline='latest' -)); $cur_standby->start; ############################################################################### @@ -267,10 +263,6 @@ sub configure_and_reload # restart old master as new standby $cur_standby->enable_streaming($cur_master); -$cur_standby->append_conf( - 'postgresql.conf', qq( -recovery_target_timeline='latest' -)); $cur_standby->start; $cur_master->psql('postgres', "COMMIT PREPARED 'xact_009_11'"); @@ -307,10 +299,6 @@ sub configure_and_reload # restart old master as new standby $cur_standby->enable_streaming($cur_master); -$cur_standby->append_conf( - 'postgresql.conf', qq( -recovery_target_timeline='latest' -)); $cur_standby->start; $cur_master->psql('postgres', "COMMIT PREPARED 'xact_009_12'"); diff --git a/src/test/recovery/t/012_subtransactions.pl b/src/test/recovery/t/012_subtransactions.pl index e26cc9c2ce..c184553694 100644 --- a/src/test/recovery/t/012_subtransactions.pl +++ b/src/test/recovery/t/012_subtransactions.pl @@ -119,10 +119,6 @@ # restore state ($node_master, $node_standby) = ($node_standby, $node_master); $node_standby->enable_streaming($node_master); -$node_standby->append_conf( - 'postgresql.conf', qq( -recovery_target_timeline='latest' -)); $node_standby->start; $node_standby->psql( 'postgres', @@ -170,10 +166,6 @@ # restore state ($node_master, $node_standby) = ($node_standby, $node_master); $node_standby->enable_streaming($node_master); -$node_standby->append_conf( - 'postgresql.conf', qq( -recovery_target_timeline='latest' -)); $node_standby->start; $psql_rc = $node_master->psql('postgres', "COMMIT PREPARED 'xact_012_1'"); is($psql_rc, '0', @@ -211,10 +203,6 @@ # restore state ($node_master, $node_standby) = ($node_standby, $node_master); $node_standby->enable_streaming($node_master); -$node_standby->append_conf( - 'postgresql.conf', qq( -recovery_target_timeline='latest' -)); $node_standby->start; $psql_rc = $node_master->psql('postgres', "ROLLBACK PREPARED 'xact_012_1'"); is($psql_rc, '0', -- 2.20.1 --------------343E56B921573CAF60FBD37F--