• notice
  • Congratulations on the launch of the Sought Tech site

2 problems analysis of mysql transaction rollback

Therefore, the correct atomic operation is actually performed.It is physical execution.

You can indeed see the inserted record in the current transaction.In the end it was just deleted.But AUTO_INCREMENT will not change the value if it should be deleted.

1.Why doesn't auto_increament roll back?

Because the current value of the counter record of InnoDB's auto_increament is stored in the memory, not on the disk, when mysql server is started, when we need to query the auto_increment count value, mysql will automatically execute: SELECT MAX(id) FROM table name FOR UPDATE; statement to get the maximum value of the current auto_increment column, and then put this value in the auto_increment counter.So even the auto_increament counter of Rollback MySQL will not perform negative operations.

2.Is the MySQL transaction a physical operation when operating on a table?

MySQL transactions have redo and undo.All information about redo operations is recorded in redo_log.That is to say, when a transaction performs a commit operation, the operation of the transaction needs to be written to redo_log first, and then Flush these operations to the disk.When a failure occurs, you only need to read the redo_log, and then flush to the disk again.

And undo is more troublesome.When MySQL is processing transactions, it will apply for a segment called segment in the data sharing table space to save undo information.When processing rollback, it is not a complete physical undo, but Logical undo means that the previous operation will be reversed, but these shared table spaces are not recycled.The recovery of these table spaces needs to be recovered by the mysql master thread process.

Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+