Skip to content
This repository was archived by the owner on Mar 13, 2020. It is now read-only.

Commit 75b86dc

Browse files
authored
Merge pull request #73 from pageuppeople-opensource/retry_dropoff
Support exponential delay for lambda retry attempts
2 parents d97de19 + c1f66d7 commit 75b86dc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

rdl/data_sources/AWSLambdaDataSource.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pandas
33
import json
44
import boto3
5+
import time
56

67
from rdl.data_sources.ChangeTrackingInfo import ChangeTrackingInfo
78
from rdl.data_sources.SourceTableInfo import SourceTableInfo
@@ -149,9 +150,14 @@ def __get_data_frame(self, data: [[]], column_names: []):
149150

150151
def __invoke_lambda(self, pay_load):
151152
max_attempts = Constants.MAX_AWS_LAMBDA_INVOKATION_ATTEMPTS
153+
retry_delay = Constants.AWS_LAMBDA_RETRY_DELAY_SECONDS
152154
response_payload = None
153155

154156
for current_attempt in list(range(1, max_attempts+1, 1)):
157+
if current_attempt > 1:
158+
self.logger.debug(f"\nDelaying retry for {(current_attempt - 1) ^ retry_delay} seconds")
159+
time.sleep((current_attempt - 1) ^ retry_delay)
160+
155161
self.logger.debug(f"\nRequest being sent to Lambda, attempt {current_attempt} of {max_attempts}:")
156162
self.logger.debug(pay_load)
157163

rdl/shared/Constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
APP_NAME = "Relational Data Loader"
22
DATA_PIPELINE_EXECUTION_SCHEMA_NAME = "rdl"
3-
MAX_AWS_LAMBDA_INVOKATION_ATTEMPTS = 3
3+
MAX_AWS_LAMBDA_INVOKATION_ATTEMPTS = 4 # 1 + 3 retries
4+
AWS_LAMBDA_RETRY_DELAY_SECONDS = 4 # 4 ^ retry attempt, so retry attempt 3 is delayed 64 seconds
45

56

67
class FullRefreshReason:

0 commit comments

Comments
 (0)