In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you what is two-phase submission and group submission, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.
For the sake of performance, in order to ensure data security when the transaction is committed, it is necessary to unload the redo and undo data without waiting for the data to be dropped. However, mysql should consider not only the redo data of the innodn storage engine layer, but also the order of the binlog data of the upper layer of the database. Two-phase commit can solve the problem of redo and binlog order of a single transaction.
Two-phase commit (2PC) is divided into two processes:
L preparation phase (prepare phase)
The xid information is generated, the rollback segment is set to prepare status, and the redo is removed from the disk.
L submission phase (commit phase)
The XID event,Binlog of commit is generated in binlog, the rollback segment is released, and the lock is released.
Rollback of two-phase commit:
Only write redo, not binlog, rollback.
Redo,binlog closed the market successfully, there is also commit XID, naturally it is a success.
The redo,binlog is closed successfully. Without commit XID, the transaction is considered to have been committed.
Now let's think about the next question. If you have to unload redo and binlog when everything is submitted, then the bottleneck will be magnified in the unwinding phase. At this time, it is necessary to bring in the group to submit. Group commit allows redo and binlog to be unloaded in batches, and redo and binlog for multiple transactions can complete data storage in one fsync operation, reducing the call to fsync functions and improving efficiency. At the same time, the innodb storage engine layer itself supports group commit.
After the group was submitted, another problem was introduced. The binlog write order in the upper layer of the database cannot be consistent with the transaction commit order in the innodb layer. If it is not consistent, there will be a scenario of lost transactions when building a master / slave through an online tool such as xtrabackup backup database, such as the following:
Binlog commit order (T _ 1 ~ T _ 2 ~ T _ 2 ~ T _ 3) and innodb commit _ order (T _ 2 ~ T _ 3 ~ T _ 1). At this time, innodb detects that both the upper and lower layers of T3 have been committed and believes that recovery is no longer needed, so T1 transactions do not go through two phases of commit during backup, and the data of T1 transactions are still the data before the start of transactions, and the data from the database is no longer recovered, resulting in T1 transactions being discarded. So later, prepare_commit_mutex was introduced to ensure the order in a serial way, but this would invalidate the group submission, so BLGC (binary log group commit) was later proposed.
The behavior is divided into three stages.
Flush stage
Generate binary logs of transactions in memory
Sync stage
Call the binary log of multiple transactions in memory to fsync flush once.
Commit stage
The binary log will have a queue in memory, the first transaction of the queue is leader, and the other times follower,leader will call the storage engine layer transaction in order to commit. Innodb itself supports group submission.
What are the two-phase submission and group submission? have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 217
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.