diff --git a/doc/xml/release.xml b/doc/xml/release.xml index b0dc4692d..f81d7e73f 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -25,6 +25,15 @@ + + + + + + +

Bypass database checks when stanza-delete issued with force.

+
+

Improve performance of non-blocking reads by using maximum buffer size.

@@ -7022,6 +7031,11 @@ guruguruguru + + Roman + hatifnatt + + Hans-Jürgen Schönig diff --git a/lib/pgBackRest/Stanza.pm b/lib/pgBackRest/Stanza.pm index c3bca4035..7e0766cea 100644 --- a/lib/pgBackRest/Stanza.pm +++ b/lib/pgBackRest/Stanza.pm @@ -307,18 +307,22 @@ sub stanzaDelete "\nHINT: has the pgbackrest stop command been run on this server?", ERROR_FILE_MISSING); } - # Get the master database object and index - my ($oDbMaster, $iMasterRemoteIdx) = dbObjectGet({bMasterOnly => true}); - - # Initialize the master file object and path - my $oStorageDbMaster = storageDb({iRemoteIdx => $iMasterRemoteIdx}); - - # Check if Postgres is running and if so only continue when forced - if ($oStorageDbMaster->exists(DB_FILE_POSTMASTERPID) && !cfgOption(CFGOPT_FORCE)) + # If a force has not been issued, then check the database + if (!cfgOption(CFGOPT_FORCE)) { - confess &log(ERROR, DB_FILE_POSTMASTERPID . " exists - looks like the postmaster is running. " . - "To delete stanza '${strStanza}', shutdown the postmaster for stanza '${strStanza}' and try again, " . - "or use --force.", ERROR_POSTMASTER_RUNNING); + # Get the master database object and index + my ($oDbMaster, $iMasterRemoteIdx) = dbObjectGet({bMasterOnly => true}); + + # Initialize the master file object and path + my $oStorageDbMaster = storageDb({iRemoteIdx => $iMasterRemoteIdx}); + + # Check if Postgres is running and if so only continue when forced + if ($oStorageDbMaster->exists(DB_FILE_POSTMASTERPID)) + { + confess &log(ERROR, DB_FILE_POSTMASTERPID . " exists - looks like the postmaster is running. " . + "To delete stanza '${strStanza}', shutdown the postmaster for stanza '${strStanza}' and try again, " . + "or use --force.", ERROR_POSTMASTER_RUNNING); + } } # Delete the archive info files diff --git a/src/perl/embed.auto.c b/src/perl/embed.auto.c index 02b5009ed..1096fd359 100644 --- a/src/perl/embed.auto.c +++ b/src/perl/embed.auto.c @@ -15514,16 +15514,20 @@ static const EmbeddedModule embeddedModule[] = "\"\\nHINT: has the pgbackrest stop command been run on this server?\", ERROR_FILE_MISSING);\n" "}\n" "\n\n" + "if (!cfgOption(CFGOPT_FORCE))\n" + "{\n" + "\n" "my ($oDbMaster, $iMasterRemoteIdx) = dbObjectGet({bMasterOnly => true});\n" "\n\n" "my $oStorageDbMaster = storageDb({iRemoteIdx => $iMasterRemoteIdx});\n" "\n\n" - "if ($oStorageDbMaster->exists(DB_FILE_POSTMASTERPID) && !cfgOption(CFGOPT_FORCE))\n" + "if ($oStorageDbMaster->exists(DB_FILE_POSTMASTERPID))\n" "{\n" "confess &log(ERROR, DB_FILE_POSTMASTERPID . \" exists - looks like the postmaster is running. \" .\n" "\"To delete stanza '${strStanza}', shutdown the postmaster for stanza '${strStanza}' and try again, \" .\n" "\"or use --force.\", ERROR_POSTMASTER_RUNNING);\n" "}\n" + "}\n" "\n\n" "$oStorageRepo->remove(STORAGE_REPO_ARCHIVE . '/' . ARCHIVE_INFO_FILE, {bIgnoreMissing => true});\n" "$oStorageRepo->remove(STORAGE_REPO_ARCHIVE . '/' . ARCHIVE_INFO_FILE . INI_COPY_EXT, {bIgnoreMissing => true});\n" diff --git a/test/expect/real-all-004.log b/test/expect/real-all-004.log index 9466a76e9..80864dfe7 100644 --- a/test/expect/real-all-004.log +++ b/test/expect/real-all-004.log @@ -312,3 +312,23 @@ repo1-path=[TEST_PATH]/backup/repo [global:backup] archive-copy=y start-fast=y + +stop all stanzas (db-master host) +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf stop +------------------------------------------------------------------------------------------------------------------------------------ + +stop db stanza (backup host) +> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db stop +------------------------------------------------------------------------------------------------------------------------------------ + +stanza-delete db - delete stanza with --force when pgbackrest on pg host not accessible (backup host) +> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db --log-level-console=detail --force stanza-delete +------------------------------------------------------------------------------------------------------------------------------------ + +start all stanzas (db-master host) +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf start +------------------------------------------------------------------------------------------------------------------------------------ + +start all stanzas (backup host) +> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf start +------------------------------------------------------------------------------------------------------------------------------------ diff --git a/test/lib/pgBackRestTest/Module/Real/RealAllTest.pm b/test/lib/pgBackRestTest/Module/Real/RealAllTest.pm index 8cd01f372..1756372dd 100644 --- a/test/lib/pgBackRestTest/Module/Real/RealAllTest.pm +++ b/test/lib/pgBackRestTest/Module/Real/RealAllTest.pm @@ -988,6 +988,22 @@ sub run 'succeed on --no-' . cfgOptionName(CFGOPT_ONLINE) . ' with --' . cfgOptionName(CFGOPT_FORCE), {strOptionalParam => '--no-' . cfgOptionName(CFGOPT_ONLINE) . ' --' . cfgOptionName(CFGOPT_FORCE)}); } + + # Stanza-delete --force without access to pgbackrest on database host + #--------------------------------------------------------------------------------------------------------------------------- + if ($bTestExtra && !$bS3 && $bHostBackup) + { + # With stanza-delete --force, allow stanza to be deleted regardless of accessiblility of database host + if ($bHostBackup) + { + $oHostDbMaster->stop(); + $oHostBackup->stop({strStanza => $self->stanza}); + $oHostBackup->stanzaDelete("delete stanza with --force when pgbackrest on pg host not accessible", + {strOptionalParam => ' --' . cfgOptionName(CFGOPT_FORCE)}); + $oHostDbMaster->start(); + $oHostBackup->start(); + } + } } } }