Skip to content

Commit 189ffb0

Browse files
authored
Set a 5 minute limit for redshift statement execution (#1915)
Signed-off-by: Achal Shah <achals@gmail.com>
1 parent 5d0f37b commit 189ffb0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sdk/python/feast/infra/utils/aws_utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
import pandas as pd
88
import pyarrow as pa
99
import pyarrow.parquet as pq
10-
from tenacity import retry, retry_if_exception_type, wait_exponential
10+
from tenacity import (
11+
retry,
12+
retry_if_exception_type,
13+
stop_after_attempt,
14+
stop_after_delay,
15+
wait_exponential,
16+
)
1117

1218
from feast.errors import RedshiftCredentialsError, RedshiftQueryError
1319
from feast.type_map import pa_to_redshift_value_type
@@ -53,6 +59,7 @@ def get_bucket_and_key(s3_path: str) -> Tuple[str, str]:
5359
@retry(
5460
wait=wait_exponential(multiplier=1, max=4),
5561
retry=retry_if_exception_type(ConnectionClosedError),
62+
stop=stop_after_attempt(5),
5663
)
5764
def execute_redshift_statement_async(
5865
redshift_data_client, cluster_id: str, database: str, user: str, query: str
@@ -88,6 +95,7 @@ class RedshiftStatementNotFinishedError(Exception):
8895
@retry(
8996
wait=wait_exponential(multiplier=1, max=30),
9097
retry=retry_if_exception_type(RedshiftStatementNotFinishedError),
98+
stop=stop_after_delay(300), # 300 seconds
9199
)
92100
def wait_for_redshift_statement(redshift_data_client, statement: dict) -> None:
93101
"""Waits for the Redshift statement to finish. Raises RedshiftQueryError if the statement didn't succeed.

0 commit comments

Comments
 (0)