From ada5c5c0d96e63f9f13009b6b0818457b49c6591 Mon Sep 17 00:00:00 2001 From: David Steele Date: Mon, 21 May 2018 10:46:45 -0400 Subject: [PATCH] Fix archive write lock being taken for the synchronous archive-get command. Reported by Uspen. --- doc/xml/release.xml | 8 ++++++++ lib/pgBackRest/Protocol/Base/Minion.pm | 4 ++-- libc/xs/common/lock.xs | 2 +- .../Module/Protocol/ProtocolCommonMinionPerlTest.pm | 5 ++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 4ced0f62b..45522ef7f 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -22,6 +22,14 @@

Fix potential buffer overrun in error message handling.

+ + + + + + +

Fix archive write lock being taken for the synchronous archive-get command.

+
diff --git a/lib/pgBackRest/Protocol/Base/Minion.pm b/lib/pgBackRest/Protocol/Base/Minion.pm index aadbdd0c7..0ab42fd6c 100644 --- a/lib/pgBackRest/Protocol/Base/Minion.pm +++ b/lib/pgBackRest/Protocol/Base/Minion.pm @@ -149,8 +149,8 @@ sub process # Loop until the exit command is received eval { - # Aquire a lock if required (this will be determined by lockAcquire()). This is done here so any errors will be transmitted - # through the protocol layer and cause a graceful shutdown rather than a remote abort. + # Acquire a lock if required (this will be determined by lockAcquire()). This is done here so any errors will be + # transmitted through the protocol layer and cause a graceful shutdown rather than a remote abort. if (defined($strLockPath) && defined($strLockStanza)) { eval diff --git a/libc/xs/common/lock.xs b/libc/xs/common/lock.xs index 01f6b868a..fbe648480 100644 --- a/libc/xs/common/lock.xs +++ b/libc/xs/common/lock.xs @@ -21,7 +21,7 @@ CODE: cfgCommandSet(cfgCommandId(command)); // Attempt to acquire the lock - if (cfgLockType() != lockTypeNone) + if (cfgLockRequired()) RETVAL = lockAcquire(strNew(lockPath), strNew(stanza), cfgLockType(), lockTimeout, failOnNoLock); } MEM_CONTEXT_XS_TEMP_END(); diff --git a/test/lib/pgBackRestTest/Module/Protocol/ProtocolCommonMinionPerlTest.pm b/test/lib/pgBackRestTest/Module/Protocol/ProtocolCommonMinionPerlTest.pm index 21dde5948..ed92b0211 100644 --- a/test/lib/pgBackRestTest/Module/Protocol/ProtocolCommonMinionPerlTest.pm +++ b/test/lib/pgBackRestTest/Module/Protocol/ProtocolCommonMinionPerlTest.pm @@ -19,6 +19,7 @@ use pgBackRest::Common::Exception; use pgBackRest::Common::Io::Buffered; use pgBackRest::Common::Log; use pgBackRest::Common::Wait; +use pgBackRest::LibC qw(:config); use pgBackRest::Protocol::Base::Minion; use pgBackRest::Version; @@ -103,7 +104,9 @@ sub run my $oIoHandle = shift; my $oMinion = new pgBackRest::Protocol::Base::Minion('test', new pgBackRest::Common::Io::Buffered($oIoHandle, 5, 4096)); - $oMinion->process(); + + # Use bogus lock path to ensure a lock is not taken for the archive-get command + $oMinion->process($self->testPath(), cfgCommandName(CFGCMD_ARCHIVE_GET), "test"); }); #---------------------------------------------------------------------------------------------------------------------------