view counter

Why ALTER TABLE shows as two transactions in SHOW ENGINE INNODB STATUS

Thanks to Peter Zaitsev for this story

When executing an ALTER TABLE, InnoDB (and XtraDB) will create two InnoDB transactions:

view counter
  1. One transaction is created when the table being ALTERed is locked by the server.
    This will show up as something like “TABLE LOCK table `schema`.`table_name` trx id XXXX lock mode S” in SHOW ENGINE INNODB STATUS.
  2. Another is created when adding or dropping an index to perform operations on the InnoDB data dictionary.

A little known fact is that the InnoDB data dictionary is somewhat transactional (the big thing it’s missing is any form of MVCC. It’s not ACID). The largest part of ALTER TABLE not being completely crash safe in MySQL is the MySQL server manipulating FRM files.

The only MySQL storage engine I’m aware of having fully crash safe DDL is MySQL Cluster (NDB).

Read the entire article at its source

view counter