Skip to content

[Bug]: SAVEPOINT is silently accepted but ROLLBACK TO SAVEPOINT always fails #30692

Closed as duplicate

Description

@Ariznawlll

Bug or Feature Request

Bug

Description

SAVEPOINT <name> silently succeeds (returns OK) but the matching ROLLBACK TO SAVEPOINT always fails with a hard error — leaving the user in a broken half-transaction state where the only escape is rolling back the entire transaction:

mysql> BEGIN;
Query OK
mysql> SAVEPOINT spX;          -- accepted, OK, no warning
Query OK
mysql> SELECT ...;             -- work continues
mysql> ROLLBACK TO SAVEPOINT spX;
ERROR 20101 (HY000): internal error: savepoint has not been implemented yet. please rollback the transaction.

This is a "half-implemented statement" pattern: the parser accepts SAVEPOINT, the executor acknowledges it (source: pkg/frontend/mysql_cmd_executor.go:5610 — case *tree.SavePoint, *tree.ReleaseSavePoint: return nil — silently a no-op), and only the rollback leg reveals the truth (case *tree.RollbackToSavePoint: ... "savepoint has not been implemented yet. please rollback the transaction.").

Why this is a real compatibility break, not just a missing feature:

  1. ORM drivers break at runtime. Django (transaction.atomic nested), SQLAlchemy (begin_nested), Sequelize, Knex etc. issue SAVEPOINT for nested transactions / inner atomic blocks. Against MatrixOne, the SAVEPOINT statement succeeds, so the ORM proceeds under the assumption nested-rollback is available; the failure then detonates later in the middle of application logic — possibly after a partial DML batch — with the only recovery being full-transaction rollback. If instead SAVEPOINT errored up front, the drivers would fall back to emulation or refuse cleanly at connect/probe time.

  2. Hand-written procedures get half-executed. A script that runs SAVEPOINT a; <DML batch>; ROLLBACK TO SAVEPOINT a on error — the standard batch pattern — commits the DML batch on success paths fine, but on the error path discovers the rollback command doesn't exist, and per the error message's own instruction must discard ALL work of the outer transaction.

  3. RELEASE SAVEPOINT is likewise accepted-and-ignored (same no-op case arm), so even the "cleanup" half of the protocol lies.

Steps to Reproduce

v3.x @ b24d1b3, macOS arm64:

BEGIN;
SAVEPOINT spX;                         -- Query OK (silently invalid)
SELECT 'still working' AS x;           -- continues fine
ROLLBACK TO SAVEPOINT spX;
-- ERROR 20101 (HY000): internal error: savepoint has not been implemented yet. please rollback the transaction.
ROLLBACK;                              -- the only way out per the error message

Controls:

  • SAVEPOINT spX; alone in a transaction → OK (no error, no warning) — evidence it's accepted-and-dropped.
  • RELEASE SAVEPOINT spX; → also OK, no-op.
  • MySQL 8: all three statements work; savepoints are core SQL/MySQL transactional protocol since 4.x.

Expected behavior

Pick one, but be consistent:

  • Implement SAVEPOINT / ROLLBACK TO / RELEASE (MySQL semantics), or
  • Reject SAVEPOINT (and RELEASE) with a not supported error immediately — mirroring the existing behavior of ROLLBACK TO SAVEPOINT — so drivers and scripts fail fast at the first statement rather than being led into a transaction they can no longer control.

Silently accepting SAVEPOINT while its counterpart errors is the worst of both worlds.

Versions

  • MatrixOne commit b24d1b3 (2026-10-16), v3.x dev, macOS arm64

Additional context

Activity

  1. added
    kind/bug
    on Oct 21, 2026
  2. added this to the MO-202611 milestone on Oct 21, 2026
  3. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    Consolidated into #23125. The accepted-but-no-op SAVEPOINT behavior from this report is retained there alongside the newer report of an explicit error at SAVEPOINT.

  4. Ariznawlll commented on Oct 26, 2026

    @Ariznawlll
    CollaboratorAuthor

    This is still reproducing on current main and now has a worse consequence than a plain error: the whole transaction is silently discarded, so a client that used SAVEPOINT as a partial-rollback guard loses its committed-so-far work.

    CREATE TABLE t_sp2 (id INT PRIMARY KEY, v INT);
    INSERT INTO t_sp2 VALUES (1, 10);
    
    BEGIN;
    UPDATE t_sp2 SET v = 20 WHERE id = 1;   -- work we want to keep
    SAVEPOINT sp1;                          -- silently accepted
    UPDATE t_sp2 SET v = 30 WHERE id = 1;   -- work we want to undo
    ROLLBACK TO sp1;
    -- ERROR 20101: internal error: savepoint has not been implemented yet. please rollback the transaction.
    COMMIT;
    SELECT v FROM t_sp2 WHERE id = 1;
    -- MO   : 10   <-- the v=20 update is LOST
    -- MySQL: 20   <-- correct

    So the failure mode is not "savepoint is a no-op": the ROLLBACK TO error aborts the entire transaction, and the subsequent COMMIT commits nothing. Clients using the common pattern "do work, savepoint, risky work, rollback to savepoint on error, commit the good part" lose the good part entirely.

    At minimum, SAVEPOINT should raise the same "not implemented" error immediately (as ROLLBACK TO does) so clients fail fast instead of building on a guard that silently discards everything.

  5. Ariznawlll commented on Oct 29, 2026

    @Ariznawlll
    CollaboratorAuthor

    Regression re-verification (main c6683bd2f5, 2026-10-29): the ganz pathology from this report is still present — SAVEPOINT is accepted, RELEASE SAVEPOINT is accepted, and only ROLLBACK TO SAVEPOINT errors, with the enclosing transaction continuing to a full COMMIT:

    BEGIN; INSERT ... (1);
    SAVEPOINT sp_a;                    -- OK
    INSERT ... (2);
    SAVEPOINT sp_b;                    -- OK
    INSERT ... (3);
    ROLLBACK TO SAVEPOINT sp_b;        -- ERROR 20101: savepoint has not been implemented
    SELECT COUNT(*);                   -- 3   (rollback did not happen, txn continues)
    ROLLBACK TO SAVEPOINT sp_a;        -- ERROR 20101 (same)
    RELEASE SAVEPOINT sp_a;             -- OK (!)
    COMMIT;                            -- commits all 3 rows

    The "accept-the-syntax, reject-the-only-meaningful-verb" shape is worse than an outright 1064: scripts declaring savepoints see every statement parse and only fail at the rollback instant, by which time the guarded work has already happened — and the subsequent successful COMMIT persists what the developer explicitly tried to roll back. In the trace above the final table contains all 3 rows.

    If the closure was about the syntax layer only (grammar accepting SAVEPOINT/RELEASE), the semantic half remains open on main; re-open or I can file a fresh standalone. Same closure-status pattern as #23126 (SKIP LOCKED) re-verified today in my session — worth a sweep of recently-closed transaction/compat issues.

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions