1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-07 00:35:37 +02:00

Use zero-based indexes when referring to option indexes.

There were a number of places in the code where "hostId" was used, but hostId is just the option group index + 1 so this led to a lot of +1 and -1 to convert the id to an index and vice versa.

Instead just use the zero based index wherever possible. This is pretty much everywhere except when the host-id option is read or set, or where a message is being formatted for the user.

Also fix a bug in protocolRemoteParam() where remotes spawned from the main process could get process ids that were not 0. Only the locals should spawn remotes with process id > 0. This seems to have been harmless since the process id is only a label, but it could be confusing when debugging.
This commit is contained in:
David Steele
2020-10-26 10:25:16 -04:00
committed by GitHub
parent ae35c4f029
commit d452e9cc38
21 changed files with 169 additions and 182 deletions

View File

@ -371,12 +371,12 @@ testRun(void)
TEST_ASSIGN(db, dbGet(false, false, false), "get primary and standby");
TEST_RESULT_VOID(checkDbConfig(PG_VERSION_92, db.primaryId, db.primary, false), "valid db config");
TEST_RESULT_VOID(checkDbConfig(PG_VERSION_92, db.primaryIdx, db.primary, false), "valid db config");
// Version mismatch
// -------------------------------------------------------------------------------------------------------------------------
TEST_ERROR_FMT(
checkDbConfig(PG_VERSION_94, db.primaryId, db.primary, false), DbMismatchError,
checkDbConfig(PG_VERSION_94, db.primaryIdx, db.primary, false), DbMismatchError,
"version '%s' and path '%s' queried from cluster do not match version '%s' and '%s' read from '%s/"
PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "'\n"
"HINT: the pg1-path and pg1-port settings likely reference different clusters.",
@ -385,7 +385,7 @@ testRun(void)
// Path mismatch
// -------------------------------------------------------------------------------------------------------------------------
TEST_ERROR_FMT(
checkDbConfig(PG_VERSION_92, db.standbyId, db.standby, true), DbMismatchError,
checkDbConfig(PG_VERSION_92, db.standbyIdx, db.standby, true), DbMismatchError,
"version '%s' and path '%s' queried from cluster do not match version '%s' and '%s' read from '%s/"
PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "'\n"
"HINT: the pg8-path and pg8-port settings likely reference different clusters.",
@ -397,7 +397,7 @@ testRun(void)
strLstAddZ(argList, "--no-archive-check");
harnessCfgLoad(cfgCmdCheck, argList);
TEST_RESULT_VOID(checkDbConfig(PG_VERSION_92, db.primaryId, db.primary, false), "valid db config --no-archive-check");
TEST_RESULT_VOID(checkDbConfig(PG_VERSION_92, db.primaryIdx, db.primary, false), "valid db config --no-archive-check");
// archive-check not valid for command
// -------------------------------------------------------------------------------------------------------------------------
@ -410,7 +410,7 @@ testRun(void)
harnessCfgLoad(cfgCmdStanzaCreate, argList);
TEST_RESULT_VOID(
checkDbConfig(PG_VERSION_92, db.primaryId, db.primary, false), "valid db config, archive-check not valid for command");
checkDbConfig(PG_VERSION_92, db.primaryIdx, db.primary, false), "valid db config, archive-check not valid for command");
TEST_RESULT_VOID(dbFree(db.primary), "free primary");
TEST_RESULT_VOID(dbFree(db.standby), "free standby");
@ -432,7 +432,7 @@ testRun(void)
TEST_ASSIGN(db, dbGet(true, true, false), "get primary");
TEST_ERROR_FMT(
checkDbConfig(PG_VERSION_92, db.primaryId, db.primary, false), FeatureNotSupportedError,
checkDbConfig(PG_VERSION_92, db.primaryIdx, db.primary, false), FeatureNotSupportedError,
"archive_mode=always not supported");
TEST_RESULT_VOID(dbFree(db.primary), "free primary");