Skip to content

Commit

Permalink
failure_retry waits 2 seconds for every retry up to 5 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
agates committed Sep 20, 2021
1 parent abf0d76 commit aeaf859
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 0 additions & 3 deletions src/podping_hivewriter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@

# Operation JSON must be less than or equal to 8192 bytes.
HIVE_CUSTOM_OP_DATA_MAX_LENGTH = 8192
# This is a global signal to shut down until RC's recover
# Stores the RC cost of each operation to calculate an average
HIVE_HALT_TIMES = [0, 1, 1, 1, 1, 1, 1, 1, 3, 6, 9, 15, 15, 15, 15, 15, 15, 15]
11 changes: 5 additions & 6 deletions src/podping_hivewriter/podping_hivewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
STARTUP_FAILED_UNKNOWN_EXIT_CODE,
STARTUP_OPERATION_ID,
CURRENT_PODPING_VERSION,
HIVE_HALT_TIMES,
HIVE_CUSTOM_OP_DATA_MAX_LENGTH,
)
from podping_hivewriter.exceptions import PodpingCustomJsonPayloadExceeded
Expand Down Expand Up @@ -399,11 +398,11 @@ async def failure_retry(self, iri_set: Set[str]) -> Tuple[str, int]:
failure_count = 0

while True:
# Sleep a maximum of 5 minutes, 2 additional seconds for every retry
sleep_time = min(failure_count * 2, 300)
if failure_count > 0:
logging.warning(
f"Waiting {HIVE_HALT_TIMES[failure_count]}s before retry"
)
await asyncio.sleep(HIVE_HALT_TIMES[failure_count])
logging.warning(f"Waiting {sleep_time}s before retry")
await asyncio.sleep(sleep_time)
logging.info(
f"FAILURE COUNT: {failure_count} - RETRYING {len(iri_set)} IRIs"
)
Expand All @@ -414,7 +413,7 @@ async def failure_retry(self, iri_set: Set[str]) -> Tuple[str, int]:
trx_id = await self.send_notification_iris(iris=iri_set)
if failure_count > 0:
logging.info(
f"----> FAILURE CLEARED after {failure_count} retries <-----"
f"FAILURE CLEARED after {failure_count} retries, {sleep_time}s"
)
return trx_id, failure_count
except Exception:
Expand Down

0 comments on commit aeaf859

Please sign in to comment.