diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 66312b53b8..9d0f3608c4 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3597,9 +3597,11 @@ include_dir 'conf.d' This parameter can only be set in the postgresql.conf - file or on the server command line. It is ignored unless + file or on the server command line. It is only used if archive_mode was enabled at server start and - archive_library is set to an empty string. + archive_library is set to an empty string. If both + archive_command and archive_library + are set, archiving will fail. If archive_command is an empty string (the default) while archive_mode is enabled (and archive_library is set to an empty string), WAL archiving is temporarily @@ -3624,7 +3626,9 @@ include_dir 'conf.d' The library to use for archiving completed WAL file segments. If set to an empty string (the default), archiving via shell is enabled, and - is used. Otherwise, the specified + is used. If both + archive_command and archive_library + are set, archiving will fail. Otherwise, the specified shared library is used for archiving. For more information, see and . diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c index 3868cd7bd3..39c2115943 100644 --- a/src/backend/postmaster/pgarch.c +++ b/src/backend/postmaster/pgarch.c @@ -801,7 +801,8 @@ HandlePgArchInterrupts(void) archiveLibChanged = strcmp(XLogArchiveLibrary, archiveLib) != 0; pfree(archiveLib); - if (archiveLibChanged) + if (archiveLibChanged || + (XLogArchiveLibrary[0] != '\0' && XLogArchiveCommand[0] != '\0')) { /* * Call the currently loaded archive module's shutdown callback, @@ -809,17 +810,25 @@ HandlePgArchInterrupts(void) */ call_archive_module_shutdown_callback(0, 0); - /* - * Ideally, we would simply unload the previous archive module and - * load the new one, but there is presently no mechanism for - * unloading a library (see the comment above - * internal_load_library()). To deal with this, we simply restart - * the archiver. The new archive module will be loaded when the - * new archiver process starts up. - */ - ereport(LOG, - (errmsg("restarting archiver process because value of " - "\"archive_library\" was changed"))); + if (archiveLibChanged) + { + /* + * Ideally, we would simply unload the previous archive module + * and load the new one, but there is presently no mechanism + * for unloading a library (see the comment above + * internal_load_library()). To deal with this, we simply + * restart the archiver. The new archive module will be loaded + * when the new archiver process starts up. + */ + ereport(LOG, + (errmsg("restarting archiver process because value of " + "\"archive_library\" was changed"))); + } + else + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("both archive_command and archive_library specified"), + errdetail("Only one of archive_command, archive_library may be set."))); proc_exit(0); } @@ -836,6 +845,12 @@ LoadArchiveLibrary(void) { ArchiveModuleInit archive_init; + if (XLogArchiveLibrary[0] != '\0' && XLogArchiveCommand[0] != '\0') + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("both archive_command and archive_library specified"), + errdetail("Only one of archive_command, archive_library may be set."))); + memset(&ArchiveContext, 0, sizeof(ArchiveModuleCallbacks)); /*