diff --git a/doc/xml/release.xml b/doc/xml/release.xml index cefa6a0a4..46ae16d1a 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -25,6 +25,15 @@

Prevent defunct processes in asynchronous archive commands.

+ + + + + + +

Error when archive-get/archive-push/restore are not run on a host.

+
+ diff --git a/src/command/archive/get/get.c b/src/command/archive/get/get.c index 8f425c4d0..2bed5682e 100644 --- a/src/command/archive/get/get.c +++ b/src/command/archive/get/get.c @@ -107,6 +107,9 @@ cmdArchiveGet(void) { FUNCTION_LOG_VOID(logLevelDebug); + // PostgreSQL must be local + pgIsLocalVerify(); + // Set the result assuming the archive file will not be found int result = 1; @@ -315,6 +318,9 @@ cmdArchiveGetAsync(void) { FUNCTION_LOG_VOID(logLevelDebug); + // PostgreSQL must be local + pgIsLocalVerify(); + MEM_CONTEXT_TEMP_BEGIN() { TRY_BEGIN() diff --git a/src/command/archive/push/push.c b/src/command/archive/push/push.c index d08d630f0..8e36c5b98 100644 --- a/src/command/archive/push/push.c +++ b/src/command/archive/push/push.c @@ -257,6 +257,9 @@ cmdArchivePush(void) ASSERT(cfgCommand() == cfgCmdArchivePush); + // PostgreSQL must be local + pgIsLocalVerify(); + MEM_CONTEXT_TEMP_BEGIN() { // Make sure there is a parameter to retrieve the WAL segment from @@ -428,6 +431,9 @@ cmdArchivePushAsync(void) ASSERT(cfgCommand() == cfgCmdArchivePush && cfgCommandRole() == cfgCmdRoleAsync); + // PostgreSQL must be local + pgIsLocalVerify(); + MEM_CONTEXT_TEMP_BEGIN() { // Make sure there is a parameter with the wal path diff --git a/test/src/module/command/archiveGetTest.c b/test/src/module/command/archiveGetTest.c index 17aa03018..423220980 100644 --- a/test/src/module/command/archiveGetTest.c +++ b/test/src/module/command/archiveGetTest.c @@ -330,6 +330,21 @@ testRun(void) TEST_ERROR(cmdArchiveGetAsync(), ParamInvalidError, "at least one wal segment is required"); + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("command must be run on the pg host"); + + StringList *argList = strLstNew(); + strLstAddZ(argList, "--" CFGOPT_PG1_HOST "=host"); + strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/pg"); + strLstAddZ(argList, "--" CFGOPT_REPO1_PATH "=/repo"); + strLstAddZ(argList, "--" CFGOPT_SPOOL_PATH "=/spool"); + strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC); + strLstAddZ(argList, "--" CFGOPT_STANZA "=test2"); + strLstAddZ(argList, "000000010000000100000001"); + harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleAsync, argList); + + TEST_ERROR(cmdArchiveGetAsync(), HostInvalidError, "archive-get command must be run on the PostgreSQL host"); + // Create pg_control file and archive.info // ------------------------------------------------------------------------------------------------------------------------- storagePutP( @@ -347,7 +362,7 @@ testRun(void) // Get a single segment // ------------------------------------------------------------------------------------------------------------------------- - StringList *argList = strLstDup(argCleanList); + argList = strLstDup(argCleanList); strLstAddZ(argList, "000000010000000100000001"); harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleAsync, argList); @@ -474,7 +489,21 @@ testRun(void) // ***************************************************************************************************************************** if (testBegin("cmdArchiveGet()")) { + TEST_TITLE("command must be run on the pg host"); + StringList *argList = strLstNew(); + strLstAddZ(argList, "--" CFGOPT_PG1_HOST "=host"); + strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/pg"); + strLstAddZ(argList, "--" CFGOPT_REPO1_PATH "=/repo"); + strLstAddZ(argList, "--" CFGOPT_STANZA "=test2"); + strLstAddZ(argList, "000000010000000100000001"); + strLstAddZ(argList, "pg_wal/000000010000000100000001"); + harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleDefault, argList); + + TEST_ERROR(cmdArchiveGet(), HostInvalidError, "archive-get command must be run on the PostgreSQL host"); + + // ------------------------------------------------------------------------------------------------------------------------- + argList = strLstNew(); strLstAddZ(argList, "pgbackrest-bogus"); // Break this until async tests are setup correctly strLstAddZ(argList, "--archive-timeout=1"); strLstAdd(argList, strNewFmt("--lock-path=%s/lock", testPath())); diff --git a/test/src/module/command/archivePushTest.c b/test/src/module/command/archivePushTest.c index db6bbf158..0589dfcd2 100644 --- a/test/src/module/command/archivePushTest.c +++ b/test/src/module/command/archivePushTest.c @@ -176,7 +176,18 @@ testRun(void) // ***************************************************************************************************************************** if (testBegin("Synchronous cmdArchivePush(), archivePushFile() and archivePushProtocol()")) { + TEST_TITLE("command must be run on the pg host"); + StringList *argList = strLstNew(); + strLstAddZ(argList, "--" CFGOPT_PG1_HOST "=host"); + strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/pg"); + strLstAddZ(argList, "--" CFGOPT_STANZA "=test2"); + harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleDefault, argList); + + TEST_ERROR(cmdArchivePush(), HostInvalidError, "archive-push command must be run on the PostgreSQL host"); + + // ------------------------------------------------------------------------------------------------------------------------- + argList = strLstNew(); strLstAddZ(argList, "--stanza=test"); harnessCfgLoad(cfgCmdArchivePush, argList); @@ -412,9 +423,21 @@ testRun(void) { harnessLogLevelSet(logLevelDetail); + TEST_TITLE("command must be run on the pg host"); + + StringList *argList = strLstNew(); + strLstAddZ(argList, "--" CFGOPT_PG1_HOST "=host"); + strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/pg"); + strLstAddZ(argList, "--" CFGOPT_SPOOL_PATH "=/spool"); + strLstAddZ(argList, "--" CFGOPT_STANZA "=test2"); + strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC); + harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argList); + + TEST_ERROR(cmdArchivePush(), HostInvalidError, "archive-push command must be run on the PostgreSQL host"); + // Call with a bogus exe name so the async process will error out and we can make sure timeouts work // ------------------------------------------------------------------------------------------------------------------------- - StringList *argList = strLstNew(); + argList = strLstNew(); strLstAddZ(argList, "pgbackrest-bogus"); strLstAddZ(argList, "--stanza=test"); strLstAddZ(argList, "--archive-async");