1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Add error retry detail for HTTP retries.

This should make it clearer when retries have happened and for how long.
This commit is contained in:
David Steele 2023-04-06 11:38:18 +04:00
parent df419b34b5
commit f33e1cfb16
3 changed files with 18 additions and 2 deletions

View File

@ -16,6 +16,15 @@
<release-list>
<release date="XXXX-XX-XX" version="2.46dev" title="UNDER DEVELOPMENT">
<release-core-list>
<release-improvement-list>
<release-item>
<commit subject="Move error modules to common/error directory."/>
<commit subject="Improve retry error messages."/>
<p>Add error retry detail for HTTP retries.</p>
</release-item>
</release-improvement-list>
<release-development-list>
<release-item>
<commit subject="Add reference filter and output to manifest command."/>

View File

@ -4,6 +4,7 @@ HTTP Request
#include "build.auto.h"
#include "common/debug.h"
#include "common/error/retry.h"
#include "common/io/http/common.h"
#include "common/io/http/request.h"
#include "common/log.h"
@ -73,6 +74,7 @@ httpRequestProcess(HttpRequest *this, bool waitForResponse, bool contentCache)
MEM_CONTEXT_TEMP_BEGIN()
{
bool retry;
ErrorRetry *const errRetry = errRetryNew();
Wait *wait = waitNew(httpClientTimeout(this->client));
do
@ -151,6 +153,9 @@ httpRequestProcess(HttpRequest *this, bool waitForResponse, bool contentCache)
}
CATCH_ANY()
{
// Add the error retry info
errRetryAdd(errRetry);
// Sleep and then retry unless the total wait time has expired
if (waitMore(wait))
{
@ -160,7 +165,7 @@ httpRequestProcess(HttpRequest *this, bool waitForResponse, bool contentCache)
statInc(HTTP_STAT_RETRY_STR);
}
else
RETHROW();
THROWP(errRetryType(errRetry), strZ(errRetryMessage(errRetry)));
}
TRY_END();
}

View File

@ -304,7 +304,9 @@ testRun(void)
TEST_ERROR_FMT(
httpRequestResponse(httpRequestNewP(client, STRDEF("GET"), STRDEF("/")), false), HostConnectError,
"unable to connect to 'localhost:%u': [111] Connection refused", hrnServerPort(0));
"unable to connect to 'localhost:%u': [111] Connection refused\n"
"[RETRY DETAIL OMITTED]",
hrnServerPort(0));
HRN_FORK_BEGIN()
{