seata MYSQL慢日志一直打印问题

ruyhziif  于 2022-10-21  发布在  Mysql
关注(0)|答案(3)|浏览(310)

你好,我这边是用了seata做分布式事务,然后数据库是用MYSQL,以下是seata_server的数据库:

然后我在微服务的mysql开启慢日志,然后监控慢日志时,发现每秒钟都会打印以下日志信息,我慢日志的时间long_query_time已经是调了2秒了,但是还是会不断打印以下信息:
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 43088
Query_time: 0.000446 Lock_time: 0.000207 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635285;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (8) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:05.684876Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 43088
Query_time: 0.000503 Lock_time: 0.000237 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635285;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (0,1,2,3,4,5,6,7,8) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:06.659649Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 43088
Query_time: 0.000536 Lock_time: 0.000289 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635286;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (5,4,6,7) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:06.665833Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 70722
Query_time: 0.000246 Lock_time: 0.000088 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635286;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (8) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:06.665849Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 43088
Query_time: 0.000459 Lock_time: 0.000231 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635286;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (3) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:06.687370Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 70722
Query_time: 0.000521 Lock_time: 0.000284 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635286;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (0,1,2,3,4,5,6,7,8) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:07.659773Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 70722
Query_time: 0.000573 Lock_time: 0.000289 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635287;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (5,4,6,7) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:07.665637Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 70722
Query_time: 0.000418 Lock_time: 0.000215 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635287;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (3) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:07.666084Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 43088
Query_time: 0.000427 Lock_time: 0.000266 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635287;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (8) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:07.685012Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 70722
Query_time: 0.000567 Lock_time: 0.000278 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635287;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (0,1,2,3,4,5,6,7,8) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:08.659693Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 70722
Query_time: 0.000478 Lock_time: 0.000247 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635288;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (5,4,6,7) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:08.666109Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 43088
Query_time: 0.000462 Lock_time: 0.000218 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635288;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (8) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:08.666109Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 70722
Query_time: 0.000462 Lock_time: 0.000218 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635288;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (3) order by gmt_modified limit 100;
Time: 2021-08-22T12:28:08.684733Z
User@Host: 项目名[项目名] @ 项目名_seata.项目名 [xxx.xxx.xxx.xxx] Id: 43088
Query_time: 0.000420 Lock_time: 0.000232 Rows_sent: 0 Rows_examined: 0
SET timestamp=1629635288;
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (0,1,2,3,4,5,6,7,8) order by gmt_modified limit 100;

请问这个情况是要怎么处理呢?

guicsvcw

guicsvcw1#

没看出来哪里慢了,你的慢sql检测的组件是什么?
select xid, transaction_id, status, application_id, transaction_service_group, transaction_name, timeout, begin_time, application_data, gmt_create, gmt_modified from global_table where status in (8) order by gmt_modified limit 100;
这是tc的表,跟你微服务打印有什么关系,为什么你微服务打印了tc表查询的sql?

pwuypxnk

pwuypxnk2#

你好,我这边用的5.7版本的MYSQL,然后tc的数据库和微服务的数据库是放一台数据库里面的,也就是本质上只有一台mysql。

然后我这台mysql开启了慢日志set global slow_query_log = on,主要是检测一些执行比较慢的sql语句。

然后我设置了慢日志的时间是2秒,执行了:set long_query_time = 2,正常整个数据库超过2秒的执行语句才会记录到慢日志。

但是我发现,seata的这条扫描所有global_table数据的执行语句,执行时间其实不到1秒,但是会一直在慢日志打印,1秒打印一次,日志文件一下子就堆积了,所以我想问问具体是什么问题。

blmhpbnm

blmhpbnm3#

mysqldumpslow 拿一下慢查询的详细信息贴一下

相关问题