archive_mode

A server configuration parameter determining when completed WAL segments are sent to archive storage

archive_mode is a server configuration parameter  determining when completed WAL segments are sent to archive storage.

It has three possible options:

Change history

Relevant code

In src/include/access/xlog.h:

 /* Archive modes */
typedef enum ArchiveMode
{
        ARCHIVE_MODE_OFF = 0,           /* disabled */
        ARCHIVE_MODE_ON,                        /* enabled while server is running normally */
        ARCHIVE_MODE_ALWAYS                     /* enabled always (even during recovery) */
} ArchiveMode;
extern int      XLogArchiveMode;

In src/backend/access/transam/xlog.c:

/* User-settable parameters */
...
int			XLogArchiveMode = ARCHIVE_MODE_OFF;

In src/backend/utils/misc/guc.c:

        {
                {"archive_mode", PGC_POSTMASTER, WAL_ARCHIVING,
                        gettext_noop("Allows archiving of WAL files using archive_command."),
                        NULL
                },
                &XLogArchiveMode,
                ARCHIVE_MODE_OFF, archive_mode_options,
                NULL, NULL, NULL
        },

In src/backend/postmaster/postmaster.c:

		if (XLogArchiveMode > ARCHIVE_MODE_OFF && wal_level == WAL_LEVEL_MINIMAL)
		ereport(ERROR,
				(errmsg("WAL archival cannot be enabled when wal_level is \"minimal\"")));

In src/backend/access/transam/xlogarchive.c:

	/*
	 * Create .done file forcibly to prevent the restored segment from being
	 * archived again later.
	 */
	if (XLogArchiveMode != ARCHIVE_MODE_ALWAYS)
		XLogArchiveForceDone(xlogfname);
	else
		XLogArchiveNotify(xlogfname);

In src/backend/replication/walreceiver.c:

                        /*
                         * Create .done file forcibly to prevent the streamed segment from
                         * being archived later.
                         */
                        XLogFileName(xlogfname, recvFileTLI, recvSegNo, wal_segment_size);
                        if (XLogArchiveMode != ARCHIVE_MODE_ALWAYS)
                                XLogArchiveForceDone(xlogfname);
                        else
                                XLogArchiveNotify(xlogfname);

Categories

Backup, Configuration, GUC configuration item, Replication, Storage, WAL

See also

archive_command, pg_stat_archiver