Skip to content

fix(ios): stop MySQL timeouts and Stop leaving statements running, and keep synced passwords - #4177

Merged
datlechin merged 2 commits into
mainfrom
fix/audit-wave-2-ios
Nov 10, 2026
Merged

datlechin merged 2 commits into
mainfrom
fix/audit-wave-2-ios

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Fixes from the 2026-11-10 code audit (wave 2) for the iOS app.

MySQL

  • The fixed 30 s read timeout covers only the sign-in and setup reads. After that the socket timeout is none, or the query timeout plus 30 s, as on the Mac; IOSDriverFactory now passes the connection's query timeout, enforced on the server with max_execution_time (MySQL, TiDB), max_statement_time (MariaDB) or ob_query_timeout (OceanBase). A statement that outlasts the socket timeout is killed on the server.
  • The session socket has TCP keepalive (60 s idle, 10 s interval, 3 probes), so a dead path fails in about 90 s instead of hanging for two hours.
  • Stop sends KILL QUERY <thread id> (KILL TIDB QUERY on TiDB) over a second connection with the same TLS and sign-in, for the caller's own statement only. A reader that leaves sends no kill on TiDB, where a late kill drops the session. An IAM kill reuses the session's token for 10 minutes, then mints a fresh one for the real endpoint (behind an SSH tunnel too, through DriverFactory.createDriver(for:password:preTunnelHost:refreshPassword:)), and mints once more on a 1045.

PostgreSQL

  • The session socket gets the same keepalive. The iOS libpq is built without __darwin__, so keepalives_idle in the connection string was ignored.

Sessions and Keychain

  • A DuckDB file session closed when the app goes to the background now reports its lost transaction when the window comes back, with wording for a statement that was running at the time.
  • KeychainSecureStore.store updates in place and writes only the copy the Sync Passwords setting selects; it no longer deletes the synced copy other devices use. CertificateMaterialStore had the same delete-then-add and is fixed the same way.
  • With Sync Passwords on, a read returns the newer of the synced and device copies by kSecAttrModificationDate; with it off, this device's own copy first.

Test plan

  • verify.sh ios on an iPhone simulator, 28 suites covering every MySQL and PostgreSQL driver path, the connection coordinator, the transaction monitor and the Keychain stores: 302 passed. New suites: MySQLStopTests, MySQLQueryTimeoutTests, MySQLSessionSocketTests, MySQLKillTokenTests, MySQLKillSignInTests, PostgreSQLSessionSocketTests, ConnectionCoordinatorBackgroundTests, KeychainSecureStoreTests. Each new test is written to fail on main; that was traced, not run.
  • swift test for TableProCore: 4,944 passed, including the new ConnectionManagerSignInTests cases.
  • Not run against real servers, devices or an RDS endpoint.
  • Reviewed in three rounds by Claude agents that did not write the change; the last round's one minor finding is fixed.

@datlechin
datlechin merged commit b8ef7aa into main Nov 10, 2026
11 checks passed
@datlechin
datlechin deleted the fix/audit-wave-2-ios branch November 10, 2026 23:45
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.

1 participant