Index: doc/src/sgml/high-availability.sgml =================================================================== --- doc/src/sgml/high-availability.sgml (head) +++ doc/src/sgml/high-availability.sgml (archive_cleanup_command) @@ -681,7 +681,7 @@ - You can use restartpoint_command to prune the archive of + You can use archive_cleanup_command to prune the archive of files no longer needed by the standby. @@ -714,7 +714,7 @@ If you're using a WAL archive, its size can be minimized using - the restartpoint_command option to remove files that are + the archive_cleanup_command option to remove files that are no longer required by the standby server. Note however, that if you're using the archive for backup purposes, you need to retain files needed to recover from at least the latest base backup, even if they're no Index: doc/src/sgml/recovery-config.sgml =================================================================== --- doc/src/sgml/recovery-config.sgml (head) +++ doc/src/sgml/recovery-config.sgml (archive_cleanup_command) @@ -73,16 +73,16 @@ - - restartpoint_command (string) + + archive_cleanup_command (string) - restartpoint_command recovery parameter + archive_cleanup_command recovery parameter This parameter specifies a shell command that will be executed at every restartpoint. This parameter is optional. The purpose of the - restartpoint_command is to provide a mechanism for cleaning + archive_cleanup_command is to provide a mechanism for cleaning up old archived WAL files that are no longer needed by the standby server. Any %r is replaced by the name of the file @@ -114,7 +114,7 @@ recovery_end_command is to provide a mechanism for cleanup following replication or recovery. Any %r is replaced by the name of the file containing the - last valid restart point, like in . + last valid restart point, like in . If the command returns a non-zero exit status then a WARNING log Index: doc/src/sgml/release-9.0.sgml =================================================================== --- doc/src/sgml/release-9.0.sgml (head) +++ doc/src/sgml/release-9.0.sgml (archive_cleanup_command) @@ -415,6 +415,15 @@ + + + Add archive_cleanup_command, + which can be used to clean up old archived WAL files that are no longer + needed WAL by the standby server (Heikki Linnakangas) + + + Index: src/backend/access/transam/recovery.conf.sample =================================================================== --- src/backend/access/transam/recovery.conf.sample (head) +++ src/backend/access/transam/recovery.conf.sample (archive_cleanup_command) @@ -46,12 +46,12 @@ #restore_command = '' # e.g. 'cp /mnt/server/archivedir/%f %p' # # -# restartpoint_command +# archive_cleanup_command # # specifies an optional shell command to execute at every restartpoint. # This can be useful for cleaning up the archive of a standby server. # -#restartpoint_command = '' +#archive_cleanup_command = '' # # recovery_end_command # Index: src/backend/access/transam/xlog.c =================================================================== --- src/backend/access/transam/xlog.c (head) +++ src/backend/access/transam/xlog.c (archive_cleanup_command) @@ -180,7 +180,7 @@ /* options taken from recovery.conf for archive recovery */ static char *recoveryRestoreCommand = NULL; static char *recoveryEndCommand = NULL; -static char *restartPointCommand = NULL; +static char *archiveCleanupCommand = NULL; static RecoveryTargetType recoveryTarget = RECOVERY_TARGET_UNSET; static bool recoveryTargetInclusive = true; static TransactionId recoveryTargetXid; @@ -382,10 +382,10 @@ TimeLineID ThisTimeLineID; TimeLineID RecoveryTargetTLI; /* - * restartPointCommand is read from recovery.conf but needs to be in + * archiveCleanupCommand is read from recovery.conf but needs to be in * shared memory so that the bgwriter process can access it. */ - char restartPointCommand[MAXPGPATH]; + char archiveCleanupCommand[MAXPGPATH]; /* * SharedRecoveryInProgress indicates if we're still in crash or archive @@ -3047,7 +3047,7 @@ * 'failonSignal' is true and the command is killed by a signal, a FATAL * error is thrown. Otherwise a WARNING is emitted. * - * This is currently used for restore_end_command and restartpoint_command. + * This is currently used for restore_end_command and archive_cleanup_command. */ static void ExecuteRecoveryCommand(char *command, char *commandName, bool failOnSignal) @@ -5124,12 +5124,12 @@ (errmsg("recovery_end_command = '%s'", recoveryEndCommand))); } - else if (strcmp(tok1, "restartpoint_command") == 0) + else if (strcmp(tok1, "archive_cleanup_command") == 0) { - restartPointCommand = pstrdup(tok2); + archiveCleanupCommand = pstrdup(tok2); ereport(DEBUG2, - (errmsg("restartpoint_command = '%s'", - restartPointCommand))); + (errmsg("archive_cleanup_command = '%s'", + archiveCleanupCommand))); } else if (strcmp(tok1, "recovery_target_timeline") == 0) { @@ -5737,13 +5737,13 @@ ControlFile->checkPointCopy.ThisTimeLineID))); /* - * Save the selected recovery target timeline ID and restartpoint_command + * Save the selected recovery target timeline ID and archive_cleanup_command * in shared memory so that other processes can see them */ XLogCtl->RecoveryTargetTLI = recoveryTargetTLI; - strncpy(XLogCtl->restartPointCommand, - restartPointCommand ? restartPointCommand : "", - sizeof(XLogCtl->restartPointCommand)); + strncpy(XLogCtl->archiveCleanupCommand, + archiveCleanupCommand ? archiveCleanupCommand : "", + sizeof(XLogCtl->archiveCleanupCommand)); if (InArchiveRecovery) { @@ -7645,11 +7645,11 @@ LWLockRelease(CheckpointLock); /* - * Finally, execute restartpoint_command, if any. + * Finally, execute archive_cleanup_command, if any. */ - if (XLogCtl->restartPointCommand[0]) - ExecuteRecoveryCommand(XLogCtl->restartPointCommand, - "restartpoint_command", + if (XLogCtl->archiveCleanupCommand[0]) + ExecuteRecoveryCommand(XLogCtl->archiveCleanupCommand, + "archive_cleanup_command", false); return true;