Skip to content

Retry on connection timeout #103

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

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,6 @@ cython_debug/
databricks_sql_connector.egg-info/
dist/
build/

# vs code stuff
.vscode
34 changes: 17 additions & 17 deletions src/databricks/sql/thrift_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,27 +322,27 @@ def attempt_request(attempt):
except OSError as err:
error = err
error_message = str(err)
# fmt: off
# The built-in errno package encapsulates OSError codes, which are OS-specific.
# log.info for errors we believe are not unusual or unexpected. log.warn for
# for others like EEXIST, EBADF, ERANGE which are not expected in this context.
#
# I manually tested this retry behaviour using mitmweb and confirmed that
# GetOperationStatus requests are retried when I forced network connection
# interruptions / timeouts / reconnects. See #24 for more info.
# | Debian | Darwin |
info_errs = [ # |--------|--------|
errno.ESHUTDOWN, # | 32 | 32 |
errno.EAFNOSUPPORT, # | 97 | 47 |
errno.ECONNRESET, # | 104 | 54 |
errno.ETIMEDOUT, # | 110 | 60 |
]

gos_name = TCLIServiceClient.GetOperationStatus.__name__
if method.__name__ == gos_name:
# retry on timeout. Happens a lot in Azure and it is safe as data has not been sent to server yet
if method.__name__ == gos_name or err.errno == errno.ETIMEDOUT:
retry_delay = bound_retry_delay(attempt, self._retry_delay_default)

# fmt: off
# The built-in errno package encapsulates OSError codes, which are OS-specific.
# log.info for errors we believe are not unusual or unexpected. log.warn for
# for others like EEXIST, EBADF, ERANGE which are not expected in this context.
#
# I manually tested this retry behaviour using mitmweb and confirmed that
# GetOperationStatus requests are retried when I forced network connection
# interruptions / timeouts / reconnects. See #24 for more info.
# | Debian | Darwin |
info_errs = [ # |--------|--------|
errno.ESHUTDOWN, # | 32 | 32 |
errno.EAFNOSUPPORT, # | 97 | 47 |
errno.ECONNRESET, # | 104 | 54 |
errno.ETIMEDOUT, # | 110 | 60 |
]

# fmt: on
log_string = f"{gos_name} failed with code {err.errno} and will attempt to retry"
if err.errno in info_errs:
Expand Down