Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit223431c

Browse files
committed
Request XLOG switch before writing checkpoint in pg_start_backup(). Otherwise
you can end up with an unrecoverable backup if you start a new base backupright after finishing archive recovery. In that scenario, the redo pointer ofthe checkpoint that pg_start_backup() writes points to the XLOG segment wherethe timeline-changing end-of-archive-recovery checkpoint is. The beginningof that segment contains pages with the old timeline ID, and we don't acceptthat in recovery unless we find a history file covering the old timeline ID.If you omit pg_xlog from the base backup and clear the archive directorybefore starting the backup, there will be no such history file available.The bug is present in all versions since PITR was introduced in 8.0, but I'mback-patching only back to 8.2. Earlier versions didn't have XLOG switchrecords, making this fix unfeasible. Given the lack of reports until now,it doesn't seem worthwhile to spend more effort to fix 8.0 and 8.1.Per report and suggestion by Mikael Krantz
1 parent1f36fec commit223431c

File tree

1 file changed

+14
-1
lines changed
  • src/backend/access/transam

1 file changed

+14
-1
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.336 2009/04/22 19:51:12 heikki Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.337 2009/05/07 11:25:25 heikki Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -6987,6 +6987,19 @@ pg_start_backup(PG_FUNCTION_ARGS)
69876987
XLogCtl->Insert.forcePageWrites= true;
69886988
LWLockRelease(WALInsertLock);
69896989

6990+
/*
6991+
* Force an XLOG file switch before the checkpoint, to ensure that the WAL
6992+
* segment the checkpoint is written to doesn't contain pages with old
6993+
* timeline IDs. That would otherwise happen if you called
6994+
* pg_start_backup() right after restoring from a PITR archive: the first
6995+
* WAL segment containing the startup checkpoint has pages in the
6996+
* beginning with the old timeline ID. That can cause trouble at recovery:
6997+
* we won't have a history file covering the old timeline if pg_xlog
6998+
* directory was not included in the base backup and the WAL archive was
6999+
* cleared too before starting the backup.
7000+
*/
7001+
RequestXLogSwitch();
7002+
69907003
/* Ensure we release forcePageWrites if fail below */
69917004
PG_ENSURE_ERROR_CLEANUP(pg_start_backup_callback, (Datum)0);
69927005
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp