Skip to content

Commit d38603b

Browse files
Improve sequence and sense of messages from pg_stop_backup().
Now doesn't report it is waiting until it actually is waiting, plus message doesn't appear until at least 5 seconds wait, so we avoid reporting the wait before we've given the archiver a reasonable time to wake up and archive the file we just created earlier in the function. Also add new unconditional message to confirm safe completion. Now a normal, healthy execution does not report waiting at all, just safe completion.
1 parent 2847de9 commit d38603b

File tree

1 file changed

+12
-4
lines changed
  • src/backend/access/transam

1 file changed

+12
-4
lines changed

src/backend/access/transam/xlog.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, 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.399 2010/04/18 18:17:12 sriggs Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.400 2010/04/18 18:44:53 sriggs Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -8290,6 +8290,7 @@ pg_stop_backup(PG_FUNCTION_ARGS)
82908290
int ich;
82918291
int seconds_before_warning;
82928292
int waits = 0;
8293+
bool reported_waiting = false;
82938294

82948295
if (!superuser())
82958296
ereport(ERROR,
@@ -8431,9 +8432,6 @@ pg_stop_backup(PG_FUNCTION_ARGS)
84318432
BackupHistoryFileName(histfilename, ThisTimeLineID, _logId, _logSeg,
84328433
startpoint.xrecoff % XLogSegSize);
84338434

8434-
ereport(NOTICE,
8435-
(errmsg("pg_stop_backup cleanup done, waiting for required WAL segments to be archived")));
8436-
84378435
seconds_before_warning = 60;
84388436
waits = 0;
84398437

@@ -8442,6 +8440,13 @@ pg_stop_backup(PG_FUNCTION_ARGS)
84428440
{
84438441
CHECK_FOR_INTERRUPTS();
84448442

8443+
if (!reported_waiting && waits > 5)
8444+
{
8445+
ereport(NOTICE,
8446+
(errmsg("pg_stop_backup cleanup done, waiting for required WAL segments to be archived")));
8447+
reported_waiting = true;
8448+
}
8449+
84458450
pg_usleep(1000000L);
84468451

84478452
if (++waits >= seconds_before_warning)
@@ -8456,6 +8461,9 @@ pg_stop_backup(PG_FUNCTION_ARGS)
84568461
}
84578462
}
84588463

8464+
ereport(NOTICE,
8465+
(errmsg("pg_stop_backup complete, all required WAL segments have been archived")));
8466+
84598467
/*
84608468
* We're done. As a convenience, return the ending WAL location.
84618469
*/

0 commit comments

Comments
 (0)