Skip to content

Transactions: SAVEPOINT semantics are missing or inconsistent across clients #23125

Description

@dengn

Description

在事务中使用 SAVEPOINT 与 ROLLBACK TO SAVEPOINT 会触发内部错误:savepoint has not been implemented yet. please rollback the transaction. 表明 MatrixOne 尚未实现 MySQL 标准的保存点语义。

Error Message

ERROR 20101 (HY000) at line 8: internal error: savepoint has not been implemented yet. please rollback the transaction.

Related Table DDL

CREATE TABLE temp_txn_savepoint_2274 AS
SELECT id, company_name FROM company LIMIT 5;

Reproduction SQL

START TRANSACTION;
UPDATE temp_txn_savepoint_2274 SET company_name = CONCAT(company_name, '_tx') WHERE id % 2 = 0;
SAVEPOINT before_revert;
UPDATE temp_txn_savepoint_2274 SET company_name = CONCAT(company_name, '_rollback') WHERE id % 2 = 1;
ROLLBACK TO SAVEPOINT before_revert;
COMMIT;

Impact

  • 无法在长事务中做分段回滚,影响复杂 DML/调度流程。
  • MySQL 应用中依赖保存点的逻辑(如在线 DDL 工具、分批写入等)全部失效。

Expected Behavior

MySQL 允许创建多个保存点,并可回滚到任意保存点,同时保持事务继续。MatrixOne 应支持同等语义或提供清晰的功能缺失提示。

References

  • 报告: report_test_batch_228_txn_boundary_20251124_154800.md Case 2274 等 10 个用例。

