You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: AsyncClient ignores connection and query timeout settings #30063
Checked relevant Python SDK issues; this report concerns the SDK client path.
Environment
Repository main 3e50e1b32d8da61bbbf70c89989fb08b671809de, Python 3.12, SQLAlchemy 1.4/2.x. Initial findings were reproduced offline with synthetic inputs; real-service validation will be linked from the implementation PR.
Priority: P1.
Actual behavior and reproduction
AsyncClient stores connection_timeout and query_timeout, but _create_async_engine() does not pass connection timeout and execute() has no query deadline. connect() defaults can also override constructor options. In SQLAlchemy 2.1, the SDK's plain SQLAlchemy dependency can omit the required greenlet async runtime and leave async imports unavailable.
Expected behavior and design
Respect inherited/explicit connection timeout. Bound the connection probe and the full AsyncClient.execute operation, including pool wait and result fetching, with a documented deadline. Cancellation must propagate and release pool capacity. A timed-out write must not be blindly retried or described as proven rollback.
Declare the async SQLAlchemy runtime dependency. This fix covers AsyncClient calls, not a new asynchronous Arrow API or every independently managed Session operation.
Acceptance tests
Assert driver options, constructor/explicit precedence, positive finite validation, cancellation/finally execution, stalled actual network result timeout, pool return/reuse and failed-connect disposal. Re-run against SQLAlchemy 1.4, 2.0 and 2.1 with proper package installation/runtime dependencies.
Implementation tracking
#30074 — draft implementation with regression cases and recorded local validation. Pending review/merge; the issue closes on merge.
Activity
Ariznawlll commentedon Oct 20, 2026
测试版本
main,完整 commit21966565287edf9f7d7f519af60d269711608945;服务端git_version()=2196656528。8ef2eaf4d923bdb4136dd81a50850e8eced0f368;已通过 GitHub main compare 确认包含于执行时 main。mo-service(1 CN / 1 TN / 1 LogService,MySQL 127.0.0.1:6001)和独立 Python 3.12 SDK 虚拟环境;SQLAlchemy 2.1.5、aiomysql 0.3.2。仅使用本地测试库。原问题验证
在真实 MO 协议连接上对
AsyncClient.execute进行三轮端到端测试:query_timeout=0.05执行SELECT SLEEP(1),每轮均抛asyncio.TimeoutError;检查 SQLAlchemy 连接池checkedout()==0,然后恢复 3 秒期限执行SELECT 1,每轮均返回[(1,)]。另在执行SELECT SLEEP(1)期间显式取消 Python task,每轮均向调用方传播asyncio.CancelledError、池占用回到 0,之后SELECT 1仍返回[(1,)]。两条在线路径各 3/3 通过。Happy Path 覆盖
SELECT 1,六次均返回精确值 1;取消或超时后没有耗尽连接池。test_connection_contracts.py+test_connection_redaction_transport.py每轮 32 用例、3/3 轮通过;包含构造参数的connect_timeout传递到同步/异步驱动、显式超时值校验、成功连接探针和失败状态清理。加入连接 hooks 文件的定向运行 51/51 通过。Unhappy Path 覆盖
SELECT SLEEP(1)超出短期限:3/3 抛超时、释放池连接且随后可用。白盒验证
当前 main 的
AsyncClient.execute对完整_executeawait 使用asyncio.wait_for;_create_async_engine将配置的connect_timeout传给驱动。离线定向三轮和真实网络超时/取消三轮与该实现一致。未运行 Python-race(不适用)。回归测试
test_sdk_connection_contracts.py的两个在线超时/取消用例各 3/3。此问题是 SDK API 的 deadline/pool 行为,不适合用纯 SQL MOTR 替代,故未追加 MOTR。CI Required为成功;SDK online job 被跳过。本轮独立运行了上述在线定向,但未运行整个 SDK online suite;其它 independently managed Session/Arrow API 不属于本 issue 声明的修复范围。测试证据
git_version()如上;三轮在线命令每轮均显示两个测试通过,总计 timeout 3/3、explicit cancellation 3/3,各轮后的checkedout()==0和SELECT 1由断言核验。测试结论
测试通过。