Skip to content

Commit 4dc395b

Browse files
remove retry_all from add_query and set backoff>1 (#1095)
Co-authored-by: Mila Page <[email protected]>
1 parent 13a7ad3 commit 4dc395b

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Fixes
2+
body: remove retry_all from add_query and set backoff so it actually backs off
3+
time: 2025-05-13T10:44:30.673728-07:00
4+
custom:
5+
Author: colin-rogers-dbt
6+
Issue: "1095"

dbt-redshift/src/dbt/adapters/redshift/connections.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def _handle_execute_exception(
551551
raise e
552552
if oid_not_found_msg in str(e):
553553
pass
554-
elif isinstance(e, redshift_connector.Error) and retry_all:
554+
elif isinstance(e, DbtDatabaseError) and retry_all:
555555
pass
556556
else:
557557
logger.debug(f"Not retrying error: {e}")
@@ -564,7 +564,7 @@ def _handle_execute_exception(
564564
self.open(self.get_thread_connection())
565565
time.sleep(backoff)
566566
# return with exponential backoff
567-
return retries, min(backoff * 2, 60)
567+
return retries, min(max(backoff * 2, 2), 60)
568568

569569
def _execute_internal(
570570
sql: str,
@@ -618,8 +618,6 @@ def add_query(self, sql, auto_begin=True, bindings=None, abridge_sql_log=False):
618618
redshift_connector.InterfaceError,
619619
redshift_connector.InternalError,
620620
)
621-
if self.profile.credentials.retry_all:
622-
redshift_retryable_exceptions = redshift_connector.Error
623621

624622
for query in queries:
625623
# Strip off comments from the current query

dbt-redshift/tests/functional/adapter/test_exception_handling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@ def profiles_config_update(self, dbt_profile_target):
9898

9999
def test_running_bad_model_retries(self, project):
100100
result, log = run_dbt_and_capture(["run", "--log-level=debug"], expect_pass=False)
101-
assert "Got a retryable error" in log
101+
assert "Retrying query due to error" in log

dbt-redshift/tests/unit/test_query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from dbt.adapters.sql.connections import SQLConnectionManager
77
from dbt_common.clients import agate_helper
8-
from dbt_common.exceptions import DbtRuntimeError
8+
from dbt_common.exceptions import DbtRuntimeError, DbtDatabaseError
99

1010
from dbt.adapters.redshift import (
1111
Plugin as RedshiftPlugin,
@@ -111,8 +111,8 @@ def test_execute_with_retry_all(self):
111111
self.adapter.connections.profile.credentials.retries = 3
112112
self.adapter.connections.profile.credentials.retry_all = True
113113
mock_add_query.side_effect = [
114-
redshift_connector.InterfaceError,
115-
redshift_connector.InternalError,
114+
DbtDatabaseError("test"),
115+
DbtDatabaseError("test2"),
116116
(None, cursor),
117117
]
118118
with mock.patch.object(

0 commit comments

Comments
 (0)