1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-17 01:12:23 +02:00

Change locking around async process forking to be more test friendly.

The lock is now released before the fork and reacquired after the fork so the parent process no longer needs to worry about clearing the lock.

This is the same locking mechanism that will be used once archive-get-async is exec'd as a separate command, so introduce it now to simplify testing.
This commit is contained in:
David Steele
2018-09-11 14:43:16 -04:00
parent 9e574a37dc
commit 787e7c295f
3 changed files with 19 additions and 36 deletions

View File

@ -183,10 +183,6 @@ testRun(void)
storageExistsNP(storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s.ok", strPtr(walSegment))), false,
"check OK file was removed");
// Wait for the lock to be released
lockAcquire(cfgOptionStr(cfgOptLockPath), cfgOptionStr(cfgOptStanza), cfgLockType(), 30, true);
lockRelease(true);
// Write out a WAL segment for success
// -------------------------------------------------------------------------------------------------------------------------
storagePutNP(
@ -199,10 +195,6 @@ testRun(void)
TEST_RESULT_BOOL(storageExistsNP(storageTest, walFile), true, "check WAL segment was moved");
storageRemoveP(storageTest, walFile, .errorOnMissing = true);
// Wait for the lock to be released
lockAcquire(cfgOptionStr(cfgOptLockPath), cfgOptionStr(cfgOptStanza), cfgLockType(), 30, true);
lockRelease(true);
// Write more WAL segments (in this case queue should be full)
// -------------------------------------------------------------------------------------------------------------------------
strLstAddZ(argList, "--archive-get-queue-max=48");
@ -222,10 +214,6 @@ testRun(void)
TEST_RESULT_BOOL(storageExistsNP(storageTest, walFile), true, "check WAL segment was moved");
// Wait for the lock to be released
lockAcquire(cfgOptionStr(cfgOptLockPath), cfgOptionStr(cfgOptStanza), cfgLockType(), 30, true);
lockRelease(true);
// Make sure the process times out when it can't get a lock
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(