You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	Update Archive::Info->archiveIdList() to return a valid error code instead of unknown.
This commit is contained in:
		| @@ -151,6 +151,10 @@ | ||||
|                         <p>Show exact log level required for stack trace param output instead of just <quote>debug</quote>.</p> | ||||
|                     </release-item> | ||||
|  | ||||
|                     <release-item> | ||||
|                         <p>Update <code>Archive::Info->archiveIdList()</code> to return a valid error code instead of unknown.</p> | ||||
|                     </release-item> | ||||
|  | ||||
|                     <release-item> | ||||
|                         <p>Add <code>cvtBoolToConstZ()</code> to simplify conversion of boolean to string.</p> | ||||
|                     </release-item> | ||||
|   | ||||
| @@ -285,7 +285,9 @@ sub archiveIdList | ||||
|     # If the archive id has still not been found, then error | ||||
|     if (@stryArchiveId == 0) | ||||
|     { | ||||
|         confess &log(ERROR, "unable to retrieve the archive id for database version '$strDbVersion' and system-id '$ullDbSysId'"); | ||||
|         confess &log( | ||||
|             ERROR, "unable to retrieve the archive id for database version '$strDbVersion' and system-id '$ullDbSysId'", | ||||
|             ERROR_ARCHIVE_MISMATCH); | ||||
|     } | ||||
|  | ||||
|     # Return from function and log return values if any | ||||
|   | ||||
| @@ -1159,7 +1159,9 @@ static const EmbeddedModule embeddedModule[] = | ||||
|             "\n\n" | ||||
|             "if (@stryArchiveId == 0)\n" | ||||
|             "{\n" | ||||
|             "confess &log(ERROR, \"unable to retrieve the archive id for database version '$strDbVersion' and system-id '$ullDbSysId'\");\n" | ||||
|             "confess &log(\n" | ||||
|             "ERROR, \"unable to retrieve the archive id for database version '$strDbVersion' and system-id '$ullDbSysId'\",\n" | ||||
|             "ERROR_ARCHIVE_MISMATCH);\n" | ||||
|             "}\n" | ||||
|             "\n\n" | ||||
|             "return logDebugReturn\n" | ||||
|   | ||||
| @@ -194,8 +194,8 @@ P00   INFO: archive-get command end: completed successfully | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG | ||||
| ------------------------------------------------------------------------------------------------------------------------------------ | ||||
| P00   INFO: archive-get command begin [BACKREST-VERSION]: [000000010000000100000001, [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG] --no-compress --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --log-subprocess --no-log-timestamp --pg1-path=[TEST_PATH]/db-master/db/base --protocol-timeout=60 --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=[TEST_PATH]/db-master/repo --stanza=db | ||||
| P00  ERROR: [125]: unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
| P00   INFO: archive-get command end: aborted with exception [125] | ||||
| P00  ERROR: [044]: unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
| P00   INFO: archive-get command end: aborted with exception [044] | ||||
|  | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 | ||||
| ------------------------------------------------------------------------------------------------------------------------------------ | ||||
| @@ -207,8 +207,8 @@ P00   INFO: archive-push command end: aborted with exception [044] | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG | ||||
| ------------------------------------------------------------------------------------------------------------------------------------ | ||||
| P00   INFO: archive-get command begin [BACKREST-VERSION]: [000000010000000100000001, [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG] --no-compress --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --log-subprocess --no-log-timestamp --pg1-path=[TEST_PATH]/db-master/db/base --protocol-timeout=60 --repo1-cipher-pass=<redacted> --repo1-cipher-type=aes-256-cbc --repo1-path=[TEST_PATH]/db-master/repo --stanza=db | ||||
| P00  ERROR: [125]: unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
| P00   INFO: archive-get command end: aborted with exception [125] | ||||
| P00  ERROR: [044]: unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
| P00   INFO: archive-get command end: aborted with exception [044] | ||||
|  | ||||
| stop db stanza (db-master host) | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db stop | ||||
|   | ||||
| @@ -171,8 +171,8 @@ P00   INFO: archive-get command end: completed successfully | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG | ||||
| ------------------------------------------------------------------------------------------------------------------------------------ | ||||
| P00   INFO: archive-get command begin [BACKREST-VERSION]: [000000010000000100000001, [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG] --no-compress --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/db-master/pgbackrest.conf --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --log-subprocess --no-log-timestamp --pg1-path=[TEST_PATH]/db-master/db/base --protocol-timeout=60 --repo1-host=backup --repo1-host-cmd=[BACKREST-BIN] --repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf --repo1-host-user=[USER-1] --stanza=db | ||||
| P00  ERROR: [125]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
| P00   INFO: archive-get command end: aborted with exception [125] | ||||
| P00  ERROR: [044]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
| P00   INFO: archive-get command end: aborted with exception [044] | ||||
|  | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 | ||||
| ------------------------------------------------------------------------------------------------------------------------------------ | ||||
| @@ -184,8 +184,8 @@ P00   INFO: archive-push command end: aborted with exception [044] | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG | ||||
| ------------------------------------------------------------------------------------------------------------------------------------ | ||||
| P00   INFO: archive-get command begin [BACKREST-VERSION]: [000000010000000100000001, [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG] --no-compress --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/db-master/pgbackrest.conf --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --log-subprocess --no-log-timestamp --pg1-path=[TEST_PATH]/db-master/db/base --protocol-timeout=60 --repo1-host=backup --repo1-host-cmd=[BACKREST-BIN] --repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf --repo1-host-user=[USER-1] --stanza=db | ||||
| P00  ERROR: [125]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
| P00   INFO: archive-get command end: aborted with exception [125] | ||||
| P00  ERROR: [044]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
| P00   INFO: archive-get command end: aborted with exception [044] | ||||
|  | ||||
| stop db stanza (db-master host) | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db stop | ||||
|   | ||||
| @@ -72,7 +72,7 @@ P00  ERROR: [044]: raised from remote process on 'backup': WAL segment version 9 | ||||
|  | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG | ||||
| ------------------------------------------------------------------------------------------------------------------------------------ | ||||
| P00  ERROR: [125]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
| P00  ERROR: [044]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
|  | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 | ||||
| ------------------------------------------------------------------------------------------------------------------------------------ | ||||
| @@ -81,7 +81,7 @@ P00  ERROR: [044]: raised from remote process on 'backup': WAL segment system-id | ||||
|  | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG | ||||
| ------------------------------------------------------------------------------------------------------------------------------------ | ||||
| P00  ERROR: [125]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
| P00  ERROR: [044]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '1000000000000000094' | ||||
|  | ||||
| stop db stanza (db-master host) | ||||
| > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db stop | ||||
|   | ||||
| @@ -113,7 +113,7 @@ sub run | ||||
|         # db-version, db-sys-id passed but combination doesn't exist in archive.info history | ||||
|         #--------------------------------------------------------------------------------------------------------------------------- | ||||
|         $self->testException(sub {archiveGetCheck( | ||||
|             PG_VERSION_95, $self->dbSysId(PG_VERSION_94), undef, false)}, ERROR_UNKNOWN, | ||||
|             PG_VERSION_95, $self->dbSysId(PG_VERSION_94), undef, false)}, ERROR_ARCHIVE_MISMATCH, | ||||
|             "unable to retrieve the archive id for database version '" . PG_VERSION_95 . "' and system-id '" . | ||||
|             $self->dbSysId(PG_VERSION_94) . "'"); | ||||
|  | ||||
|   | ||||
| @@ -163,7 +163,8 @@ sub run | ||||
|             {strDbVersion => PG_VERSION_93, ullDbSysId => $self->dbSysId(PG_VERSION_93)})}, | ||||
|             PG_VERSION_93 . "-13", 'archiveId - return only newest archiveId for multiple histories'); | ||||
|  | ||||
|         $self->testException(sub {$oArchiveInfo->archiveId({strDbVersion => PG_VERSION_94, ullDbSysId => BOGUS})}, ERROR_UNKNOWN, | ||||
|         $self->testException( | ||||
|             sub {$oArchiveInfo->archiveId({strDbVersion => PG_VERSION_94, ullDbSysId => BOGUS})}, ERROR_ARCHIVE_MISMATCH, | ||||
|             "unable to retrieve the archive id for database version '" . PG_VERSION_94 . "' and system-id '" . BOGUS . "'"); | ||||
|  | ||||
|         $self->testException(sub {$oArchiveInfo->check(PG_VERSION_94, $self->dbSysId(PG_VERSION_94))}, ERROR_ARCHIVE_MISMATCH, | ||||
| @@ -179,7 +180,8 @@ sub run | ||||
|         $self->testResult(sub {(@stryArchiveId == 1) && ($stryArchiveId[0] eq PG_VERSION_94 . "-12")}, true, | ||||
|             'archiveIdList - returns older archiveId'); | ||||
|  | ||||
|         $self->testException(sub {$oArchiveInfo->archiveIdList(PG_VERSION_95, $self->dbSysId(PG_VERSION_94))}, ERROR_UNKNOWN, | ||||
|         $self->testException( | ||||
|             sub {$oArchiveInfo->archiveIdList(PG_VERSION_95, $self->dbSysId(PG_VERSION_94))}, ERROR_ARCHIVE_MISMATCH, | ||||
|             "unable to retrieve the archive id for database version '" . PG_VERSION_95 . "' and system-id '" . | ||||
|             $self->dbSysId(PG_VERSION_94) . "'"); | ||||
|     } | ||||
|   | ||||
| @@ -286,7 +286,7 @@ sub run | ||||
|  | ||||
|         $oHostDbMaster->executeSimple( | ||||
|             $strCommandGet . " ${strSourceFile1} ${strWalPath}/RECOVERYXLOG", | ||||
|             {iExpectedExitStatus => ERROR_UNKNOWN, oLogTest => $self->expect()}); | ||||
|             {iExpectedExitStatus => ERROR_ARCHIVE_MISMATCH, oLogTest => $self->expect()}); | ||||
|  | ||||
|         # Restore the file to its original condition | ||||
|         $oHostBackup->infoRestore(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE)); | ||||
| @@ -305,7 +305,7 @@ sub run | ||||
|  | ||||
|         $oHostDbMaster->executeSimple( | ||||
|             $strCommandGet . " ${strSourceFile1} ${strWalPath}/RECOVERYXLOG", | ||||
|             {iExpectedExitStatus => ERROR_UNKNOWN, oLogTest => $self->expect()}); | ||||
|             {iExpectedExitStatus => ERROR_ARCHIVE_MISMATCH, oLogTest => $self->expect()}); | ||||
|  | ||||
|         # Restore the file to its original condition | ||||
|         $oHostBackup->infoRestore(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user