Limit number of stats collection retries to once a day.

pull/1751/head
Hadi Moshayedi 2017-10-31 21:28:43 -04:00 committed by Hadi Moshayedi
parent 78a2cd9052
commit 747e439601
1 changed files with 21 additions and 9 deletions

View File

@ -214,7 +214,9 @@ CitusMaintenanceDaemonMain(Datum main_arg)
{
Oid databaseOid = DatumGetObjectId(main_arg);
MaintenanceDaemonDBData *myDbData = NULL;
TimestampTz nextStatsCollectionTime USED_WITH_LIBCURL_ONLY = GetCurrentTimestamp();
TimestampTz nextStatsCollectionTime USED_WITH_LIBCURL_ONLY =
TimestampTzPlusMilliseconds(GetCurrentTimestamp(), 60 * 1000);
bool retryStatsCollection USED_WITH_LIBCURL_ONLY = false;
ErrorContextCallback errorCallback;
/*
@ -321,26 +323,36 @@ CitusMaintenanceDaemonMain(Datum main_arg)
FlushDistTableCache();
WarnIfSyncDNS();
statsCollectionSuccess = CollectBasicUsageStatistics();
if (statsCollectionSuccess)
{
/*
* Checking for updates only when collecting statistics succeeds,
* so we don't log update messages twice when we retry statistics
* collection in a minute.
*/
CheckForUpdates();
}
}
if (statsCollectionSuccess)
/*
* If statistics collection was successful the next collection is
* 24-hours later. Also, if this was a retry attempt we don't do
* any more retries until 24-hours later, so we limit number of
* retries to one.
*/
if (statsCollectionSuccess || retryStatsCollection)
{
/*
* Checking for updates only when collecting statistics succeeds,
* so we don't log update messages twice when we retry statistics
* collection in a minute.
*/
CheckForUpdates();
nextStatsCollectionTime =
TimestampTzPlusMilliseconds(GetCurrentTimestamp(),
STATS_COLLECTION_TIMEOUT_MILLIS);
retryStatsCollection = false;
}
else
{
nextStatsCollectionTime =
TimestampTzPlusMilliseconds(GetCurrentTimestamp(),
STATS_COLLECTION_RETRY_TIMEOUT_MILLIS);
retryStatsCollection = true;
}
CommitTransactionCommand();