-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support retryable exceptions during query execution #368
base: main
Are you sure you want to change the base?
Conversation
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few style nits and one actual blocking change (the double decrement for retries).
dbt/adapters/sql/connections.py
Outdated
retryable_exceptions: Iterable[Type[Exception]] = [], | ||
retry_limit: int = 1, | ||
retry_timeout: Union[Callable[[int], SleepTime], SleepTime] = 1, | ||
_attempts: int = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like an early abstraction. Can we start with a timeout that's just an integer and go from there?
_attempts: int = 0, | ||
) -> None: | ||
timeout = retry_timeout(_attempts) if callable(retry_timeout) else retry_timeout | ||
if timeout < 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like java style programming, aka "look before you leap". If we remove the callable variant of the timeout, can we omit this as well? In that scenario, I think it's either our default, or the user setting, both of which can be reasonably assumed to be non-negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does removing the callable variant of the timeout mean here? We're passing in a function that the downstream user implements and I personally jive with that
try: | ||
execute_fn(sql, bindings) | ||
|
||
except tuple(retryable_exceptions) as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also feels like early abstraction. Can we update the type to be Tuple
from start since the user of this is an adapter maintainer and not an end user?
return self._retryable_cursor_execute( | ||
execute_fn=execute_fn, | ||
sql=sql, | ||
retry_limit=retry_limit - 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already decremented the retry limit on line 234. This does it twice.
retry_limit=retry_limit - 1, | ||
retry_timeout=retry_timeout, | ||
retryable_exceptions=retryable_exceptions, | ||
_attempts=_attempts + 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see why we would pass in _attempts
now, but this could be a separate concept, similar to the way BQ manages retries. I still think it's an early abstraction and we could update this with a more intelligent method in a future update.
resolves #
docs dbt-labs/docs.getdbt.com/#
Problem
Solution
Checklist