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 1gmCTc-0001y9-8R for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Jan 2019 06:57:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gmCTa-0008W5-I4 for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Jan 2019 06:57:30 +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 1gmCTa-0008Vy-Al for pgsql-hackers@lists.postgresql.org; Wed, 23 Jan 2019 06:57:30 +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 1gmCTY-00046c-Lo for pgsql-hackers@lists.postgresql.org; Wed, 23 Jan 2019 06:57:29 +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 x0N6vRrj113968 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 23 Jan 2019 07:57:27 +0100 MIME-Version: 1.0 Date: Wed, 23 Jan 2019 06:57:27 +0000 Content-Type: multipart/alternative; boundary="--=_RainLoop_500_940715402.1548226647" X-Mailer: RainLoop/1.12.1 From: leif@lako.no Message-ID: <85a0cdd7cefa306a12c390967021500b@lako.no> Subject: Fwd: Re: BUG #15589: Due to missing wal, restore ends prematurely and opens database for read/write To: pgsql-hackers@lists.postgresql.org In-Reply-To: References: <15589-8e6e353a97b085fb@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ----=_RainLoop_500_940715402.1548226647 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi=0AI have reported a bug via PostgreSQL bug report form, but havent got= any response so far.=0AThis might not be a bug, but a feature not implem= ented yet.=0AI have created an suggestion to make a small addition to Sta= rtupXLOG.c to solve the issue.=0A=0AAny suggestions?=0A=0A--=0ALeif Gunna= r Erlandsen=0A=0A-------- Videresendt melding -------=0AFra: leif@lako.no= (mailto:leif@lako.no)=0ATil: "Jeff Janes" )>, = pgsql-bugs@lists.postgresql.org (mailto:pgsql-bugs@lists.postgresql.org)= =0ASendt: 12. januar 2019 kl. 08:40=0AEmne: Re: BUG #15589: Due to missin= g wal, restore ends prematurely and opens database for read/write=0A"Jeff= Janes" )> skrev 11. januar 2019 kl. 15:03:=0A = On Fri, Jan 11, 2019 at 4:08 AM PG Bug reporting form wrote: =0APostgreSQL should have pa= used recovery also on the first scenario. Then I=0Acould have added missi= ng wal and continued with restore. =0AAt the least, I think we should log= an explicit WARNING if the WAL stream ends before the specified PIT is r= eached. =0A The documentation for recovery.conf states that with recover= y_target_time set recovery_target_action defaults to pause.=0AEven if sto= p point is not reached, pause should be activated.=0AAfter checking the s= ource this might be solved with a small addition in StartupXLOG.c=0ASomeo= ne with more experience with the source code should check this out. =0A i= f (reachedStopPoint) =0A{ =0A if (!reachedConsistency) =0A ereport(FATA= L, =0A (errmsg("requested recovery stop point is before consistent recov= ery point"))); =0A/* =0A* This is the last point where we can restart re= covery with a =0A* new recovery target, if we shutdown and begin again. A= fter =0A* this, Resource Managers may choose to do permanent =0A* correct= ive actions at end of recovery. =0A*/ =0A switch (recoveryTargetAction) = =0A{ =0A case RECOVERY_TARGET_ACTION_SHUTDOWN: =0A/* =0A* exit with spec= ial return code to request shutdown =0A* of postmaster. Log messages issu= ed from =0A* postmaster. =0A*/ =0A proc_exit(3); =0A case RECOVERY_TARGE= T_ACTION_PAUSE: =0A SetRecoveryPause(true); =0A recoveryPausesHere(); = =0A/* drop into promote */ =0A case RECOVERY_TARGET_ACTION_PROMOTE: =0A = break; =0A} =0A /* Add these lines .... */ =0A } else if (recoveryTarg= et =3D=3D RECOVERY_TARGET_TIME) =0A{ =0A/* =0A* Stop point not reached b= ut next WAL could not be read =0A* Some explanation and warning should be= logged =0A*/ =0A switch (recoveryTargetAction) =0A{ =0A case RECOVERY_T= ARGET_ACTION_PAUSE: =0A SetRecoveryPause(true); =0A recoveryPausesHere(= ); =0A break; =0A} =0A} =0A/* .... until here */ =0A--=0A=0ALeif ----=_RainLoop_500_940715402.1548226647 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
H= i
I have reported a bug via PostgreSQL bug report form, but havent got= any response so far.
This might not be a bug, but a feature not imple= mented yet.
I have created an suggestion to make a small addition to S= tartupXLOG.c to solve the issue.

Any suggestions?

--
Lei= f Gunnar Erlandsen

-------- Videresendt melding -------
Fra: leif@lako= .no
Til: "Jeff Janes" <jeff.janes@gmail.com>, pgsql-bugs@list= s.postgresql.org
Sendt: 12. januar 2019 kl. 08:40
Emne: Re: BUG= #15589: Due to missing wal, restore ends prematurely and opens database = for read/write


"Jeff Janes" <= jeff.janes@gmail.com> skrev 11. januar 2019 kl. 15:03:

On Fri, Jan 11, 201= 9 at 4:08 AM PG Bug reporting form <noreply@postgresql.org> wrote:

PostgreSQL should have paused recovery also= on the first scenario. Then I
could have added missing wal and contin= ued with restore.
At the least,= I think we should log an explicit WARNING if the WAL stream ends before = the specified PIT is reached.
= The documentation for recovery.conf states that with recovery_target_time set reco= very_target_action defaults to pa= use.
Even if stop point is not reached, pause should be activated.
= A
fter checking the source this might be solved with a small= addition in StartupXLOG.c
Someone with more experience with the sourc= e code should check this out.
if (reachedS= topPoint)
{
if (!reachedConsistency)
ereport(FATAL,
(errmsg("requested recovery stop point is before consistent reco= very point")));
= /*
* This is the last point where we can restart recovery with a
* new recovery target, if= we shutdown and begin again. After
* this, Resource Managers may choose to do permanent
* corrective actions at end of r= ecovery.
*/
=
switch (recoveryTargetAction)
{
case= RECOVERY_TARGET_ACTION_SHUTDOWN: <= /div>
/*
* exit with special return code to request shutdown<= /span>
* of postmaster. Log mes= sages issued from
* post= master.
*/
=
proc_exit(3);
case RECOVERY_TARGET_ACTIO= N_PAUSE:
SetRecoveryPa= use(true);
<= span style=3D"color: #dcdcaa">recoveryPausesHere();
/* drop into promote */
case RECOVERY_TARGET_ACTION_= PROMOTE:
break<= span style=3D"color: #d4d4d4">;
}
/* Add these= lines .... */
= } e= lse if (recoveryTarget =3D=3D= RECOVERY_TARGET_TIME)
= {
/*
<= span style=3D"color: #608b4e">* Stop point not reached but next WAL could= not be read
* Some expl= anation and warning should be logged
*/
switch<= /span> (recoveryTargetAction)
{
case RECOVERY_TARG= ET_ACTION_PAUSE:
SetRe= coveryPause(true);
=
recoveryPausesHere();
break;
}
}
/* .... until here = */

--

Leif


----=_RainLoop_500_940715402.1548226647--