You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Refactor logging functions to never allocate memory.
Allocating memory made these functions simpler but it meant that memory was leaking into the calling context when logging was enabled. It is not clear that this was an issue but it seems that trace level logging could result it a lot of memory usage depending on the use case. This also makes it possible to audit allocations returned to the calling context, which will be done in a followup commit. Also rename objToLog() to objNameToLog() since it seemed logical to name the new function objToLog().
This commit is contained in:
@ -236,6 +236,8 @@ testRun(void)
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("pgControlToLog()"))
|
||||
{
|
||||
char logBuf[STACK_TRACE_PARAM_MAX];
|
||||
|
||||
PgControl pgControl =
|
||||
{
|
||||
.version = PG_VERSION_11,
|
||||
@ -244,21 +246,24 @@ testRun(void)
|
||||
.pageChecksum = true
|
||||
};
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
pgControlToLog(&pgControl), "{version: 110000, systemId: 1030522662895, walSegmentSize: 16777216, pageChecksum: true}",
|
||||
"check log");
|
||||
TEST_RESULT_VOID(FUNCTION_LOG_OBJECT_FORMAT(&pgControl, pgControlToLog, logBuf, sizeof(logBuf)), "pgControlToLog");
|
||||
TEST_RESULT_Z(
|
||||
logBuf, "{version: 110000, systemId: 1030522662895, walSegmentSize: 16777216, pageChecksum: true}", "check log");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("pgWalToLog()"))
|
||||
{
|
||||
char logBuf[STACK_TRACE_PARAM_MAX];
|
||||
|
||||
PgWal pgWal =
|
||||
{
|
||||
.version = PG_VERSION_10,
|
||||
.systemId = 0xFEFEFEFEFE
|
||||
};
|
||||
|
||||
TEST_RESULT_STR_Z(pgWalToLog(&pgWal), "{version: 100000, systemId: 1095199817470}", "check log");
|
||||
TEST_RESULT_VOID(FUNCTION_LOG_OBJECT_FORMAT(&pgWal, pgWalToLog, logBuf, sizeof(logBuf)), "pgWalToLog");
|
||||
TEST_RESULT_Z(logBuf, "{version: 100000, systemId: 1095199817470}", "check log");
|
||||
}
|
||||
|
||||
FUNCTION_HARNESS_RETURN_VOID();
|
||||
|
Reference in New Issue
Block a user