You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-13 01:00:23 +02:00
Add timeout to walSegmentFind().
Keep trying to locate the WAL segment until timeout. This is useful for the check and backup commands which must wait for segments to arrive in the archive.
This commit is contained in:
@ -7,6 +7,7 @@ Test Archive Common
|
||||
#include "storage/posix/storage.h"
|
||||
|
||||
#include "common/harnessConfig.h"
|
||||
#include "common/harnessFork.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Run
|
||||
@ -196,20 +197,39 @@ testRun(void)
|
||||
strLstAddZ(argList, "archive-get");
|
||||
harnessCfgLoad(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
TEST_RESULT_PTR(walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678")), NULL, "no path");
|
||||
TEST_RESULT_PTR(walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678"), 0), NULL, "no path");
|
||||
|
||||
storagePathCreateNP(storageTest, strNew("archive/db/9.6-2/1234567812345678"));
|
||||
TEST_RESULT_PTR(walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678")), NULL, "no segment");
|
||||
TEST_RESULT_PTR(walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678"), 0), NULL, "no segment");
|
||||
TEST_RESULT_PTR(
|
||||
walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678"), 500), NULL,
|
||||
"no segment after 500ms");
|
||||
|
||||
storagePutNP(
|
||||
storageNewWriteNP(
|
||||
storageTest,
|
||||
strNew("archive/db/9.6-2/1234567812345678/123456781234567812345678-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")),
|
||||
NULL);
|
||||
// Check timeout by making the wal segment appear after 250ms
|
||||
HARNESS_FORK_BEGIN()
|
||||
{
|
||||
HARNESS_FORK_CHILD_BEGIN(0, false)
|
||||
{
|
||||
sleepMSec(250);
|
||||
|
||||
TEST_RESULT_STR(
|
||||
strPtr(walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678"))),
|
||||
"123456781234567812345678-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "found segment");
|
||||
storagePutNP(
|
||||
storageNewWriteNP(
|
||||
storageTest,
|
||||
strNew(
|
||||
"archive/db/9.6-2/1234567812345678/123456781234567812345678-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")),
|
||||
NULL);
|
||||
}
|
||||
HARNESS_FORK_CHILD_END();
|
||||
|
||||
HARNESS_FORK_PARENT_BEGIN()
|
||||
{
|
||||
TEST_RESULT_STR(
|
||||
strPtr(walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678"), 1000)),
|
||||
"123456781234567812345678-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "found segment");
|
||||
}
|
||||
HARNESS_FORK_PARENT_END();
|
||||
}
|
||||
HARNESS_FORK_END();
|
||||
|
||||
storagePutNP(
|
||||
storageNewWriteNP(
|
||||
@ -218,7 +238,7 @@ testRun(void)
|
||||
NULL);
|
||||
|
||||
TEST_ERROR(
|
||||
walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678")),
|
||||
walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678"), 0),
|
||||
ArchiveDuplicateError,
|
||||
"duplicates found in archive for WAL segment 123456781234567812345678:"
|
||||
" 123456781234567812345678-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
@ -226,7 +246,7 @@ testRun(void)
|
||||
"\nHINT: are multiple primaries archiving to this stanza?");
|
||||
|
||||
TEST_RESULT_STR(
|
||||
walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678.partial")), NULL,
|
||||
walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678.partial"), 0), NULL,
|
||||
"did not find partial segment");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user