Skip to content

Clear transport deadlines when set_timeouts! changes the timeouts - #259

Merged
quinnj-bot[bot] merged 2 commits into
mainfrom
claude/set-timeouts-clear-deadlines
Nov 11, 2026
Merged

quinnj-bot[bot] merged 2 commits into
mainfrom
claude/set-timeouts-clear-deadlines

Conversation

@quinnj-bot

@quinnj-bot quinnj-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Why

After MySQL.Protocol.set_timeouts!(s, 0, 0), the deadline that the previous timeouts armed stays on the transport. Once it passes, the next statement fails with TimeoutError and the connection closes (#257). A pool that bounds a health-check ping with set_timeouts! and then restores 0 hits this on the next statement.

What changed

  • set_timeouts! clears the transport's read and write deadlines when the session is open. A non-zero timeout re-arms its own deadline before the next read or write, and a 0 timeout leaves none.
  • connect no longer clears the connection-establishment deadline itself, because the set_timeouts! call that follows it now does.

Fixes #257

Scope

  • Covers every caller of set_timeouts!: connect and code that sets the timeouts later on an open connection.
  • A 0 timeout still arms nothing before each read and write, so the connect phase keeps its single connect_timeout deadline.
  • Postgres.jl has no equivalent bug. Its only per-operation deadline, in wait_for_notification, is cleared in a finally.

Blast Radius

Only set_timeouts! and the end of connect change. A caller that set an absolute deadline on the transport and then called set_timeouts! now loses that deadline. No code in the package does this; connect cleared its deadline at that point anyway.

Verification

  • Reproduced the issue's script against MySQL 8.4.13 in Docker over plain TCP and TLS on main: TimeoutError ... (phase READY) and isopen(conn) == false. With this branch: the second SELECT 1 succeeds and the connection stays open. A probe of the transport's armed deadlines shows them at 0 after set_timeouts!(s, 0, 0); on main they stayed at about now + 1 s.
  • New serverless test "set_timeouts! to 0 leaves no deadline armed (Protocol.set_timeouts!(s, 0, 0) leaves the last armed read/write deadline in force; the next statement fails with TimeoutError #257)". It fails on main with the same TimeoutError from flush_command!, and passes here. Protocol suite on Julia 1.12.6: 1791/1791.
  • connect_timeout=1 with and without read_timeout/write_timeout, over TCP and TLS against MySQL 8.4.13: a statement 1.5 s after connect succeeds, so the establishment deadline is still cleared.
  • Re-read adversarially: the only internal caller is connect (session READY, so the clear runs). A closed or broken session skips the clear, because setting a deadline on a closed Reseau descriptor throws. The arm functions and their zero-cost default path are unchanged.

🤖 Generated with Claude Code

quinnj and others added 2 commits November 10, 2026 12:20
After a command runs under 1 s read and write timeouts, lowering them to 0
and waiting 1.5 s must not fail the next command. On main it fails with
TimeoutError (phase READY) and closes the connection (#257).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A per-operation timeout of 0 arms nothing before a read or write, so after
set_timeouts!(s, 0, 0) the deadline armed under the previous timeouts stayed
on the transport. Once it passed, the next statement failed with TimeoutError
and the connection closed.

set_timeouts! now clears both transport deadlines when the session is open.
connect no longer clears the establishment deadline separately, because the
set_timeouts! call that follows it does.

Fixes #257

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@quinnj quinnj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[review generated via AI]

Approving. An independent check reproduced #257 on main: the new testset fails there, because a timeout set to 0 still left a deadline armed. On this head the protocol suite passes 1791/1791, and the full suite with the live MySQL 8.4 lanes passes 2305/2305, over plain TCP and TLS.

@quinnj-bot
quinnj-bot Bot merged commit 29d3a0a into main Nov 11, 2026
17 checks passed
@quinnj-bot
quinnj-bot Bot deleted the claude/set-timeouts-clear-deadlines branch November 11, 2026 04:22
@quinnj-bot quinnj-bot Bot mentioned this pull request Nov 11, 2026
quinnj referenced this pull request Nov 11, 2026
Co-authored-by: Jacob Quinn <quinn.jacobd@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

Protocol.set_timeouts!(s, 0, 0) leaves the last armed read/write deadline in force; the next statement fails with TimeoutError

1 participant