Original Does MySQL's quest for begin or start transaction really open new business?

Source: Internet
Author: User

Server Version:5.6.21-log MySQL Community Server (GPL)

Prerequisite Summary:

We know that under MySQL's RR (repeatable Read) isolation level, transactions cannot see the actions that are being made by the active firm, including post-commit.

The General command to open a transaction manually is begin or start transaction; My previous understanding is that once the execution of this statement has opened the transaction, that is, the transaction ID has been generated (available for the MVCC version comparison), and transaction A and transaction B perform the Begin, Commit TRANSACTION B for all operations of transaction A is not visible;

The facts are negative;

Environment:

Mysql>Show variables like 'tx_iso%';+---------------+-----------------+|Variable_name|Value|+---------------+-----------------+|Tx_isolation| Repeatable-READ |+---------------+-----------------+1Rowinch Set(0.00sec) MySQL>Show variables like 'auto%';+--------------------------+-------+|Variable_name|Value|+--------------------------+-------+|Auto_increment_increment| 1     ||Auto_increment_offset| 1     ||Autocommit|  on    ||Automatic_sp_privileges|  on    |+--------------------------+-------+4Rowsinch Set(0.00sec) MySQL>ShowCreate TableT12;+-------+----------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -------------+| Table | Create Table                                                                                                                                                                                                                    |+-------+----------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -------------+|T12| CREATE TABLE' T12 ' (' A 'int(Ten) unsigned not NULLauto_increment, ' B 'varchar(766)DEFAULT NULL, ' C 'int( One)DEFAULT NULL,  PRIMARY KEY(' A '),KEY' B ' (' B ')) ENGINE=InnoDB auto_increment= - DEFAULTCHARSET=Latin1|+-------+---------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- --------------+1Rowinch Set(0.00Sec

The experimental result is that transaction B sees the data submitted by transaction A in the case of uncommitted and rollback;

Once a begin, the transaction is opened immediately following the SELECT statement, or the data submitted by transaction A is not visible at start transaction with consistent snapshot;

That is to achieve the non-locking consistent read;

Conclusion: Begin;start transaction; The statement actually does not really open the transaction;

Original Does MySQL's quest for begin or start transaction really open new business?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.