diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index d6c057a..33485de 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -8829,10 +8829,6 @@ CreateRestartPoint(int flags) * the database opened up for read-only connections at a point-in-time * before the last shutdown. Such time travel is still possible in case of * immediate shutdown, though. - * - * We don't explicitly advance minRecoveryPoint when we do create a - * restartpoint. It's assumed that flushing the buffers will do that as a - * side-effect. */ if (XLogRecPtrIsInvalid(lastCheckPointRecPtr) || lastCheckPoint.redo <= ControlFile->checkPointCopy.redo) @@ -8988,6 +8984,15 @@ CreateRestartPoint(int flags) if (EnableHotStandby) TruncateSUBTRANS(GetOldestXmin(NULL, false)); + /* + * Update minRecoveryPoint just past the last redo checkpoint if + * necessary. This ensures that at next startup minRecoveryPoint will + * not be past the next point it would start at, preventing any + * weird behaviors with for example backups taken from standbys that + * rely on minRecoveryPoint as end backup location. + */ + UpdateMinRecoveryPoint(RedoRecPtr, false); + /* Real work is done, but log and update before releasing lock. */ LogCheckpointEnd(true); diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl index fd71095..981c00b 100644 --- a/src/test/recovery/t/001_stream_rep.pl +++ b/src/test/recovery/t/001_stream_rep.pl @@ -24,6 +24,11 @@ $node_standby_1->start; # pg_basebackup works on a standby). $node_standby_1->backup($backup_name); +# Take a second backup of the standby while the master is offline. +$node_master->stop; +$node_standby_1->backup('my_backup_2'); +$node_master->start; + # Create second standby node linking to standby 1 my $node_standby_2 = get_new_node('standby_2'); $node_standby_2->init_from_backup($node_standby_1, $backup_name,