Skip to content

Commit 341ff68

Browse files
Retry on connection timeout (#103)
A lot of the time we see the error `[Errno 110] Connection timed out`. This happens a lot in Azure, particularly. In this PR I make it a retryable error as it is safe Signed-off-by: Andre Furlan <[email protected]>
1 parent 82925ec commit 341ff68

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,6 @@ cython_debug/
202202
databricks_sql_connector.egg-info/
203203
dist/
204204
build/
205+
206+
# vs code stuff
207+
.vscode

src/databricks/sql/thrift_backend.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -322,27 +322,27 @@ def attempt_request(attempt):
322322
except OSError as err:
323323
error = err
324324
error_message = str(err)
325+
# fmt: off
326+
# The built-in errno package encapsulates OSError codes, which are OS-specific.
327+
# log.info for errors we believe are not unusual or unexpected. log.warn for
328+
# for others like EEXIST, EBADF, ERANGE which are not expected in this context.
329+
#
330+
# I manually tested this retry behaviour using mitmweb and confirmed that
331+
# GetOperationStatus requests are retried when I forced network connection
332+
# interruptions / timeouts / reconnects. See #24 for more info.
333+
# | Debian | Darwin |
334+
info_errs = [ # |--------|--------|
335+
errno.ESHUTDOWN, # | 32 | 32 |
336+
errno.EAFNOSUPPORT, # | 97 | 47 |
337+
errno.ECONNRESET, # | 104 | 54 |
338+
errno.ETIMEDOUT, # | 110 | 60 |
339+
]
325340

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

330-
# fmt: off
331-
# The built-in errno package encapsulates OSError codes, which are OS-specific.
332-
# log.info for errors we believe are not unusual or unexpected. log.warn for
333-
# for others like EEXIST, EBADF, ERANGE which are not expected in this context.
334-
#
335-
# I manually tested this retry behaviour using mitmweb and confirmed that
336-
# GetOperationStatus requests are retried when I forced network connection
337-
# interruptions / timeouts / reconnects. See #24 for more info.
338-
# | Debian | Darwin |
339-
info_errs = [ # |--------|--------|
340-
errno.ESHUTDOWN, # | 32 | 32 |
341-
errno.EAFNOSUPPORT, # | 97 | 47 |
342-
errno.ECONNRESET, # | 104 | 54 |
343-
errno.ETIMEDOUT, # | 110 | 60 |
344-
]
345-
346346
# fmt: on
347347
log_string = f"{gos_name} failed with code {err.errno} and will attempt to retry"
348348
if err.errno in info_errs:

0 commit comments

Comments
 (0)