1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-09-16 09:06:18 +02:00

Fixed an issue where the db-port option specified on the backup server would not be properly passed to the remote unless it was from the first configured database.

Reported by Michael Vitale.
This commit is contained in:
David Steele
2016-12-10 14:05:28 -05:00
parent 1a5fa920e6
commit b4884e5a0b
15 changed files with 75 additions and 13 deletions

View File

@@ -139,6 +139,10 @@
<release-bug-list>
<release-item>
<release-item-contributor-list>
<release-item-ideator id="kulkarni.nikhilchandra"/>
</release-item-contributor-list>
<p>Fixed an issue where options that were invalid for the specified command could be provided on the command-line without generating an error. The options were ignored and did not cause any change in behavior, but it did lead to some confusion. Invalid options will now generate an error.</p>
</release-item>
@@ -147,8 +151,20 @@
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-ideator id="vondendriesch.adrian"/>
</release-item-contributor-list>
<p>Fixed an issue that prevented errors from being output to the console before the logging system was initialized, i.e. while parsing options. Error codes were still being returned accurately so this would not have made a process look like it succeeded when it did not.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-ideator id="vitale.michael"/>
</release-item-contributor-list>
<p>Fixed an issue where the <br-option>db-port</br-option> option specified on the backup server would not be properly passed to the remote unless it was from the first configured database.</p>
</release-item>
</release-bug-list>
<release-feature-list>

View File

@@ -1520,7 +1520,6 @@ my %oOptionRule =
{
&CMD_BACKUP => true,
&CMD_CHECK => true,
&CMD_REMOTE => true,
},
},

View File

@@ -124,6 +124,7 @@ sub protocolGet
my $strOptionConfig = OPTION_BACKUP_CONFIG;
my $strOptionHost = OPTION_BACKUP_HOST;
my $strOptionUser = OPTION_BACKUP_USER;
my $strOptionDbPort = undef;
my $strOptionDbSocketPath = undef;
if ($strRemoteType eq DB)
@@ -134,6 +135,14 @@ sub protocolGet
$strOptionUser = optionIndex(OPTION_DB_USER, $iRemoteIdx);
}
# Db socket is not valid in all contexts (restore, for instance)
if (optionValid(optionIndex(OPTION_DB_PORT, $iRemoteIdx)))
{
$strOptionDbPort =
optionSource(optionIndex(OPTION_DB_PORT, $iRemoteIdx)) eq SOURCE_DEFAULT ?
undef : optionGet(optionIndex(OPTION_DB_PORT, $iRemoteIdx));
}
# Db socket is not valid in all contexts (restore, for instance)
if (optionValid(optionIndex(OPTION_DB_SOCKET_PATH, $iRemoteIdx)))
{
@@ -156,8 +165,14 @@ sub protocolGet
&OPTION_TYPE => {value => $strRemoteType},
&OPTION_LOG_PATH => {},
&OPTION_LOCK_PATH => {},
&OPTION_DB_PORT => {value => $strOptionDbPort},
&OPTION_DB_SOCKET_PATH => {value => $strOptionDbSocketPath},
# ??? Not very pretty but will work until there is nicer code in commandWrite to handle this case. It
# doesn't hurt to pass these params but it's messy and distracting for debugging.
optionIndex(OPTION_DB_PORT, 2) => {},
optionIndex(OPTION_DB_SOCKET_PATH, 2) => {},
# Set protocol options explicitly so values are not picked up from remote config files
&OPTION_BUFFER_SIZE => {value => optionGet(OPTION_BUFFER_SIZE)},
&OPTION_COMPRESS_LEVEL => {value => optionGet(OPTION_COMPRESS_LEVEL)},

View File

@@ -34,7 +34,7 @@ start-fast=y
-----------------------------------------------------------
[db]
db-path=[TEST_PATH]/db-standby/db/base
db-port=[PORT-1]
db-port=[PORT-2]
db-socket-path=[TEST_PATH]/db-standby/db
[global]
@@ -93,7 +93,7 @@ start-fast=y
-----------------------------------------------------------
[db]
db-path=[TEST_PATH]/db-standby/db/base
db-port=[PORT-1]
db-port=[PORT-2]
db-socket-path=[TEST_PATH]/db-standby/db
[db:restore]
@@ -144,7 +144,7 @@ start-fast=y
-----------------------------------------------------------
[db]
db-path=[TEST_PATH]/db-standby/db/base
db-port=[PORT-1]
db-port=[PORT-2]
db-socket-path=[TEST_PATH]/db-standby/db
[db:restore]

View File

@@ -29,7 +29,7 @@ repo-path=[TEST_PATH]/db-standby/repo
-----------------------------------------------------------
[db]
db-path=[TEST_PATH]/db-standby/db/base
db-port=[PORT-1]
db-port=[PORT-2]
db-socket-path=[TEST_PATH]/db-standby/db
db2-cmd=[BACKREST-BIN]
db2-config=[TEST_PATH]/db-master/pgbackrest.conf
@@ -88,7 +88,7 @@ repo-path=[TEST_PATH]/db-standby/repo
-----------------------------------------------------------
[db]
db-path=[TEST_PATH]/db-standby/db/base
db-port=[PORT-1]
db-port=[PORT-2]
db-socket-path=[TEST_PATH]/db-standby/db
db2-cmd=[BACKREST-BIN]
db2-config=[TEST_PATH]/db-master/pgbackrest.conf
@@ -139,7 +139,7 @@ repo-path=[TEST_PATH]/db-standby/repo
-----------------------------------------------------------
[db]
db-path=[TEST_PATH]/db-standby/db/base
db-port=[PORT-1]
db-port=[PORT-2]
db-socket-path=[TEST_PATH]/db-standby/db
db2-cmd=[BACKREST-BIN]
db2-config=[TEST_PATH]/db-master/pgbackrest.conf

View File

@@ -88,6 +88,7 @@ db-cmd=[BACKREST-BIN]
db-config=[TEST_PATH]/db-master/pgbackrest.conf
db-host=db-master
db-path=[TEST_PATH]/db-master/db/base
db-port=[PORT-1]
db-user=[USER-2]
[global]
@@ -166,6 +167,7 @@ db-cmd=[BACKREST-BIN]
db-config=[TEST_PATH]/db-master/pgbackrest.conf
db-host=db-master
db-path=[TEST_PATH]/db-master/db/base
db-port=[PORT-1]
db-user=[USER-2]
[global]
@@ -232,6 +234,7 @@ db-cmd=[BACKREST-BIN]
db-config=[TEST_PATH]/db-master/pgbackrest.conf
db-host=db-master
db-path=[TEST_PATH]/db-master/db/base
db-port=[PORT-1]
db-user=[USER-2]
[global]
@@ -366,6 +369,7 @@ db-cmd=[BACKREST-BIN]
db-config=[TEST_PATH]/db-master/pgbackrest.conf
db-host=db-master
db-path=[TEST_PATH]/db-master/db/base
db-port=[PORT-1]
db-user=[USER-2]
[global]

View File

@@ -31,6 +31,7 @@ db-cmd=[BACKREST-BIN]
db-config=[TEST_PATH]/db-master/pgbackrest.conf
db-host=db-master
db-path=[TEST_PATH]/db-master/db/base
db-port=[PORT-1]
db-user=[USER-2]
[global]
@@ -75,6 +76,7 @@ db-cmd=[BACKREST-BIN]
db-config=[TEST_PATH]/db-master/pgbackrest.conf
db-host=db-master
db-path=[TEST_PATH]/db-master/db/base
db-port=[PORT-1]
db-user=[USER-2]
[global]

View File

@@ -36,6 +36,7 @@ db-cmd=[BACKREST-BIN]
db-config=[TEST_PATH]/db-master/pgbackrest.conf
db-host=db-master
db-path=[TEST_PATH]/db-master/db/base
db-port=[PORT-1]
db-user=[USER-2]
[global]
@@ -86,6 +87,7 @@ db-cmd=[BACKREST-BIN]
db-config=[TEST_PATH]/db-master/pgbackrest.conf
db-host=db-master
db-path=[TEST_PATH]/db-master/db/base
db-port=[PORT-1]
db-user=[USER-2]
[global]

View File

@@ -35,6 +35,7 @@ db-cmd=[BACKREST-BIN]
db-config=[TEST_PATH]/db-master/pgbackrest.conf
db-host=db-master
db-path=[TEST_PATH]/db-master/db/base
db-port=[PORT-1]
db-user=[USER-2]
[global]
@@ -83,6 +84,7 @@ db-cmd=[BACKREST-BIN]
db-config=[TEST_PATH]/db-master/pgbackrest.conf
db-host=db-master
db-path=[TEST_PATH]/db-master/db/base
db-port=[PORT-1]
db-user=[USER-2]
[global]

View File

@@ -29,7 +29,7 @@ repo-path=[TEST_PATH]/backup/repo
-----------------------------------------------------------
[db]
db-path=[TEST_PATH]/db-standby/db/base
db-port=[PORT-1]
db-port=[PORT-2]
db-socket-path=[TEST_PATH]/db-standby/db
[global]
@@ -52,11 +52,13 @@ db1-cmd=[BACKREST-BIN]
db1-config=[TEST_PATH]/db-master/pgbackrest.conf
db1-host=db-master
db1-path=[TEST_PATH]/db-master/db/base
db1-port=[PORT-1]
db1-user=[USER-2]
db2-cmd=[BACKREST-BIN]
db2-config=[TEST_PATH]/db-standby/pgbackrest.conf
db2-host=db-standby
db2-path=[TEST_PATH]/db-standby/db/base
db2-port=[PORT-2]
db2-user=[USER-2]
[global]
@@ -110,7 +112,7 @@ repo-path=[TEST_PATH]/backup/repo
-----------------------------------------------------------
[db]
db-path=[TEST_PATH]/db-standby/db/base
db-port=[PORT-1]
db-port=[PORT-2]
db-socket-path=[TEST_PATH]/db-standby/db
[db:restore]
@@ -135,11 +137,13 @@ db1-cmd=[BACKREST-BIN]
db1-config=[TEST_PATH]/db-master/pgbackrest.conf
db1-host=db-master
db1-path=[TEST_PATH]/db-master/db/base
db1-port=[PORT-1]
db1-user=[USER-2]
db2-cmd=[BACKREST-BIN]
db2-config=[TEST_PATH]/db-standby/pgbackrest.conf
db2-host=db-standby
db2-path=[TEST_PATH]/db-standby/db/base
db2-port=[PORT-2]
db2-user=[USER-2]
[global]
@@ -183,7 +187,7 @@ repo-path=[TEST_PATH]/backup/repo
-----------------------------------------------------------
[db]
db-path=[TEST_PATH]/db-standby/db/base
db-port=[PORT-1]
db-port=[PORT-2]
db-socket-path=[TEST_PATH]/db-standby/db
[db:restore]
@@ -208,11 +212,13 @@ db1-cmd=[BACKREST-BIN]
db1-config=[TEST_PATH]/db-master/pgbackrest.conf
db1-host=db-master
db1-path=[TEST_PATH]/db-master/db/base
db1-port=[PORT-1]
db1-user=[USER-2]
db2-cmd=[BACKREST-BIN]
db2-config=[TEST_PATH]/db-standby/pgbackrest.conf
db2-host=db-standby
db2-path=[TEST_PATH]/db-standby/db/base
db2-port=[PORT-2]
db2-user=[USER-2]
[global]

View File

@@ -4260,3 +4260,6 @@ diff backup - protocol shutdown timeout (backup host)
P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 TEST: PgBaCkReStTeSt-BACKUP-STOP-PgBaCkReStTeSt
P00 ERROR: [141]: remote process terminated on db-master host: unable to read line after 2 second(s)
P00 WARN: unable to shutdown protocol [141]: remote process terminated on db-master host: unable to read line after 2 second(s)
HINT: the process completed all operations successfully but protocol-timeout may need to be increased.

View File

@@ -2118,7 +2118,8 @@ sub backupTestRun
OPTION_DEFAULT_RESTORE_SET, undef, \%oRemapHash, $bDelta, $bForce, $strType, $strTarget, $bTargetExclusive,
$strTargetAction, $strTargetTimeline, $oRecoveryHashRef, $strComment, $iExpectedExitStatus,
' --recovery-option=standby_mode=on' .
' --recovery-option="primary_conninfo=host=' . HOST_DB_MASTER . ' port=' . HOST_DB_PORT . ' user=replicator"');
' --recovery-option="primary_conninfo=host=' . HOST_DB_MASTER .
' port=' . $oHostDbMaster->dbPort() . ' user=replicator"');
$oHostDbStandby->clusterStart({bHotStandby => true});

View File

@@ -918,6 +918,12 @@ sub configCreate
$oParamHash{$strStanza}{optionIndex(OPTION_DB_USER, 1, $bForce)} = $oHostDb1->userGet();
$oParamHash{$strStanza}{optionIndex(OPTION_DB_CMD, 1, $bForce)} = $oHostDb1->backrestExe();
$oParamHash{$strStanza}{optionIndex(OPTION_DB_CONFIG, 1, $bForce)} = $oHostDb1->backrestConfig();
# Port can't be configured for a synthetic host
if (!$self->synthetic())
{
$oParamHash{$strStanza}{optionIndex(OPTION_DB_PORT, 1, $bForce)} = $oHostDb1->dbPort();
}
}
$oParamHash{$strStanza}{optionIndex(OPTION_DB_PATH, 1, $bForce)} = $oHostDb1->dbBasePath();
@@ -929,6 +935,12 @@ sub configCreate
$oParamHash{$strStanza}{optionIndex(OPTION_DB_CMD, 2)} = $oHostDb2->backrestExe();
$oParamHash{$strStanza}{optionIndex(OPTION_DB_CONFIG, 2)} = $oHostDb2->backrestConfig();
$oParamHash{$strStanza}{optionIndex(OPTION_DB_PATH, 2)} = $oHostDb2->dbBasePath();
# Only test explicit ports on the backup server. This is so locally configured ports are also tested.
if (!$self->synthetic() && $self->nameTest(HOST_BACKUP))
{
$oParamHash{$strStanza}{optionIndex(OPTION_DB_PORT, 2)} = $oHostDb2->dbPort();
}
}
}

