1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-13 01:00:23 +02:00

Add protocolKeepAlive() to send noops to all remotes.

While the local processes are doing their jobs the remote connection from the main process may timeout.

Send occasional noops to ensure that doesn't happen.
This commit is contained in:
David Steele
2019-03-27 20:59:28 +00:00
parent f8cbf5d78c
commit 7db8cedd68
4 changed files with 30 additions and 0 deletions

View File

@ -89,6 +89,10 @@
<p><code>httpClientRequest()</code> accepts a body parameter.</p> <p><code>httpClientRequest()</code> accepts a body parameter.</p>
</release-item> </release-item>
<release-item>
<p>Add <code>protocolKeepAlive()</code> to send <id>noops</id> to all remotes.</p>
</release-item>
<release-item> <release-item>
<p>Make <code>strLstDup()</code> null-tolerant.</p> <p>Make <code>strLstDup()</code> null-tolerant.</p>
</release-item> </release-item>

View File

@ -327,6 +327,26 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType)
FUNCTION_LOG_RETURN(PROTOCOL_CLIENT, protocolHelperClient->client); FUNCTION_LOG_RETURN(PROTOCOL_CLIENT, protocolHelperClient->client);
} }
/***********************************************************************************************************************************
Send keepalives to all remotes
***********************************************************************************************************************************/
void
protocolKeepAlive(void)
{
FUNCTION_LOG_VOID(logLevelTrace);
if (protocolHelper.memContext != NULL)
{
for (unsigned int clientIdx = 0; clientIdx < protocolHelper.clientRemoteSize; clientIdx++)
{
if (protocolHelper.clientRemote[clientIdx].client != NULL)
protocolClientNoOp(protocolHelper.clientRemote[clientIdx].client);
}
}
FUNCTION_LOG_RETURN_VOID();
}
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Free the protocol objects and shutdown processes Free the protocol objects and shutdown processes
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -26,6 +26,7 @@ Constants
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
void protocolKeepAlive(void);
ProtocolClient *protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int protocolId); ProtocolClient *protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int protocolId);
ProtocolClient *protocolRemoteGet(ProtocolStorageType protocolStorageType); ProtocolClient *protocolRemoteGet(ProtocolStorageType protocolStorageType);

View File

@ -629,6 +629,10 @@ testRun(void)
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("protocolGet()")) if (testBegin("protocolGet()"))
{ {
// Call keep alive before any remotes exist
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(protocolKeepAlive(), "keep alive");
// Simple protocol start // Simple protocol start
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
StringList *argList = strLstNew(); StringList *argList = strLstNew();
@ -647,6 +651,7 @@ testRun(void)
TEST_ASSIGN(client, protocolRemoteGet(protocolStorageTypeRepo), "get remote protocol"); TEST_ASSIGN(client, protocolRemoteGet(protocolStorageTypeRepo), "get remote protocol");
TEST_RESULT_PTR(protocolRemoteGet(protocolStorageTypeRepo), client, "get remote cached protocol"); TEST_RESULT_PTR(protocolRemoteGet(protocolStorageTypeRepo), client, "get remote cached protocol");
TEST_RESULT_PTR(protocolHelper.clientRemote[0].client, client, "check position in cache"); TEST_RESULT_PTR(protocolHelper.clientRemote[0].client, client, "check position in cache");
TEST_RESULT_VOID(protocolKeepAlive(), "keep alive");
TEST_RESULT_VOID(protocolFree(), "free remote protocol objects"); TEST_RESULT_VOID(protocolFree(), "free remote protocol objects");
TEST_RESULT_VOID(protocolFree(), "free remote protocol objects again"); TEST_RESULT_VOID(protocolFree(), "free remote protocol objects again");