Skip to content

SNOW-4058589: retry SSLError "Unexpected EOF" during TLS handshake - #3027

Merged
sfc-gh-dszmolka merged 4 commits into
mainfrom
SNOW-4058589-retry-unexpected-EOF
Sep 4, 2026
Merged

sfc-gh-dszmolka merged 4 commits into
mainfrom
SNOW-4058589-retry-unexpected-EOF

Conversation

@sfc-gh-dszmolka

@sfc-gh-dszmolka sfc-gh-dszmolka commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

SnowflakeRestful._request_exec only retries an SSLError when its repr() contains ECONNRESET. A TLS handshake aborted by the peer surfaces (via pyOpenSSL) as SSLError("bad handshake: SysCallError(-1, 'Unexpected EOF')"), which does not match — so it is treated as non-retryable and raised as OperationalError (errno 250003).

Impact

When the peer closes the connection mid-TLS-handshake — a transient, retryable condition — the request fails immediately instead of being retried, surfacing as a hard connection error. Affects both the sync and async request paths.

We got a customer complaint due to this.

Fix

Retry when "Unexpected EOF" is present in repr(se), alongside the existing ECONNRESET check, in network.py (sync) and aio/_network.py (async).

Tests

  • Added test_sslerror_with_unexpected_eof_retries (sync + async), asserting RetryRequest.
  • Renamed the negative test to test_sslerror_without_econnreset_or_unexpected_eof_does_not_retry.
  • All test_retry_network unit tests pass (43, sync + async).

A TLS handshake terminated by the peer surfaces in pyOpenSSL as
SSLError("bad handshake: SysCallError(-1, 'Unexpected EOF')"). The retry
gate only recognized "ECONNRESET" in repr(e), so this handshake failure
was classified non-retryable and raised OperationalError (errno 250003)
instead of being retried like ECONNRESET.

Widen the gate on both the sync (network.py) and async (aio/_network.py)
request paths to also retry when "Unexpected EOF" is present in repr(se).

Tests: add test_sslerror_with_unexpected_eof_retries and rename the
negative test to
test_sslerror_without_econnreset_or_unexpected_eof_does_not_retry,
on both sync and async paths. Add DESCRIPTION.md release note.
@sfc-gh-dszmolka
sfc-gh-dszmolka force-pushed the SNOW-4058589-retry-unexpected-EOF branch from f6a2f0a to 1359d9f Compare September 4, 2026 08:24
@codecov-commenter

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@sfc-gh-dszmolka
sfc-gh-dszmolka marked this pull request as ready for review September 4, 2026 08:49
@sfc-gh-dszmolka
sfc-gh-dszmolka requested a review from a team as a code owner September 4, 2026 08:49
Comment thread src/snowflake/connector/aio/_network.py Outdated
raw_ret.close() # ensure response is closed
except (aiohttp.ClientSSLError, aiohttp.ClientConnectorSSLError) as se:
if is_econnreset_exception(se):
if is_econnreset_exception(se) or "Unexpected EOF" in repr(se):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it into is_unexpected_eof_exception to keep it aligned

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

sfc-gh-dszmolka and others added 2 commits September 4, 2026 10:30
Address review feedback on PR #3027: replace the inline "Unexpected EOF" in repr() check with a named is_unexpected_eof_exception() predicate, mirroring is_econnreset_exception, in both the sync and async SSLError retry handlers. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sfc-gh-dszmolka
sfc-gh-dszmolka merged commit a28c63e into main Sep 4, 2026
50 of 54 checks passed
@sfc-gh-dszmolka
sfc-gh-dszmolka deleted the SNOW-4058589-retry-unexpected-EOF branch September 4, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants