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 1giDu1-0006et-9b for pgsql-bugs@arkaria.postgresql.org; Sat, 12 Jan 2019 07:40:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1giDtz-00043j-PY for pgsql-bugs@arkaria.postgresql.org; Sat, 12 Jan 2019 07:40:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1giDtz-00040g-Ar for pgsql-bugs@lists.postgresql.org; Sat, 12 Jan 2019 07:40:19 +0000 Received: from server2.lako.no ([77.235.58.136]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1giDtr-0005qO-Jd for pgsql-bugs@lists.postgresql.org; Sat, 12 Jan 2019 07:40:18 +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 x0C7e7pb040028 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 12 Jan 2019 08:40:07 +0100 MIME-Version: 1.0 Date: Sat, 12 Jan 2019 07:40:07 +0000 Content-Type: multipart/alternative; boundary="--=_RainLoop_681_770868435.1547278807" 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: "Jeff Janes" , pgsql-bugs@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_681_770868435.1547278807 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable "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 ha= ve paused recovery also on the first scenario. Then I=0Acould have added = missing wal and continued with restore. =0AAt the least, I think we shoul= d log an explicit WARNING if the WAL stream ends before the specified PIT= is reached. =0A The documentation for recovery.conf states that with re= covery_target_time set recovery_target_action defaults to pause.=0AEven i= f stop point is not reached, pause should be activated.=0AAfter checking = the source this might be solved with a small addition in StartupXLOG.c=0A= Someone with more experience with the source code should check this out.= =0A if (reachedStopPoint) =0A{ =0A if (!reachedConsistency) =0A erepo= rt(FATAL, =0A (errmsg("requested recovery stop point is before consiste= nt recovery point"))); =0A /* =0A * This is the last point where we ca= n restart recovery with a =0A * new recovery target, if we shutdown and b= egin again. After =0A * this, Resource Managers may choose to do permanen= t =0A * corrective actions at end of recovery. =0A */ =0A switch (recove= ryTargetAction) =0A { =0A case RECOVERY_TARGET_ACTION_SHUTDOWN: =0A /= * =0A * exit with special return code to request shutdown =0A * of postm= aster. Log messages issued from =0A * postmaster. =0A */ =0A proc_exit(3= ); =0A case RECOVERY_TARGET_ACTION_PAUSE: =0A SetRecoveryPause(true);= =0A recoveryPausesHere(); =0A /* drop into promote */ =0A case REC= OVERY_TARGET_ACTION_PROMOTE: =0A break; =0A } =0A /* Add these lines .= ... */ =0A } else if (recoveryTarget =3D=3D RECOVERY_TARGET_TIME) =0A{= =0A /* =0A * Stop point not reached but next WAL could not be read =0A= * Some explanation and warning should be logged =0A */ =0A switch (reco= veryTargetAction) =0A { =0A case RECOVERY_TARGET_ACTION_PAUSE: =0A Se= tRecoveryPause(true); =0A recoveryPausesHere(); =0A break; =0A } =0A= } =0A/* .... until here */ =0A--=0A=0ALeif ----=_RainLoop_681_770868435.1547278807 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
=

"Jeff Janes" <jeff.janes@gmail.com> skrev 11. januar 2019 kl. 15:03:
=
On Fri, Jan 11,= 2019 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 co= ntinued with restore.
At the le= ast, I think we should log an explicit WARNING if the WAL stream ends bef= ore the specified PIT is reached.
The documentation for recovery.conf states that with recovery_target_time set= recovery_ta= rget_action de= faults to pause.
Even if stop point is not reached, pause should be ac= tivated.
A
fter checking the source this might be solved = with a small addition in StartupXLOG.c
Someone with more experience wi= th the source code should check this out.
if (reachedStopPoint)
{
if (!reachedConsistency)
ereport(FATAL,
(errmsg("requested recove= ry stop point is before consistent recovery point")));
= /*
* This is the last point where we can restart recov= ery with a
* new recov= ery target, if we shutdown and begin again. After
* this, Resource Managers may choose to do pe= rmanent
* corrective a= ctions at end of recovery.
*/
switch (= recoveryTargetAction)
= {
case RECOVERY= _TARGET_ACTION_SHUTDOWN:
/*
* exit with special return code to request shut= down
* of postmaster. = Log messages issued from
*/
proc_exit(<= span style=3D"color: #b5cea8;">3);=
= case SetRecoveryPause(true);
recover= yPausesHere();
=
/* drop into promote */
case RECOVERY_TARGET_ACTION_PROMOTE:
<= div> break;
}
/* Add these lines .... */
} else if (recoveryTarget =3D=3D RECOVERY_TARGET_TIME)
{
/*
<= span style=3D"color: #608b4e;"> * Stop point not reached but next WAL cou= ld not be read
* Some = explanation and warning should be logged
*/
= switch (recoveryTargetAction)
{
case RECOVERY_TARGET_ACTION_PAUSE:
SetRecoveryPause(true);
reco= veryPausesHere();
break;
}
}
/* .... until = here */

--

Leif

----=_RainLoop_681_770868435.1547278807--