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

Commit 581a0be

Browse files
author
Ben Edwards
committed
Support exponential delay for lambda retry attempts
1 parent d97de19 commit 581a0be

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
APP_NAME = "Relational Data Loader"
22
DATA_PIPELINE_EXECUTION_SCHEMA_NAME = "rdl"
3-
MAX_AWS_LAMBDA_INVOKATION_ATTEMPTS = 3
4-
3+
MAX_AWS_LAMBDA_INVOKATION_ATTEMPTS = 4 # 1 + 3 retries
4+
AWS_LAMBDA_RETRY_DELAY_SECONDS = 4 # 10 ^ retry attempt, so retry attempt 64 seconds
55

66
class FullRefreshReason:
77
NOT_APPLICABLE = "N/A"

0 commit comments

Comments
 (0)