MySQL笔记-删除session,删除阻塞任务

Posted IT1995

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL笔记-删除session,删除阻塞任务相关的知识,希望对你有一定的参考价值。

对应的关键字:

Waiting for table metadata lock

主要的命令如下:

 show processlist;
 kill 10086;
 select * from information_schema.innodb_trx\\G;

查processlist和kill

mysql> show processlist;
+----+-----------+-----------------------+-----------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User      | Host                  | db        | Command | Time | State                           | Info                                                                                                 |
+----+-----------+-----------------------+-----------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| 85 | financial | DESKTOP-82CT4I6:59226 | financial | Sleep   |  209 |                                 | NULL                                                                                                 |
| 86 | root      | localhost:59239       | financial | Query   |   44 | Waiting for table metadata lock | Alter table `financial`.`fund_open_price_year_2021`
  change `fundId` `fund_id` varchar(32) CHAR |
| 87 | root      | localhost:59240       | NULL      | Sleep   |   55 |                                 | NULL                                                                                                 |
| 89 | root      | localhost:59249       | NULL      | Query   |    0 | starting                        | show processlist                                                                                     |
+----+-----------+-----------------------+-----------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
4 rows in set (0.00 sec)

mysql> kill 86;
Query OK, 0 rows affected (0.00 sec)

查未提交的事务查询

mysql>  select * from information_schema.innodb_trx\\G;
*************************** 1. row ***************************
                    trx_id: 283818627624448
                 trx_state: RUNNING
               trx_started: 2022-02-15 15:26:30
     trx_requested_lock_id: NULL
          trx_wait_started: NULL
                trx_weight: 0
       trx_mysql_thread_id: 85
                 trx_query: NULL
       trx_operation_state: NULL
         trx_tables_in_use: 0
         trx_tables_locked: 0
          trx_lock_structs: 0
     trx_lock_memory_bytes: 1136
           trx_rows_locked: 0
         trx_rows_modified: 0
   trx_concurrency_tickets: 0
       trx_isolation_level: REPEATABLE READ
         trx_unique_checks: 1
    trx_foreign_key_checks: 1
trx_last_foreign_key_error: NULL
 trx_adaptive_hash_latched: 0
 trx_adaptive_hash_timeout: 0
          trx_is_read_only: 0
trx_autocommit_non_locking: 0
1 row in set (0.00 sec)

ERROR:
No query specified

mysql> kill 85;
Query OK, 0 rows affected (0.00 sec)

以上是关于MySQL笔记-删除session,删除阻塞任务的主要内容,如果未能解决你的问题,请参考以下文章

MySQL进阶实战7,查询的执行过程

MySQL笔记: 启动弹窗问题,unable to connect to remote host. catalog download has failed.

MySql安全模式删除

mybatis-动态删除学习笔记

MySQL 数据库中的 WP_Options 表超过 360Mb - 我可以通过删除 WC_sessions 来减小大小吗?

MySQL 5.7 新增默认账号 mysql.session和mysql.sys