From 2b2be0b6d9b4435cb869841a1856831cdf5ae4e0 Mon Sep 17 00:00:00 2001 From: asahi Date: Wed, 27 Aug 2025 13:33:21 +0800 Subject: [PATCH] =?UTF-8?q?doc:=20=E9=98=85=E8=AF=BBmysql=20BLGC=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mysql/mysql文档/mysql_事务.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mysql/mysql文档/mysql_事务.md b/mysql/mysql文档/mysql_事务.md index f68de86..cce884c 100644 --- a/mysql/mysql文档/mysql_事务.md +++ b/mysql/mysql文档/mysql_事务.md @@ -643,4 +643,16 @@ binlog机制mysql上层的,和存储引擎无关,而redo log机制是和存 上述stages位于binlog commit过程的内部,并且不会造成其他影响。由于commit过程被拆分为了如下stages,故而可以同时存在数个线程同时对事务进行处理,这样会增加吞吐量。 -对于每个stage,都存在一个queue,session在queue中排队等待被处理。如果一个session被注册到了空的queue,那么其将被认为是stage leader,如果session被注册时queue不为空,那么其将作为stage follower。stage leader将会将queue中所有的threads移出stage,并且将leader和所有的followers注册到下个stage。 \ No newline at end of file +对于每个stage,都存在一个queue,session在queue中排队等待被处理。如果一个session被注册到了空的queue,那么其将被认为是stage leader,如果session被注册时queue不为空,那么其将作为stage follower。stage leader将会将queue中所有的threads经过stage处理并且将其注册到下一个stage,并且将leader和所有的followers注册到下个stage。 + +followers会被移动,并且等待leader通知整个commit都执行完成。 + +leader可能会注册到一个非空queue中,即leader可以决定成为一个follower;但是follower永远不会变成leader。 + +当leader进入到stage后,会一次性将queue抓取并依次处理queue中排队的session。当queue被抓取后,当leader在处理old queue时,其余的session又可以被注册到stage。 + +- `Flush Stage`: 在flush stage,所有注册到queue的session都会将其cache写入到binlog中。 +- `sync stage`:在sync stage,会根据`sync_binlog`的设置将binary log同步到磁盘中。如果`sync_binlog`值为1,所有被flushed的session都会被同步到磁盘中 +- `commit stage`:在commit stage,所有session将会按照其register的顺序在engine中进行提交,该步骤由stage leader完成。由于在commit procedure中,每个stage都保留了顺序,那么binlog中写入事务的顺序和引擎中事务的提交顺序是一致的。 + +