fix(plugin-mysql): make socket read timeout follow the query timeout#1925
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1921.
Problem
With Settings > General > Query timeout set to 600s, a MySQL/MariaDB query or stored procedure that runs longer than about a minute without returning a packet fails with
[2026] TLS/SSL error: Operation timed out (60), while the statement keeps running on the server. That makes the result ambiguous and risks running a statement twice.Root cause
MariaDBPluginConnection.attemptConnecthardcodedMYSQL_OPT_READ_TIMEOUT = 30, with no relation to the configured query timeout. MariaDB Connector/C applies that as a per-read (inter-packet) timeout, set once at connect, so a query that emits no packet for ~30s is aborted client-side. The server-side timeout (SET SESSION max_execution_time/max_statement_time) is derived from the setting but never touches the socket timeout, and does not apply to stored procedures at all.The connector does not multiply the read timeout (the "3x" wording is Oracle's libmysqlclient, a different library), and
mysql_optionson a live handle has no effect, so the derived value must be set at connect.Fix
additionalFieldsconfig seam, injected app-side at driver creation. No PluginKit ABI change, no version bump.Retry safety (related)
executeWithReconnectreconnects and re-runs on connection-lost errors. On a plaintext connection a read timeout surfaces as error 2013, which was in the retry set, so a dropped connection could silently re-run an insert, update, or stored procedure. The retry is now gated on the statement being read-only, so it can never re-run a statement that changes data, while metadata SELECTs keep their stale-connection recovery.Tests
MySQLSocketTimeoutTests: 0 stays infinite, negative stays infinite, finite adds the grace, large values clamp without overflow.MySQLStatementClassificationTests: SELECT/SHOW/DESCRIBE/DESC read-only; INSERT/UPDATE/DELETE/CALL/REPLACE/DROP not; leading comments treated conservatively.Out of scope
The plugin's internal reconnect does not re-apply the server-side
SET SESSIONtimeout, and a settings change does not reach live sessions ("Applied to new connections"). Both are pre-existing and tracked separately.