|
7 | 7 | * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California
|
9 | 9 | *
|
10 |
| - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.406 2010/04/29 21:36:19 tgl Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.407 2010/04/29 21:49:03 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -8205,18 +8205,11 @@ pg_start_backup(PG_FUNCTION_ARGS)
|
8205 | 8205 | errmsg("recovery is in progress"),
|
8206 | 8206 | errhint("WAL control functions cannot be executed during recovery.")));
|
8207 | 8207 |
|
8208 |
| - if (!XLogArchivingActive()) |
8209 |
| - ereport(ERROR, |
8210 |
| - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), |
8211 |
| - errmsg("WAL archiving is not active"), |
8212 |
| - errhint("archive_mode must be enabled at server start."))); |
8213 |
| - |
8214 |
| - if (!XLogArchiveCommandSet()) |
| 8208 | + if (!XLogIsNeeded()) |
8215 | 8209 | ereport(ERROR,
|
8216 | 8210 | (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
8217 |
| - errmsg("WAL archiving is not active"), |
8218 |
| - errhint("archive_command must be defined before " |
8219 |
| - "online backups can be made safely."))); |
| 8211 | + errmsg("WAL level not sufficient for making an online backup"), |
| 8212 | + errhint("wal_level must be set to \"archive\" or \"hot_standby\" at server start."))); |
8220 | 8213 |
|
8221 | 8214 | backupidstr = text_to_cstring(backupid);
|
8222 | 8215 |
|
@@ -8404,11 +8397,11 @@ pg_stop_backup(PG_FUNCTION_ARGS)
|
8404 | 8397 | errmsg("recovery is in progress"),
|
8405 | 8398 | errhint("WAL control functions cannot be executed during recovery.")));
|
8406 | 8399 |
|
8407 |
| - if (!XLogArchivingActive()) |
| 8400 | + if (!XLogIsNeeded()) |
8408 | 8401 | ereport(ERROR,
|
8409 | 8402 | (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
8410 |
| - errmsg("WAL archiving is not active"), |
8411 |
| - errhint("archive_mode must be enabled at server start."))); |
| 8403 | + errmsg("WAL level not sufficient for making an online backup"), |
| 8404 | + errhint("wal_level must be set to \"archive\" or \"hot_standby\" at server start."))); |
8412 | 8405 |
|
8413 | 8406 | /*
|
8414 | 8407 | * OK to clear forcePageWrites
|
@@ -8516,16 +8509,26 @@ pg_stop_backup(PG_FUNCTION_ARGS)
|
8516 | 8509 | CleanupBackupHistory();
|
8517 | 8510 |
|
8518 | 8511 | /*
|
8519 |
| - * Wait until both the last WAL file filled during backup and the history |
8520 |
| - * file have been archived. We assume that the alphabetic sorting |
8521 |
| - * property of the WAL files ensures any earlier WAL files are safely |
8522 |
| - * archived as well. |
| 8512 | + * If archiving is enabled, wait for all the required WAL files to be |
| 8513 | + * archived before returning. If archiving isn't enabled, the required |
| 8514 | + * WAL needs to be transported via streaming replication (hopefully |
| 8515 | + * with wal_keep_segments set high enough), or some more exotic |
| 8516 | + * mechanism like polling and copying files from pg_xlog with script. |
| 8517 | + * We have no knowledge of those mechanisms, so it's up to the user to |
| 8518 | + * ensure that he gets all the required WAL. |
| 8519 | + * |
| 8520 | + * We wait until both the last WAL file filled during backup and the |
| 8521 | + * history file have been archived, and assume that the alphabetic |
| 8522 | + * sorting property of the WAL files ensures any earlier WAL files are |
| 8523 | + * safely archived as well. |
8523 | 8524 | *
|
8524 | 8525 | * We wait forever, since archive_command is supposed to work and we
|
8525 | 8526 | * assume the admin wanted his backup to work completely. If you don't
|
8526 | 8527 | * wish to wait, you can set statement_timeout. Also, some notices are
|
8527 | 8528 | * issued to clue in anyone who might be doing this interactively.
|
8528 | 8529 | */
|
| 8530 | + if (XLogArchivingActive()) |
| 8531 | + { |
8529 | 8532 | XLByteToPrevSeg(stoppoint, _logId, _logSeg);
|
8530 | 8533 | XLogFileName(lastxlogfilename, ThisTimeLineID, _logId, _logSeg);
|
8531 | 8534 |
|
@@ -8564,6 +8567,10 @@ pg_stop_backup(PG_FUNCTION_ARGS)
|
8564 | 8567 |
|
8565 | 8568 | ereport(NOTICE,
|
8566 | 8569 | (errmsg("pg_stop_backup complete, all required WAL segments have been archived")));
|
| 8570 | + } |
| 8571 | + else |
| 8572 | + ereport(NOTICE, |
| 8573 | + (errmsg("WAL archiving is not enabled; you must ensure that all required WAL segments are copied through other means to complete the backup"))); |
8567 | 8574 |
|
8568 | 8575 | /*
|
8569 | 8576 | * We're done. As a convenience, return the ending WAL location.
|
|
0 commit comments