Skip to content

Python SDK AsyncClient pre-ping fails with PyMySQL 1.2.3 and SQLAlchemy 2.0.43 #30242

Description

@dengn

Problem

An installation allowed by matrixone-python-sdk==0.1.16 dependency metadata fails on an ordinary AsyncClient.execute() against MatrixOne v4.2.5. The error is in SQLAlchemy/aiomysql connection pre-ping, before database SQL execution. Replacing only PyMySQL 1.2.3 with 1.1.1 makes the same async query pass.

This was found while reviewing Python SDK documentation and building executable data-science tutorials (matrixorigin/matrixone-doc#518). Please document or constrain the affected dependency combination, or support it through an upstream driver/dialect fix.

Tested environment

  • Python 3.12.14
  • matrixone-python-sdk 0.1.16, installed from PyPI
  • SQLAlchemy 2.0.43
  • aiomysql 0.3.2
  • failing PyMySQL 1.2.3; passing PyMySQL 1.1.1
  • official matrixorigin/matrixone:4.2.5, reporting 8.0.30-MatrixOne-v4.2.5
  • isolated local database; synchronous queries and bound DML work

All 48 SDK Python source files in the v4.2.5 tag match the installed wheel. This report concerns the tested dependency tuple; it does not establish failure with every SQLAlchemy/Python/PyMySQL version.

Reproduce

python -m pip install matrixone-python-sdk==0.1.16 SQLAlchemy==2.0.43 aiomysql==0.3.2 PyMySQL==1.2.3

Provide MO_HOST, MO_PORT, MO_USER, MO_PASSWORD and MO_DATABASE for an existing dedicated test database.

import asyncio
import os
from matrixone import AsyncClient

async def main():
    client = AsyncClient(sql_log_mode='off')
    try:
        await client.connect(
            host=os.environ['MO_HOST'], port=int(os.environ['MO_PORT']),
            user=os.environ['MO_USER'], password=os.environ['MO_PASSWORD'],
            database=os.environ['MO_DATABASE'], on_connect=[])
        result = await client.execute('SELECT VERSION()')
        print(result.scalar())
    finally:
        await client.disconnect()

asyncio.run(main())

Expected: server version.

Observed:

matrixone.exceptions.QueryError: Query execution failed:
AsyncAdapt_aiomysql_connection.ping() missing 1 required positional argument: 'reconnect'

Repeating with PyMySQL==1.1.1 returns the server version successfully. No server setting, database or SDK code was changed.

Relevant behavior

SQLAlchemy 2.0.43's mysql/pymysql.py _send_false_to_ping inspects PyMySQL's Connection.ping signature and chooses either ping(False) or ping(). The aiomysql adapter's ping requires a reconnect positional argument. SDK AsyncClient enables pool_pre_ping. This appears to be a dependency interoperability problem, not a MatrixOne SQL feature failure.

Please include a regression check for connection reuse/pre-ping rather than testing connect() alone. The documentation should publish a working dependency tuple and distinguish distribution metadata 0.1.16 from the module's current version value 1.0.0.

Activity

  1. dengn commented on Oct 15, 2026

    @dengn
    ContributorAuthor

    Additional dependency control: PyPI currently resolves SQLAlchemy 2.1.4. Keeping SDK 0.1.16, PyMySQL 1.2.3, aiomysql 0.3.2 and the same MO v4.2.5 server, sync and async SELECT VERSION both pass with SQLAlchemy 2.1.4.

    The failure should therefore stay scoped to the SQLAlchemy 2.0.43 tuple above. Upgrading SQLAlchemy is another demonstrated basic-query workaround, alongside using PyMySQL 1.1.1. This suggests documenting/constraining tested driver dependency combinations rather than treating it as a MatrixOne server SQL bug. The 2.1.4 check was a read-only connection/SELECT smoke test, not requalification of every SDK manager or full data-science workflow.

  2. MatrixAdventurer commented on Oct 15, 2026

    @MatrixAdventurer
    Contributor

    由LW授权的ChatGPT Business智能体提交。

    Deduplication/update: draft PR #30074 already changes AsyncClient pre-ping, so I did not open a competing fix. Its current head e197b1d still misses the reported SQLAlchemy 2.0.43 combination because its workaround is gated to 1.4 only. A new isolated diagnostic reproduces the exact adapter TypeError before raw ping (zero calls); 1.4.54 and 2.0.54 controls succeed with the same PyMySQL 1.2.3 / aiomysql 0.3.2 pair. Independent review confirmed the bounded finding.

    Full evidence and limitations are in #30074 (comment) . This is a real driver/adapter boundary reproduction, not a full SDK/pool-reuse/MatrixOne integration pass. No product patch, PR, assignment, merge or deployment is claimed.

  3. XuPeng-SH commented on Oct 18, 2026

    @XuPeng-SH
    Contributor

    本轮合并后功能验证新增依赖组合证据(2026-10-18):

    • SDK/server main 4226537e5094995155eab9c2a883db649ff7b95b,Linux/amd64,Python 3.12,SQLAlchemy 1.4.54、aiomysql 0.3.2、PyMySQL 1.2.3;真实嵌入式数据库,通过 TCP/MySQL、认证用户和独立测试数据库运行。
    • tests/online/test_sdk_vector_batch_chunks.py 实际结果:15 passed / 10 failed。10 个异步场景均在连接复用/pre-ping 返回 AsyncAdapt_aiomysql_connection.ping() missing 1 required positional argument: 'reconnect';同步场景通过。不是服务端 SQL 回归。
    • 仅将 PyMySQL 切换为 1.1.1,保留相同 SDK/server SHA、SQLAlchemy/aiomysql 与原始测试:25 passed, 0 failed,Go 外层测试退出 0。覆盖实际批量写入、后续块失败回滚、原生 scalar、literal 和异步 session 路径。
    • SDK 定向离线测试另有 158 passed。上述两次在线执行都是本轮新执行,不引用 CI/作者结果。

    因此沿用本 issue 跟踪依赖兼容性,新增确认 1.4.54 的真实 SDK/pool-reuse 路径也受影响;不能将此前单独 adapter 控制的成功外推为完整 SDK 成功。不另建重复 issue,也不归因于 #30076 引入。已将该验证限制同步到 #30076。

    原始日志、测试 overlay 与退出码保留在 /workspace/work/pr-audit-continue18/logs/main-sql-final.log、main-sdk111.log;测试仅启用仓库现有 MO_TEST_CLUSTER_TCP_ONLY=1,无生产逻辑补丁。

  4. Ariznawlll commented on Oct 26, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • SDK 源码:官方 main 861a2c4cb68961d8b6b01f18e0aa6ac52a3a505f;本地隔离 MO 服务端源码 5fe08a3307e246e1ab9951ab690b50557af0f509,VERSION()=8.0.30-MatrixOne-v1.3.0,单 CN。
    • Python 3.11;SQLAlchemy 2.0.55;aiomysql 0.3.2;对照 PyMySQL 1.2.3 与 1.1.1。2026-10-26。

    原问题验证

    本轮没有复跑 issue 原始的 SQLAlchemy 2.0.43 pre-ping 场景,不判断其修复状态。补充的是同一个 SDK 允许的 aiomysql 0.3.2 + PyMySQL 1.2.3 依赖组合下,异步 ORM 绑定 bytes 的另一条失败路径;请勿把以下结果理解为服务端二进制存储失败。

    Happy Path 覆盖

    1. 同一 VARBINARY 列,SQL 字面量 X'00FF' 和同步 ORM 绑定 b'\xff\x00' 均精确写入、读回,3/3。
    2. 仅将 PyMySQL 改为 1.1.1,保持 aiomysql/SQLAlchemy/服务端不变,异步 ORM 与普通 SQLAlchemy 异步引擎绑定 00FF、FF00 均精确读回,3/3。
    3. PyMySQL 1.2.3 下异步 ORM 插入 SQL NULL 正常。

    Unhappy Path 覆盖

    1. PyMySQL 1.2.3 下 async with client.session() 添加带 bytes 的 SQLAlchemy 对象,提交时 3/3 抛 TypeError: 'str' object is not callable;普通 SQLAlchemy 异步引擎绑定 bytes 同样 3/3 抛相同错误。失败均发生在驱动参数转义,未向表中留下行;随后 SELECT 42 正常。

    白盒验证

    aiomysql 0.3.2 的 connection.escape() 调用从 pymysql.converters 导入的 escape_bytes_prefixed;PyMySQL 1.2.3 将它定义为字符串哨兵 DO NOT IMPORT THIS!!!,而 1.1.1 中它是函数。SDK 当前依赖范围 PyMySQL>=1.0.0、aiomysql>=0.2.0 均允许失败组合。此处是依赖互操作缺口,和本 issue 已讨论的依赖约束/版本矩阵同类;不另开重复 issue。

    回归测试

    本轮未修改仓库测试或 PR。修复依赖约束或上游驱动后,建议在异步 ORM 和普通异步引擎各加入 VARBINARY 的 NUL/非 UTF-8 字节绑定与读回,覆盖受支持的依赖版本组合。

    测试证据

    本地复现脚本:/private/tmp/mo-sdk-complete-20261026/async_orm_binary_dependency_probe.py;1.1.1 对照:/private/tmp/mo-sdk-complete-20261026/async_orm_binary_111_control.py。两份脚本各 3 次新库运行,精确行集、失败后状态、连接可用性和清理均已断言。

    测试结论

    测试不通过。

  5. added a commit that references this issue on Oct 26, 2026
    28e8760
  6. XuPeng-SH commented on Oct 26, 2026

    @XuPeng-SH
    Contributor

    QA addendum (2026-10-26): SDK 28e8760905a7f39dba2ce436357ea75492f30512, Python 3.12.14, SQLAlchemy 2.0.55, aiomysql 0.3.2 and PyMySQL 1.2.3, with isolated server 83c1e23526fc0ed31188abd7fc2ca87cd3a6d4b3 (v1.3.0): test_async_public_contracts_and_pre_ping passed repeated pre-ping on this tuple. SQLAlchemy 2.0.43 and MatrixOne 4.2.5 were not used, so the original tuple remains unverified on the current SDK.

    Separately, the reporter's #30242 (comment) documents an async bytes-binding failure at SDK 861a2c4 with aiomysql 0.3.2/PyMySQL 1.2.3; it is not a current-head rerun. The current SDK dependency metadata still permits those versions. Handing off to QA to verify the original tuple and this related driver boundary; this is not a pass claim.

  7. Ariznawlll commented on Oct 30, 2026

    @Ariznawlll
    Collaborator

    结论

    测试不通过。当前 main 上原依赖组合的重复 pre-ping 已通过,但本 issue 先前记录的同组异步二进制绑定仍失败,暂不能作为完整 SDK 兼容性通过。

    关键证据

    • 官方 main@d39d8a40343ccd40bf665036388df7a40ee867f8,修复 PR fix(python-sdk): enforce handshake, TLS, redaction and async deadlines #30074 的合并提交 8ef2eaf4d923bdb4136dd81a50850e8eced0f368 在该版本祖先链;隔离 1 CN / 1 TN / 1 LogService,二进制和 SDK 源码同 SHA。Python 3.12、SQLAlchemy 2.0.43、aiomysql 0.3.2、PyMySQL 1.2.3。
    • 每轮全新数据库中,AsyncClient 默认连接重复执行 SELECT 1 10 次,均返回 [(1,)],共 3/3 轮;所测 main 环境未再观察原 pre-ping 的 reconnect 参数错误。
    • 同一客户端进入异步 Session,以 SQLAlchemy 绑定 b'\x00\xff' 写入 VARBINARY,3/3 抛出 QueryError: Query execution failed: 'str' object is not callable,与本 issue 历史记录的驱动二进制互操作残留相符。每轮失败后源表为 0 行,后续 SELECT 1 正常,测试库清理。
    • 本次两部分分别记录,不把诊断脚本中对错误的捕获当成成功产品回归;未向 MOTR 提交错误 golden。请研发确认允许依赖组合与 async bytes 兼容方案。

    待解决点

    • 此次服务器为最新 main,并非 issue 最初的 4.2.5;不能据此断言 4.2.5 已修复。未跑完整 SDK/MOTR suite,未覆盖其他驱动版本组合。
  8. added a commit that references this issue on Oct 30, 2026
    91dfab2
  9. XuPeng-SH commented on Oct 30, 2026

    @XuPeng-SH
    Contributor

    新修复转 QA:#31889 已合入 main,合并提交 91dfab2132c4c4fcd3f9a115dbfa968b196b8b14。

    现有连接/池 owner 安装异步 bytes 编码适配,并在实际 pre-ping owner 设置兼容参数;对应最新评论的 SQLAlchemy2.0.43/aiomysql0.3.2/PyMySQL1.2.3 bytes 与重复 pre-ping 残留。

    已核对 issue 正文、完整评论及当前合并源码/测试内容。历史失败按其原 SHA 保留;新修复直接覆盖上述残留,未发现适用于新修复的已验证反例或尚未完成的开发 follow-up。本轮仅源码/测试内容静态核对,没有运行 MatrixOne 服务或 SDK 回归;作者在 PR 内的运行结果是作者证据,不是本轮独立测试。转 Ariznawlll 继续验证,不代表验收通过。

    QA 待验范围:原始依赖组合、managed/已预热 adopted/shared pool、NUL/非UTF8 bytes和NULL、失败后连接可用性;历史4.2.5发行版和GBK真实连接未由本轮验证。

  10. Ariznawlll commented on Nov 3, 2026

    @Ariznawlll
    Collaborator

    结论

    测试通过。所测依赖组合下,AsyncClient 重复 pre-ping 和异步二进制绑定均可正常使用。

    关键证据

    • 官方 main@d61a7206c16b30baa4efc525eb6067c4364035aa;Python 3.12、SQLAlchemy 2.0.43、aiomysql 0.3.2、PyMySQL 1.2.3,真实隔离 MO。
    • **Happy case:**原依赖组合的重复连接和 SELECT 三轮通过;managed、预热后 adopted 和 shared pool 均可重复 pre-ping,并写入、读取带 NUL/非 UTF-8 字节及 NULL,三轮通过。
    • **Unhappy case:**重复主键写入按预期失败,已有行未改变,随后 SELECT 仍成功,三轮通过。
    • 白盒:SDK test_async_binary_driver.py 10 项离线检查通过。已有 SDK MOTR 原场景与补充预期输出的二进制/连接池场景已加入 MOTR #305,本次联合三轮通过。

    待解决点

    MOTR PR 尚待评审合入;测试对象是当前 main,不声称已发布的 4.2.5 二进制被修改,GBK 真实连接未覆盖。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions