Skip to content

[Compatibility]: temporary-table CREATE and DROP are rolled back unlike MySQL #28255

Closed

Description

@Ariznawlll

Problem

MatrixOne makes CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE transactional. MySQL deliberately does not roll either operation back, although neither operation implicitly commits the surrounding transaction.

This creates two opposite compatibility differences:

  • after CREATE TEMPORARY TABLE followed by ROLLBACK, MatrixOne removes the table while MySQL keeps an empty table;
  • after DROP TEMPORARY TABLE followed by ROLLBACK, MatrixOne restores the table and its rows while MySQL keeps it dropped.

DML against a temporary table that already existed before the transaction rolls back correctly in both systems.

Version

  • MatrixOne main: e7bb0572235ec4bac81eb098eb0ad8900f0065ab
  • MySQL: 8.3.0

CREATE followed by ROLLBACK

create database codex_temp_txn;
use codex_temp_txn;
create table base(id int primary key);

start transaction;
insert into base values(1);
create temporary table tr(id int primary key);
insert into tr values(1);
rollback;

select * from base;
select * from tr;
insert into tr values(2);

Both systems roll back the permanent-table insert. MySQL retains tr with no rows and accepts the subsequent insert. MatrixOne reports that tr does not exist.

DROP followed by ROLLBACK

create temporary table td(id int primary key);
insert into td values(1);

start transaction;
insert into base values(3);
drop temporary table td;
rollback;

select * from base;
select * from td;
create temporary table td(id int primary key);

Both systems roll back the permanent-table insert, confirming that DROP TEMPORARY TABLE does not implicitly commit.

MySQL keeps td dropped, so the SELECT reports 1146 and recreating it succeeds. MatrixOne restores td with row (1) and then reports 1050 when it is recreated.

Control cases

The following paths match MySQL:

  • creating and populating a temporary table followed by COMMIT preserves both definition and rows;
  • DML on a temporary table created before START TRANSACTION is rolled back while the table remains;
  • DML on the permanent table remains transactional when temporary-table DDL occurs in the same transaction.

Expected behavior

Temporary-table DDL should follow MySQL's transaction contract: it must not cause an implicit commit, but the CREATE or DROP itself must remain effective after a later rollback. Only transactional DML performed on the temporary table should be undone.

Activity

  1. added this to the MO-202609 milestone on Sep 5, 2026
  2. added
    kind/bug
    on Sep 5, 2026
  3. added theissue type on Sep 5, 2026
  4. added
    ai-easy
    ai-light
    and removed
    ai-easy
    on Sep 8, 2026
  5. slyunnn commented on Sep 9, 2026

    @slyunnn

    Regression and extended verification for #28255 (2026-09-09)

    Verification Environment

    • MatrixOne baseline: latest local origin/main at 363f8c3fe63ab21f19d8e9ba854c24d2dcaadfc3 — fix(logservice): retry transient HAKeeper backend closures (#28453).
    • Related fix: PR #28332, feat: make temporary DDL transaction-independent, merged as cc205f5f5ef16c4e462fe31dc5dd2632d27f9f94. The merge commit is an ancestor of the baseline.
    • Topology: freshly built standalone deployment from the baseline; one mo-service hosts LOG/HAKeeper, one TN, and one CN. No Proxy and no second CN were used.
    • Endpoints: CN MySQL 127.0.0.1:6001; TN 127.0.0.1:19000; Log/HAKeeper 127.0.0.1:32001.
    • Clients and protocol: mysql CLI, PyMySQL, and MOTR/PyMySQL over MySQL wire protocol via TCP to 127.0.0.1:6001.

    What Was Covered

    • OK: Original CREATE TEMPORARY TABLE path: after ROLLBACK, the permanent-table insert is absent, the temporary definition remains, its transaction-created row is absent, and a later INSERT succeeds.
    • OK: Original DROP TEMPORARY TABLE path: after ROLLBACK, the permanent-table insert is absent, the temporary relation remains dropped with ERROR 1146, and recreating the same name succeeds.
    • OK: Happy path: CREATE TEMPORARY TABLE plus temporary DML followed by COMMIT retains both the definition and committed row.
    • OK: Happy path: DML on a temporary table created before START TRANSACTION rolls back while the table definition remains.
    • OK: Compatibility control: temporary DROP does not implicitly commit surrounding permanent-table DML; an explicit COMMIT persists that permanent row while the dropped temporary table remains absent.
    • OK: Boundary path: CREATE, populate, DROP, recreate, and populate the same temporary name in one transaction leaves only the latest empty definition after ROLLBACK; subsequent temporary DML still rolls back normally.
    • OK: The related fix BVT additionally covers temporary CTAS, failed CTAS cleanup/retry, prepared CREATE, hidden-index definitions, repeatable-read snapshot behavior, and multi-session observation.
    • Not covered: Proxy, multi-CN, JDBC, TKE, restart, and upgrade paths. The affected temporary-definition transaction boundary is connection-local and has no evidence of routing, scale, or mixed-version dependence.
    • Not covered: a fresh live MySQL 8.3.0 comparison and automatic removal on connection close; those compatibility facts were not changed by PR feat: make temporary DDL transaction-independent #28332 and were not needed to distinguish this rollback contract.

    Findings

    The current main preserves the intended MySQL-compatible boundary: CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE neither implicitly commit the surrounding transaction nor have their definition effect reversed by a later ROLLBACK. Temporary-table DML and permanent-table DML remain transactional.

    Large-data regression is not required. This defect concerns transaction ownership of a session-local temporary-table definition; it does not depend on row count, block/batch boundaries, memory/spill, concurrency, skew, network transfer, or resource scale. One row per DML outcome and two same-name generations are the minimum stable data set for the relevant state transitions.

    MOTR / BVT Coverage

    • Added MOTR regression: suites/14_issue_regression/t/issue_28255_temp_ddl_rollback.test and suites/14_issue_regression/r/issue_28255_temp_ddl_rollback.result.
    • Recorded once and replayed twice against the freshly built baseline. Each run passed 50 statements with 0 failures.
    • Independent backup branch: test/issue-28255-temp-ddl-rollback, commit 85b720f. No issue-specific PR was created.

    Final Conclusion

    Fixed. The current main contains the associated fix, and the original scenario plus happy-path, DML, commit, rollback, recreate-generation, and targeted BVT/MOTR coverage all pass. Large-data regression is not needed for the reasons above.

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

Metadata

Metadata

Assignees

Labels

ai-lightkind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions