1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00

Improve archive-push WAL segment queue handling.

Infer the size of all WAL segments from the size of the first segment rather than getting info for all segments (up to queue size). If the segments are not the same size then there are larger issues than the WAL queue.
This commit is contained in:
David Steele
2024-03-08 12:34:11 +13:00
committed by GitHub
parent 4387250f2e
commit cf17515e40
3 changed files with 23 additions and 16 deletions
+11
View File
@@ -30,6 +30,17 @@
</release-bug-list> </release-bug-list>
<release-improvement-list> <release-improvement-list>
<release-item>
<github-pull-request id="2277"/>
<release-item-contributor-list>
<release-item-contributor id="david.steele"/>
<release-item-reviewer id="stephen.frost"/>
</release-item-contributor-list>
<p>Improve <cmd>archive-push</cmd> WAL segment queue handling.</p>
</release-item>
<release-item> <release-item>
<github-pull-request id="2263"/> <github-pull-request id="2263"/>
+9 -16
View File
@@ -60,37 +60,30 @@ archivePushDropWarning(const String *const walFile, const uint64_t queueMax)
Determine if the WAL process list has become large enough to drop Determine if the WAL process list has become large enough to drop
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
static bool static bool
archivePushDrop(const String *walPath, const StringList *const processList) archivePushDrop(const String *const walPath, const StringList *const processList)
{ {
FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(STRING, walPath); FUNCTION_LOG_PARAM(STRING, walPath);
FUNCTION_LOG_PARAM(STRING_LIST, processList); FUNCTION_LOG_PARAM(STRING_LIST, processList);
FUNCTION_LOG_END(); FUNCTION_LOG_END();
ASSERT(walPath != NULL);
ASSERT(processList != NULL);
const uint64_t queueMax = cfgOptionUInt64(cfgOptArchivePushQueueMax); const uint64_t queueMax = cfgOptionUInt64(cfgOptArchivePushQueueMax);
uint64_t queueSize = 0; uint64_t queueSize = 0;
bool result = false;
MEM_CONTEXT_TEMP_RESET_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
for (unsigned int processIdx = 0; processIdx < strLstSize(processList); processIdx++) if (!strLstEmpty(processList))
{ {
queueSize += storageInfoP( queueSize = storageInfoP(
storagePg(), strNewFmt("%s/%s", strZ(walPath), strZ(strLstGet(processList, processIdx)))).size; storagePg(), strNewFmt("%s/%s", strZ(walPath), strZ(strLstGet(processList, 0)))).size * strLstSize(processList);
if (queueSize > queueMax)
{
result = true;
break;
}
// Reset the memory context occasionally so we don't use too much memory or slow down processing
MEM_CONTEXT_TEMP_RESET(1000);
} }
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
FUNCTION_LOG_RETURN(BOOL, result); FUNCTION_LOG_RETURN(BOOL, queueSize > queueMax);
} }
/*********************************************************************************************************************************** /***********************************************************************************************************************************
@@ -90,6 +90,9 @@ testRun(void)
TEST_RESULT_BOOL( TEST_RESULT_BOOL(
archivePushDrop(STRDEF("pg_wal"), archivePushProcessList(STRDEF(TEST_PATH "/db/pg_wal"))), true, "wal is dropped"); archivePushDrop(STRDEF("pg_wal"), archivePushProcessList(STRDEF(TEST_PATH "/db/pg_wal"))), true, "wal is dropped");
// No WAL to be processed
TEST_RESULT_BOOL(archivePushDrop(STRDEF("pg_wal"), strLstNew()), false, "no WAL to be processed");
} }
// ***************************************************************************************************************************** // *****************************************************************************************************************************