pgbackrest.git / summary / log / commit / refs
commit 0ed37ab9e73fb59a5558b39bb292e0eb4f331ec9
Author: David Steele <david@crunchydata.com>
Date: Fri Aug 24 16:13:10 2018 +0000
Update Archive::Info->archiveIdList() to return a valid error code instead of unknown.
doc/xml/release.xml | 4 ++++
lib/pgBackRest/Archive/Info.pm | 4 +++-
src/perl/embed.auto.c | 4 +++-
test/expect/mock-archive-001.log | 8 ++++----
test/expect/mock-archive-002.log | 8 ++++----
test/expect/mock-archive-003.log | 4 ++--
test/lib/pgBackRestTest/Module/Archive/ArchiveGetPerlTest.pm | 2 +-
test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitPerlTest.pm | 6 ++++--
test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm | 4 ++--
9 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index a4a9a620c..14311bcdc 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -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>
diff --git a/lib/pgBackRest/Archive/Info.pm b/lib/pgBackRest/Archive/Info.pm
index b2bf71982..18483e60f 100644
--- a/lib/pgBackRest/Archive/Info.pm
+++ b/lib/pgBackRest/Archive/Info.pm
@@ -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
diff --git a/src/perl/embed.auto.c b/src/perl/embed.auto.c
index 8bc03b61d..9a437165c 100644
--- a/src/perl/embed.auto.c
+++ b/src/perl/embed.auto.c
@@ -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"
diff --git a/test/expect/mock-archive-001.log b/test/expect/mock-archive-001.log
index 60847725e..4856513ac 100644
--- a/test/expect/mock-archive-001.log
+++ b/test/expect/mock-archive-001.log
@@ -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
diff --git a/test/expect/mock-archive-002.log b/test/expect/mock-archive-002.log
index 86674cafe..3df6f394e 100644
--- a/test/expect/mock-archive-002.log
+++ b/test/expect/mock-archive-002.log
@@ -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
diff --git a/test/expect/mock-archive-003.log b/test/expect/mock-archive-003.log
index 0ba4cc0c4..c26137ffd 100644
--- a/test/expect/mock-archive-003.log
+++ b/test/expect/mock-archive-003.log
@@ -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
diff --git a/test/lib/pgBackRestTest/Module/Archive/ArchiveGetPerlTest.pm b/test/lib/pgBackRestTest/Module/Archive/ArchiveGetPerlTest.pm
index 2354da185..e15a957f8 100644
--- a/test/lib/pgBackRestTest/Module/Archive/ArchiveGetPerlTest.pm
+++ b/test/lib/pgBackRestTest/Module/Archive/ArchiveGetPerlTest.pm
@@ -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) . "'");
diff --git a/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitPerlTest.pm b/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitPerlTest.pm
index d99ba55de..862be9e7f 100644
--- a/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitPerlTest.pm
+++ b/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitPerlTest.pm
@@ -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) . "'");
}
diff --git a/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm b/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm
index 583486427..3775c1480 100644
--- a/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm
+++ b/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm
@@ -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));
[parent: 227656702700]