mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
Don't warn when stop-auto is enabled on PostgreSQL >= 9.6.
PostgreSQL >= 9.6 uses non-exclusive backup which has implicit stop-auto since the backup will stop when the connection is terminated. The warning was made more verbose in 1f2ce45e but this now seems like a bad idea since there are likely users with mixed version environments where stop-auto is enabled globally. There's no reason to fill their logs with warnings over a harmless option. If anything we should warn when stop-auto is explicitly set to false but this doesn't seem very important either. Revert to the prior behavior, which is to warn and reset when stop-auto is enabled on PostgreSQL < 9.3.
This commit is contained in:
parent
03849840b8
commit
6bd280f7bd
@ -270,10 +270,9 @@ backupInit(const InfoBackup *infoBackup)
|
||||
}
|
||||
|
||||
// Only allow stop auto in PostgreSQL >= 9.3 and <= 9.5
|
||||
if (cfgOptionBool(cfgOptStopAuto) && (result->version < PG_VERSION_93 || result->version > PG_VERSION_95))
|
||||
if (cfgOptionBool(cfgOptStopAuto) && result->version < PG_VERSION_93)
|
||||
{
|
||||
LOG_WARN(
|
||||
CFGOPT_STOP_AUTO " option is only available in " PG_NAME " >= " PG_VERSION_93_STR " and <= " PG_VERSION_95_STR);
|
||||
LOG_WARN(CFGOPT_STOP_AUTO " option is only available in " PG_NAME " >= " PG_VERSION_93_STR);
|
||||
cfgOptionSet(cfgOptStopAuto, cfgSourceParam, BOOL_FALSE_VAR);
|
||||
}
|
||||
|
||||
|
18
src/db/db.c
18
src/db/db.c
@ -307,16 +307,20 @@ dbBackupStart(Db *this, bool startFast, bool stopAuto)
|
||||
// If stop-auto is enabled check for a running backup
|
||||
if (stopAuto)
|
||||
{
|
||||
// This feature is not supported for PostgreSQL >= 9.6 since backups are run in non-exclusive mode
|
||||
CHECK(dbPgVersion(this) >= PG_VERSION_93 && dbPgVersion(this) < PG_VERSION_96);
|
||||
// Feature is not supported in PostgreSQL < 9.3
|
||||
CHECK(dbPgVersion(this) >= PG_VERSION_93);
|
||||
|
||||
if (varBool(dbQueryColumn(this, STRDEF("select pg_catalog.pg_is_in_backup()::bool"))))
|
||||
// Feature is not needed for PostgreSQL >= 9.6 since backups are run in non-exclusive mode
|
||||
if (dbPgVersion(this) < PG_VERSION_96)
|
||||
{
|
||||
LOG_WARN(
|
||||
"the cluster is already in backup mode but no " PROJECT_NAME " backup process is running."
|
||||
" pg_stop_backup() will be called so a new backup can be started.");
|
||||
if (varBool(dbQueryColumn(this, STRDEF("select pg_catalog.pg_is_in_backup()::bool"))))
|
||||
{
|
||||
LOG_WARN(
|
||||
"the cluster is already in backup mode but no " PROJECT_NAME " backup process is running."
|
||||
" pg_stop_backup() will be called so a new backup can be started.");
|
||||
|
||||
dbBackupStop(this);
|
||||
dbBackupStop(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,6 +261,7 @@ testBackupPqScript(unsigned int pgVersion, time_t backupTimeStart, TestBackupPqS
|
||||
|
||||
// Start backup
|
||||
HRNPQ_MACRO_ADVISORY_LOCK(1, true),
|
||||
HRNPQ_MACRO_IS_IN_BACKUP(1, false),
|
||||
HRNPQ_MACRO_START_BACKUP_84_95(1, param.startFast, lsnStartStr, walSegmentStart),
|
||||
HRNPQ_MACRO_DATABASE_LIST_1(1, "test1"),
|
||||
HRNPQ_MACRO_TABLESPACE_LIST_0(1),
|
||||
@ -1009,7 +1010,7 @@ testRun(void)
|
||||
TEST_RESULT_LOG("P00 WARN: start-fast option is only available in PostgreSQL >= 8.4");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("reset stop-auto when PostgreSQL < 9.3 or PostgreSQL > 9.5");
|
||||
TEST_TITLE("reset stop-auto when PostgreSQL < 9.3");
|
||||
|
||||
// Create pg_control
|
||||
storagePutP(
|
||||
@ -1028,29 +1029,7 @@ testRun(void)
|
||||
TEST_RESULT_VOID(backupInit(infoBackupNew(PG_VERSION_84, 1000000000000000840, NULL)), "backup init");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptStopAuto), false, " check stop-auto");
|
||||
|
||||
TEST_RESULT_LOG("P00 WARN: stop-auto option is only available in PostgreSQL >= 9.3 and <= 9.5");
|
||||
|
||||
// Create pg_control
|
||||
storagePutP(
|
||||
storageNewWriteP(storageTest, strNewFmt("%s/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, strPtr(pg1Path))),
|
||||
pgControlTestToBuffer((PgControl){.version = PG_VERSION_96, .systemId = 1000000000000000960}));
|
||||
|
||||
harnessCfgLoad(cfgCmdBackup, argList);
|
||||
|
||||
TEST_RESULT_VOID(backupInit(infoBackupNew(PG_VERSION_96, 1000000000000000960, NULL)), "backup init");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptStopAuto), false, " check stop-auto");
|
||||
|
||||
TEST_RESULT_LOG("P00 WARN: stop-auto option is only available in PostgreSQL >= 9.3 and <= 9.5");
|
||||
|
||||
// Create pg_control
|
||||
storagePutP(
|
||||
storageNewWriteP(storageTest, strNewFmt("%s/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, strPtr(pg1Path))),
|
||||
pgControlTestToBuffer((PgControl){.version = PG_VERSION_95, .systemId = 1000000000000000950}));
|
||||
|
||||
harnessCfgLoad(cfgCmdBackup, argList);
|
||||
|
||||
TEST_RESULT_VOID(backupInit(infoBackupNew(PG_VERSION_95, 1000000000000000950, NULL)), "backup init");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptStopAuto), true, " check stop-auto");
|
||||
TEST_RESULT_LOG("P00 WARN: stop-auto option is only available in PostgreSQL >= 9.3");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("reset checksum-page when the cluster does not have checksums enabled");
|
||||
@ -1557,6 +1536,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNewFmt("--" CFGOPT_PG1_PATH "=%s", strPtr(pg1Path)));
|
||||
strLstAddZ(argList, "--" CFGOPT_REPO1_RETENTION_FULL "=1");
|
||||
strLstAddZ(argList, "--" CFGOPT_TYPE "=" BACKUP_TYPE_FULL);
|
||||
strLstAddZ(argList, "--" CFGOPT_STOP_AUTO);
|
||||
strLstAddZ(argList, "--no-" CFGOPT_COMPRESS);
|
||||
strLstAddZ(argList, "--no-" CFGOPT_ARCHIVE_CHECK);
|
||||
harnessCfgLoad(cfgCmdBackup, argList);
|
||||
@ -1638,6 +1618,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNewFmt("--" CFGOPT_PG1_PATH "=%s", strPtr(pg1Path)));
|
||||
strLstAddZ(argList, "--" CFGOPT_REPO1_RETENTION_FULL "=1");
|
||||
strLstAddZ(argList, "--" CFGOPT_TYPE "=" BACKUP_TYPE_FULL);
|
||||
strLstAddZ(argList, "--" CFGOPT_STOP_AUTO);
|
||||
strLstAddZ(argList, "--" CFGOPT_REPO1_HARDLINK);
|
||||
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_COPY);
|
||||
harnessCfgLoad(cfgCmdBackup, argList);
|
||||
@ -1795,6 +1776,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNewFmt("--" CFGOPT_PG1_PATH "=%s", strPtr(pg1Path)));
|
||||
strLstAddZ(argList, "--" CFGOPT_REPO1_RETENTION_FULL "=1");
|
||||
strLstAddZ(argList, "--" CFGOPT_TYPE "=" BACKUP_TYPE_DIFF);
|
||||
strLstAddZ(argList, "--" CFGOPT_STOP_AUTO);
|
||||
strLstAddZ(argList, "--" CFGOPT_REPO1_HARDLINK);
|
||||
harnessCfgLoad(cfgCmdBackup, argList);
|
||||
|
||||
|
@ -289,7 +289,7 @@ testRun(void)
|
||||
|
||||
TEST_ASSIGN(db, dbGet(true, true, false), "get primary");
|
||||
|
||||
TEST_ASSIGN(backupStartResult, dbBackupStart(db.primary, false, false), "start backup");
|
||||
TEST_ASSIGN(backupStartResult, dbBackupStart(db.primary, false, true), "start backup");
|
||||
TEST_RESULT_STR_Z(backupStartResult.lsn, "3/3", "check lsn");
|
||||
TEST_RESULT_STR_Z(backupStartResult.walSegmentName, "000000010000000300000003", "check wal segment name");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user