Activity

  1. added
    severity/s2
    on May 18, 2026
  2. added this to the Backlog milestone on May 18, 2026
  3. removed
    severity/s2
    on Aug 6, 2026
  4. iamlinjunhong commented on Aug 20, 2026

    @iamlinjunhong
    Contributor

    Reconfirmed through MatrixOne ODBC and a direct MySQL 9.7.1 CLI on the latest main during Python/pyodbc deep testing.

    • MatrixOne: 592ad2190a90e063e3877059f4018427a10a4998
    • MatrixOne ODBC source: 8f1ca365289a0f8ea0d22e6581cce1ea4ae67454
    • Environment: Windows 11 x64 client; Ubuntu 24.04 WSL2 server; Python 3.12.13 + pyodbc 5.3.0

    Minimal sequence:

    create table repro_savepoint(id int primary key);
    begin;
    insert into repro_savepoint values (1);
    savepoint s1;

    Actual result from both clients:

    ERROR 20101 (HY000): internal error: savepoint has not been implemented yet. please rollback the transaction.
    

    Expected: create savepoint s1, allowing a later ROLLBACK TO SAVEPOINT s1 while retaining earlier work. There is no equivalent transparent workaround for libraries that require nested transaction semantics; applications must avoid savepoints and restructure transactions.

    Evidence is retained in server-scenarios-round2.json (R205), server-candidate-repros.sql, and direct-mysql-candidate-repros.log.

  5. Ariznawlll commented on Aug 25, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • commit:e866c535f5723fca6a8522c8338f7277e4b9e40f
    • 部署:本地全新数据目录,1 Log / 1 TN / 1 CN
    • 驱动:Connector/J 8.4.0、9.7.0,均启用 useServerPrepStmts=true

    原问题验证

    两个驱动各用 3 个新连接重复以下事务:

    1. DatabaseMetaData.supportsSavepoints() 均返回 true。
    2. BEGIN 后插入一行,调用 Connection.setSavepoint("s1")。
    3. 服务端均返回 savepoint has not been implemented yet. please rollback the transaction.。

    Happy Path 覆盖

    1. 两个驱动中的完整 ROLLBACK 均成功,确认插入行数回到 0。
    2. ROLLBACK 后同一连接可继续执行查询。

    Unhappy Path 覆盖

    1. JDBC 按元数据认为 savepoint 可用,但实际第一个 setSavepoint 调用即失败。
    2. 失败后执行完整 ROLLBACK 没有遗留部分写入。

    白盒验证

    不适用。本次从 JDBC API 到服务端错误结果验证已有公开行为,没有引入故障注入。

    回归测试

    未新增回归用例。该产品路径尚未实现,不能把当前失败行为固化为成功基线。

    测试证据

    两代驱动各 3 次,共 6/6 次返回相同服务端错误;本 issue 现有 ODBC 与 MySQL CLI 复现可交叉印证。

    测试结论

    测试不通过。

  6. self-assigned this
    on Sep 1, 2026
  7. iamlinjunhong commented on Sep 1, 2026

    @iamlinjunhong
    Contributor

    最新 main 复测(2026-09-01)

    main@33af6ae3c0c23e4f277137460577ea64678f7ecf 上,通过 MySQL CLI 和 MatrixOne ODBC 9.7 均验证:

    START TRANSACTION;
    INSERT INTO repro_savepoint VALUES (1);
    SAVEPOINT s1;

    SAVEPOINT 仍返回 ERROR 20101 (HY000): internal error: savepoint has not been implemented yet. please rollback the transaction.。完整 ROLLBACK 可清理写入,但无法提供 ROLLBACK TO SAVEPOINT 语义。

  8. added
    priority/p2
    on Oct 22, 2026
  9. changed the title [-]Transactions: SAVEPOINT not implemented[/-] [+]Transactions: SAVEPOINT semantics are missing or inconsistent across clients[/+] on Oct 22, 2026
  10. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    Consolidated reports #28248 and #30692 here as the same missing SAVEPOINT feature. Preserve the observed behavior discrepancy: #28248/#30692 report SAVEPOINT returning OK as a no-op followed by ROLLBACK TO failing; the newer reproduction already recorded on this issue reports SAVEPOINT itself returning the unimplemented error. Verify both paths on one exact commit/client matrix before treating the behavior as stable. Acceptance must cover SAVEPOINT, same-name replacement, ROLLBACK TO while keeping the transaction active, RELEASE, missing names, and cleanup at COMMIT/full ROLLBACK/implicit commit; no successful OK may represent a nonexistent savepoint.

  11. XuPeng-SH commented on Oct 23, 2026

    @XuPeng-SH
    Contributor

    Fresh evidence on main@3ad9adbb4c

    ROLLBACK TO SAVEPOINT is rejected with 20101 internal error: savepoint has not been implemented yet. please rollback the transaction. — but the transaction stays open and later commits everything, including statements issued after the savepoint:

    create table sp(id int primary key);
    begin;
    insert into sp values (1);
    savepoint p1;
    insert into sp values (2);
    rollback to p1;      -- ERROR 20101 (savepoint not implemented)
    commit;              -- succeeds
    select count(*) from sp;   -- 2  <-- the row that should have been rolled back is committed

    So a client that uses the SQLAlchemy/SQL standard nested-transaction idiom (SAVEPOINT → work → ROLLBACK TO) gets an error it may catch, and then silently commits the nested work when the outer transaction commits. Either the statement should abort the transaction, or SAVEPOINT should be implemented; the current middle ground is the risky one.

    Also verified as working, for contrast: full ROLLBACK reverts INSERT/UPDATE/DELETE including with secondary indexes; statement-level rollback on duplicate-key and foreign-key errors leaves the transaction usable and does not leave partial rows.

  12. XuPeng-SH commented on Oct 23, 2026

    @XuPeng-SH
    Contributor

    补充一条比"语句不可用"更严重的证据:ROLLBACK TO SAVEPOINT 报错之后,事务并没有被中止,仍然可以 COMMIT,于是本来要求丢弃的行被真实写入。

    复现(main @ 3ad9adbb4c,macOS arm64,本地 mo-service)

    create table spx(id int primary key, v varchar(5));

    同一连接内依次执行(mysql --force,出错后继续后续语句):

    begin;
    insert into spx values(1,'w1');
    savepoint sa;
    insert into spx values(2,'w2');
    rollback to sa;   -- ERROR 20101 (HY000): internal error: savepoint has not been implemented yet. please rollback the transaction.
    commit;           -- Query OK
    select group_concat(v order by id) from spx;

    实际输出:

    ERROR 20101 (HY000) at line 5: internal error: savepoint has not been implemented yet. please rollback the transaction.
    w1,w2
    

    持久化结果:1 w1 / 2 w2 —— w2 是调用方明确要求回滚掉的那一行,却被提交了。

    对照组(同一连接、同样两条 INSERT、不使用 savepoint):结果为 c1,c2,符合预期。

    为什么这比"功能未实现"更值得处理

    错误信息写的是 "please rollback the transaction",即由客户端负责收尾;但服务端既没有 abort 事务,也没有把它标记为不可提交。于是任何忽略 savepoint 错误继续执行的应用(ORM 的 begin_nested / transaction.atomic 嵌套块、手写分批脚本的 error 分支)都会在 COMMIT 时把本想丢弃的 DML 一并提交 —— 静默的数据错误,而不是可观测的失败。

    白盒定位

    pkg/frontend/mysql_cmd_executor.go:5758-5761:

    case *tree.SavePoint, *tree.ReleaseSavePoint:
        return nil
    case *tree.RollbackToSavePoint:
        return moerr.NewInternalError(execCtx.reqCtx, "savepoint has not been implemented yet. please rollback the transaction.")

    SAVEPOINT / RELEASE SAVEPOINT 直接返回成功(no-op),ROLLBACK TO SAVEPOINT 在设置任何事务中止状态之前就 return,事务因此保持 active 且可提交。

    建议

    三个方向任选其一,但需要一致:

    1. 实现 savepoint 语义;
    2. SAVEPOINT / RELEASE 也立即报 not-supported(让驱动在第一条语句就失败,而不是走到无法收拾的中间态);
    3. 若继续维持报错 + 客户端收尾的策略,则 ROLLBACK TO SAVEPOINT 失败时必须把事务置为不可提交(后续 COMMIT 返回错误),避免"要求丢弃却被提交"。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

deferredpriority/p2

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions