Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL DDL ignores autocommit transactionality #7485

Closed
max-hoffman opened this issue Feb 12, 2024 · 1 comment · Fixed by #8767
Closed

MySQL DDL ignores autocommit transactionality #7485

max-hoffman opened this issue Feb 12, 2024 · 1 comment · Fixed by #8767
Labels
sql Issue with SQL transactions

Comments

@max-hoffman
Copy link
Contributor

max-hoffman commented Feb 12, 2024

CREATE and ALTER statements ignore autocommit transactions in MySQL. They do not commit the working set, but they are immediately available to other sessions

  • CREATE table is immediately visible to all sessions, including those with set autocommit=0
  • ALTER table, CREATE_VIEW, PROCEDURE, TRIGGER are also immediately visible
  • CREATE/ALTER do not commit in progress updates, but do block ROLLBACKs from undoing the current working set. Subsequent working set changes within the transaction can still be ROLLBACKed.
  • CREATE DATABASE seems to be session specific, not visible to other sessions immediately.

For example:

/* client O */ set @@autocommit = 0;
/* client X */ set @@autocommit = 0;
/* client O */ create table wh1 (x int primary key);
/* client X */ insert into wh1 values (0); -- succeeds
/* client O */ select * from wh1; -- empty
/* client X */ alter table wh1 add index (x); -- also visible to client O
/* client X */ insert into wh1 values (1);
/* client X */ rollback;
/* client X */ select * from wh1; -- (0) row still in the working set
@max-hoffman max-hoffman added sql Issue with SQL transactions labels Feb 12, 2024
@max-hoffman
Copy link
Contributor Author

Because only DDL operations and not data bleed through, it is maybe possible to merge empty tables into the working roots for active sessions on the same branch. We would have to think through the failure cases for multiple threads trying to DDL the same table name concurrently.

This impacts TPC-C setup, but is maybe a test setup problem more than a practical problem for most customers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql Issue with SQL transactions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant