1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-12-01 22:30:09 +02:00

Set application_name to "pgBackRest [command]" for database connections.

Suggested by Jens Wilke.
This commit is contained in:
David Steele
2016-10-05 21:15:10 -04:00
parent 0a4099fff8
commit 16d0e767ef
4 changed files with 38 additions and 0 deletions

View File

@@ -2100,10 +2100,26 @@ sub backupTestRun
{strTest => TEST_MANIFEST_BUILD, fTestDelay => $fTestDelay,
strOptionalParam => '--' . OPTION_STOP_AUTO . ' --no-' . OPTION_BACKUP_ARCHIVE_CHECK});
# Drop a table
$oHostDbMaster->sqlExecute('drop table test_remove');
$oHostDbMaster->sqlXlogRotate();
$oHostDbMaster->sqlExecute("update test set message = '$strIncrMessage'", {bCommit => true});
# Check that application name is set
if ($oHostDbMaster->dbVersion() >= PG_VERSION_APPLICATION_NAME)
{
my $strApplicationNameExpected = BACKREST_NAME . ' [' . CMD_BACKUP . ']';
my $strApplicationName = $oHostDbMaster->sqlSelectOne(
"select application_name from pg_stat_activity where application_name like '" . BACKREST_NAME . "%'");
if (!defined($strApplicationName) || $strApplicationName ne $strApplicationNameExpected)
{
confess &log(ERROR,
"application name '" . (defined($strApplicationName) ? $strApplicationName : '[null]') .
"' does not match '" . $strApplicationNameExpected . "'");
}
}
my $strIncrBackup = $oHostBackup->backupEnd($strType, $oExecuteBackup);
# Setup the xid target