mysql 查询开启事务

select @@pseudo_thread_id

88055009


SELECT
    NOW(),  
   (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(a.trx_started)) diff_sec,
    b.id,
    b.user,
    b.host,
    b.db,
    a.trx_query,
    b.COMMAND
FROM
    information_schema.innodb_trx a
        INNER JOIN
    information_schema.PROCESSLIST b ON a.TRX_MYSQL_THREAD_ID = b.id and b.COMMAND<>'Sleep';}


SELECT
    r.trx_id waiting_trx_id,
    r.trx_mysql_thread_id waiting_thread,
    r.trx_query waiting_query,
    b.trx_id blocking_trx_id,
    b.trx_mysql_thread_id blocking_thread,
    b.trx_query blocking_query
FROM
    information_schema.innodb_lock_waits w
        INNER JOIN
    information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id
        INNER JOIN
    information_schema.innodb_trx r ON r.trx_id = w.requesting_trx_id
 
 
 
select  NOW(),  trx_started,
   (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(a.trx_started)) diff_sec ,
   a.TRX_MYSQL_THREAD_ID,
   a.trx_state from information_schema.INNODB_TRX a
   
   
   
mysql> select * from information_schema.PROCESSLIST where id='88055009';
+----------+--------+--------------------+-------+---------+------+-------+------+
| ID       | USER   | HOST               | DB    | COMMAND | TIME | STATE | INFO |
+----------+--------+--------------------+-------+---------+------+-------+------+
| 88055009 | dbsnmp | 1.1.101.231:59800 | rcedb | Sleep   |  260 |       | NULL |
+----------+--------+--------------------+-------+---------+------+-------+------+
1 row in set (0.00 sec)

mysql> select * from information_schema.PROCESSLIST where id='88055009';
+----------+--------+--------------------+-------+---------+------+-------------------+-------------------------------------------+
| ID       | USER   | HOST               | DB    | COMMAND | TIME | STATE             | INFO                                      |
+----------+--------+--------------------+-------+---------+------+-------------------+-------------------------------------------+
| 88055009 | dbsnmp | 1.1.101.231:59800 | rcedb | Query   |    6 | Sending to client | select * from t_application_broadcast_log |
+----------+--------+--------------------+-------+---------+------+-------------------+-------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from information_schema.innodb_trx where TRX_MYSQL_THREAD_ID='88055009';
+-----------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-------------------------------------------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
| trx_id          | trx_state | trx_started         | trx_requested_lock_id | trx_wait_started | trx_weight | trx_mysql_thread_id | trx_query                                 | trx_operation_state | trx_tables_in_use | trx_tables_locked | trx_lock_structs | trx_lock_memory_bytes | trx_rows_locked | trx_rows_modified | trx_concurrency_tickets | trx_isolation_level | trx_unique_checks | trx_foreign_key_checks | trx_last_foreign_key_error | trx_adaptive_hash_latched | trx_adaptive_hash_timeout | trx_is_read_only | trx_autocommit_non_locking |
+-----------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-------------------------------------------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
| 421646043876064 | RUNNING   | 2022-02-24 22:17:42 | NULL                  | NULL             |          0 |            88055009 | select * from t_application_broadcast_log | NULL                |                 1 |                 0 |                0 |                  1136 |               0 |                 0 |                       0 | REPEATABLE READ     |                 1 |                      1 | NULL                       |                         0 |                         0 |                1 |                          1 |
+-----------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-------------------------------------------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
1 row in set (0.00 sec)


mysql> SELECT
    ->     NOW(),  
    ->    (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(a.trx_started)) diff_sec,
    ->     b.id,
    ->     b.user,
    ->     b.host,
    ->     b.db,
    ->     a.trx_query,
    ->     b.COMMAND
    -> FROM
    ->     information_schema.innodb_trx a
    ->         INNER JOIN
    ->     information_schema.PROCESSLIST b ON a.TRX_MYSQL_THREAD_ID = b.id and b.COMMAND<>'Sleep';
+---------------------+----------+----------+--------+--------------------+-------+-------------------------------------------+---------+
| NOW()               | diff_sec | id       | user   | host               | db    | trx_query                                 | COMMAND |
+---------------------+----------+----------+--------+--------------------+-------+-------------------------------------------+---------+
| 2022-02-24 22:18:52 |       70 | 88055009 | dbsnmp | 1.1.101.231:59800 | rcedb | select * from t_application_broadcast_log | Query   |
+---------------------+----------+----------+--------+--------------------+-------+-------------------------------------------+---------+
1 row in set (0.00 sec)
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

scan724

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值