You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-15 01:04:37 +02:00
Allow warnings to be written by archiveAsyncStatusOkWrite().
Migrate this feature to the C code since archive-push will need it.
This commit is contained in:
@ -69,6 +69,10 @@
|
||||
<p>Refactor <postgres/> interface to remove most code duplication.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Allow warnings to be written by <code>archiveAsyncStatusOkWrite()</code>.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Move WAL path prefix logic into <code>walPath()</code>.</p>
|
||||
</release-item>
|
||||
|
@ -183,11 +183,12 @@ archiveAsyncStatusErrorWrite(ArchiveMode archiveMode, const String *walSegment,
|
||||
Write an ok status file
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
archiveAsyncStatusOkWrite(ArchiveMode archiveMode, const String *walSegment)
|
||||
archiveAsyncStatusOkWrite(ArchiveMode archiveMode, const String *walSegment, const String *warning)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelDebug);
|
||||
FUNCTION_LOG_PARAM(ENUM, archiveMode);
|
||||
FUNCTION_LOG_PARAM(STRING, walSegment);
|
||||
FUNCTION_LOG_PARAM(STRING, warning);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walSegment != NULL);
|
||||
@ -199,7 +200,7 @@ archiveAsyncStatusOkWrite(ArchiveMode archiveMode, const String *walSegment)
|
||||
storageNewWriteNP(
|
||||
storageSpoolWrite(),
|
||||
strNewFmt("%s/%s" STATUS_EXT_OK, strPtr(archiveAsyncSpoolQueue(archiveMode)), strPtr(walSegment))),
|
||||
NULL);
|
||||
warning == NULL ? NULL : bufNewStr(strNewFmt("0\n%s", strPtr(warning))));
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
|
@ -59,7 +59,7 @@ WAL segment constants
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool confessOnError);
|
||||
void archiveAsyncStatusOkWrite(ArchiveMode archiveMode, const String *walSegment);
|
||||
void archiveAsyncStatusOkWrite(ArchiveMode archiveMode, const String *walSegment, const String *warning);
|
||||
void archiveAsyncStatusErrorWrite(ArchiveMode archiveMode, const String *walSegment, int code, const String *message);
|
||||
|
||||
bool walIsPartial(const String *walSegment);
|
||||
|
@ -340,7 +340,7 @@ cmdArchiveGetAsync(void)
|
||||
else
|
||||
{
|
||||
LOG_DETAIL("unable to find %s in the archive", strPtr(walSegment));
|
||||
archiveAsyncStatusOkWrite(archiveModeGet, walSegment);
|
||||
archiveAsyncStatusOkWrite(archiveModeGet, walSegment, NULL);
|
||||
}
|
||||
}
|
||||
// Else the job errored
|
||||
|
@ -138,13 +138,22 @@ testRun(void)
|
||||
"remove global error");
|
||||
|
||||
TEST_RESULT_VOID(
|
||||
archiveAsyncStatusOkWrite(archiveModeGet, walSegment), "write ok file");
|
||||
archiveAsyncStatusOkWrite(archiveModeGet, walSegment, NULL), "write ok file");
|
||||
TEST_RESULT_STR(
|
||||
strPtr(strNewBuf(storageGetNP(storageNewReadNP(storageTest, strNew("archive/db/in/000000010000000100000001.ok"))))),
|
||||
"", "check ok");
|
||||
TEST_RESULT_VOID(
|
||||
storageRemoveP(storageTest, strNew("archive/db/in/000000010000000100000001.ok"), .errorOnMissing = true),
|
||||
"remove ok");
|
||||
|
||||
TEST_RESULT_VOID(
|
||||
archiveAsyncStatusOkWrite(archiveModeGet, walSegment, strNew("WARNING")), "write ok file with warning");
|
||||
TEST_RESULT_STR(
|
||||
strPtr(strNewBuf(storageGetNP(storageNewReadNP(storageTest, strNew("archive/db/in/000000010000000100000001.ok"))))),
|
||||
"0\nWARNING", "check ok warning");
|
||||
TEST_RESULT_VOID(
|
||||
storageRemoveP(storageTest, strNew("archive/db/in/000000010000000100000001.ok"), .errorOnMissing = true),
|
||||
"remove ok");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
|
Reference in New Issue
Block a user