View File

@@ -93,7 +93,7 @@ sub new
$self->paramSet(HOST_PARAM_DB_BIN_PATH, $oHostGroup->paramGet(HOST_PARAM_DB_BIN_PATH));
$self->paramSet(HOST_PARAM_DB_VERSION, $strDbVersion);
$self->paramSet(HOST_PARAM_DB_SOCKET_PATH, $self->dbPath());
$self->paramSet(HOST_PARAM_DB_PORT, HOST_DB_PORT);
$self->paramSet(HOST_PARAM_DB_PORT, defined($$oParam{bStandby}) && $$oParam{bStandby} ? 6544 : 6543);
$self->paramSet(HOST_PARAM_DB_LOG_PATH, $self->testPath());
$self->paramSet(HOST_PARAM_DB_LOG_FILE, $self->dbLogPath() . '/postgresql.log');

View File

@@ -358,7 +358,7 @@ sub regExpReplaceAll
$strLine = $self->regExpReplace($strLine, 'USER', '[^ ]+\@db\-master', '^[^\@]+');
$strLine = $self->regExpReplace($strLine, 'USER', '[\( ]{1}' . TEST_USER . '[\,\)]{1}', TEST_USER);
$strLine = $self->regExpReplace($strLine, 'PORT', 'db-port=[0-9]+', '[0-9]+$');
$strLine = $self->regExpReplace($strLine, 'PORT', 'db[1-9]{0,1}-port=[0-9]+', '[0-9]+$');
# Replace year when it falls on a single line when executing ls -1R
$strLine = $self->regExpReplace($strLine, 'YEAR', '^20[0-9]{2}$');