我在很多输出中SHOW FULL PROCESSLIST
只看到了COMMIT
or commit
(小写和大写混合)。这些交易是什么?为什么没有 SQL 语句?我们正在运行 MariaDB 10.1.x 和 Galera 复制(3 个节点)。
如何解释这些交易?
> select COMMAND,TIME,STATE,INFO,TIME_MS,STAGE,MAX_STAGE,PROGRESS,MEMORY_USED,EXAMINED_ROWS,QUERY_ID,INFO_BINARY,TID from INFORMATION_SCHEMA.PROCESSLIST where INFO like '%commit%';
+---------+------+----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+-------+-----------+----------+-------------+---------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
| COMMAND | TIME | STATE | INFO | TIME_MS | STAGE | MAX_STAGE | PROGRESS | MEMORY_USED | EXAMINED_ROWS | QUERY_ID | INFO_BINARY | TID |
+---------+------+----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+-------+-----------+----------+-------------+---------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
| Query | 1 | init | COMMIT | 1267.015 | 0 | 0 | 0.000 | 67544 | 0 | 483610134 | COMMIT | 12241 |
| Query | 112 | init | COMMIT | 112442.763 | 0 | 0 | 0.000 | 67544 | 0 | 483594429 | COMMIT | 12003 |
| Query | 151 | init | COMMIT | 151914.251 | 0 | 0 | 0.000 | 67544 | 0 | 483588122 | COMMIT | 11972 |
| Query | 156 | init | COMMIT | 156962.716 | 0 | 0 | 0.000 | 141368 | 0 | 483587455 | COMMIT | 11962 |
| Query | 156 | init | COMMIT | 156961.757 | 0 | 0 | 0.000 | 141368 | 0 | 483587456 | COMMIT | 11960 |
| Query | 182 | init | commit | 182230.206 | 0 | 0 | 0.000 | 67544 | 0 | 483584325 | commit | 11801 |
| Query | 229 | init | COMMIT | 229144.061 | 0 | 0 | 0.000 | 67544 | 0 | 483578193 | COMMIT | 11529 |
| Query | 0 | Filling schema table | select COMMAND,TIME,STATE,INFO,TIME_MS,STAGE,MAX_STAGE,PROGRESS,MEMORY_USED,EXAMINED_ROWS,QUERY_ID,INFO_BINARY,TID from INFORMATION_SCHEMA.PROCESSLIST where INFO like '%commit%' | 0.346 | 0 | 0 | 0.000 | 104808 | 0 | 483610236 | select COMMAND,TIME,STATE,INFO,TIME_MS,STAGE,MAX_STAGE,PROGRESS,MEMORY_USED,EXAMINED_ROWS,QUERY_ID,INFO_BINARY,TID from INFORMATION_SCHEMA.PROCESSLIST where INFO like '%commit%' | 11359 |
| Query | 66 | init | commit | 66835.790 | 0 | 0 | 0.000 | 67544 | 0 | 483601099 | commit | 10917 |
| Query | 353 | init | commit | 353104.108 | 0 | 0 | 0.000 | 67544 | 0 | 483561401 | commit | 10807 |
| Query | 494 | init | COMMIT | 494696.772 | 0 | 0 | 0.000 | 338232 | 0 | 483540392 | COMMIT | 9997 |
有些事务需要在
COMMIT
. 我认为这就是你所看到的。然而,494 秒是一个很长的时间!即使是 121s 也很长。查看您的代码并找到可能的事务的 SQL 语句。在此处展示 SQL;也许我们可以进一步解释。
COMMIT TRANSACTION
如果在显式事务期间已写入/更新数据,则在从日志文件复制数据的最后一条语句之前,它可能根本不会写入数据文件。这使得在服务器崩溃后重新启动时出现错误后回滚是一个显式ROLLBACK TRANSACTION
语句,这是一个非常快速的操作,因为它只需将相关的日志条目标记为无效。如果在该事务期间添加或更改了大量数据,这可能需要一些时间。
在这种情况下
COMMIT TRANSACTION
,或一些有效的缩写,是这些会话的当前 SQL 语句。