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 1gyvIh-0004Ht-T6 for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Feb 2019 09:14:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gyvIg-00075Z-Hs for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Feb 2019 09:14:50 +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 1gyvIg-00070G-9F for pgsql-hackers@lists.postgresql.org; Wed, 27 Feb 2019 09:14:50 +0000 Received: from server2.lako.no ([77.235.58.136]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyvId-0003XN-H9 for pgsql-hackers@lists.postgresql.org; Wed, 27 Feb 2019 09:14:49 +0000 Received: from webmail.lako.no (localhost [127.0.0.1]) (authenticated bits=0) by server2.lako.no (8.14.7/8.14.7) with ESMTP id x1R9Eeqm036051 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Feb 2019 10:14:40 +0100 MIME-Version: 1.0 Date: Wed, 27 Feb 2019 09:14:40 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: RainLoop/1.12.1 From: leif@lako.no Message-ID: Subject: Re: BUG #15589: Due to missing wal, restore ends prematurely and opens database for read/write To: "Michael Paquier" , "Kyotaro HORIGUCHI" Cc: pgsql-hackers@lists.postgresql.org In-Reply-To: <20190226081255.GK27822@paquier.xyz> References: <20190226081255.GK27822@paquier.xyz> <15589-8e6e353a97b085fb@postgresql.org> <20190131.212648.235621599.horiguchi.kyotaro@lab.ntt.co.jp> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Michael Paquier" skrev 26. februar 2019 kl. 09:13:= =0A=0A> On Thu, Jan 31, 2019 at 09:26:48PM +0900, Kyotaro HORIGUCHI wrote= :=0A> =0A>> I don't think no one expected that server follows=0A>> recove= ry_target_action without setting a target, so we can change=0A>> the beha= vior when any kind of target is specified. So I propose=0A>> to follow re= covery_target_action even if not rached the target=0A>> when any recovery= target isspecified.=0A> =0A> Quoting the docs:=0A> https://www.postgresq= l.org/docs/current/recovery-target-settings.html=0A> recovery_target_acti= on (enum)=0A> "Specifies what action the server should take once the reco= very target=0A> is *reached*."=0A=0AI know this and recovery_target_actio= n in my case was "pause".=0ARecovery target was specified with a date and= time.=0A=0A> So what we have now is that an action would be taken iff a = stop point=0A> is defined and reached. What this patch changes is that th= e action=0A> would be taken even if the stop point has *not* been reached= once the=0A> end of a WAL stream is found.=0A=0AYes, and this is expecte= d behaviour in my use case. This was a PITR scenario, to a new server, an= d not crash recovery.=0AI restored a backup and placed WAL-files in a sep= arate directory, then I created a recovery.conf with correct recovery_tar= get_time.=0AAfter PostgreSQL started it stopped after a short while and o= pened the database in read/write.=0AChecks showed target was not reached.= Log showed that no more WAL could be found.=0AIf PostgreSQL had followed= recovery_target_action, then I could have restored the missing WAL-files= and continued replay of WAL.=0AAs this was not the case I had to restart= the process from the beginning, this took many hours.=0AAnother thing to= consider is that in instances such as this one, where a lot of WAL was n= eeded for replay, it is not always given that we have the sufficient amou= nt of available disk space in order to store them all at the same time.= =0A=0A =0A> Please do not take me wrong, I can see that there could be us= e cases=0A> where it is possible to take an action at the end of a WAL st= ream if=0A> there is less WAL than what was planned, perhaps if the OP ha= s set=0A> an incorrect stop position too far in the future, still too muc= h WAL=0A> would have been replayed so it would make the base backup unusa= ble for=0A> future uses. Also, it looks incorrect to me to change an exis= ting=0A> behavior and to use the same semantics for triggering an action = if a=0A> stop point is defined and reached.=0A=0AI did not set an incorre= ct stop position. I see this change as something most in a similar situat= ion would expect from their database system.=0A=0AAFAIK the doc does not = specify what happens if recovery_target_time is specified but not reached= . But as default recovery_target_action is set to "pause" I would have as= sumed "pause" to be the action.=0A=0Aregards=0ALeif Gunnar Erlandsen