diff --git a/doc/xml/release.xml b/doc/xml/release.xml index d1506f4f9..d1b236ff5 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -16,6 +16,23 @@ + + + + + + + + + + + + + +

Error on all lock failures except another process holding the lock.

+
+
+ @@ -11250,6 +11267,11 @@ fpa-postgres + + Geir Råness + geirra + + Greg Sabino Mullane turnstep diff --git a/src/common/lock.c b/src/common/lock.c index fce69d1a5..d82e962fb 100644 --- a/src/common/lock.c +++ b/src/common/lock.c @@ -322,7 +322,7 @@ lockAcquireFile(const String *const lockFile, const TimeMSec lockTimeout, const if (result == -1) { // Error when requested - if (failOnNoLock) + if (failOnNoLock || errNo != EWOULDBLOCK) { const String *errorHint = NULL; diff --git a/test/src/module/common/lockTest.c b/test/src/module/common/lockTest.c index ee92df5e5..bd885ccf6 100644 --- a/test/src/module/common/lockTest.c +++ b/test/src/module/common/lockTest.c @@ -87,6 +87,8 @@ testRun(void) strZ(strNewFmt("unable to acquire lock on file '%s': Is a directory", strZ(dirLock)))); // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("permissions error throw regardless of failOnLock"); + String *noPermLock = strNewZ(TEST_PATH "/noperm/noperm"); HRN_SYSTEM_FMT("mkdir -p 750 %s", strZ(strPath(noPermLock))); @@ -97,6 +99,11 @@ testRun(void) "unable to acquire lock on file '%s': Permission denied\n" "HINT: does '" TEST_USER ":" TEST_GROUP "' running pgBackRest have permissions on the '%s' file?", strZ(noPermLock), strZ(noPermLock)); + TEST_ERROR_FMT( + lockAcquireFile(noPermLock, 100, false), LockAcquireError, + "unable to acquire lock on file '%s': Permission denied\n" + "HINT: does '" TEST_USER ":" TEST_GROUP "' running pgBackRest have permissions on the '%s' file?", + strZ(noPermLock), strZ(noPermLock)); // ------------------------------------------------------------------------------------------------------------------------- String *backupLock = strNewZ(TEST_PATH "/main-backup" LOCK_FILE_EXT); @@ -130,6 +137,8 @@ testRun(void) "unable to acquire lock on file '%s': Resource temporarily unavailable\n" "HINT: is another pgBackRest process running?", strZ(backupLock)))); + TEST_RESULT_VOID(lockAcquireFile(backupLock, 0, false), "success when failOnLock = false"); + // Notify child to release lock HRN_FORK_PARENT_NOTIFY_PUT(0); }