与MySQL一起“等待表元数据锁定”

时间:2015-06-05 00:31:11

标签: mysql google-cloud-sql

我正在使用Google Cloud SQL(5.5)并经常发生“等待表格元数据锁定”。

我阅读了this pagethis post,并查看了general_log。

以下是general_log的摘录。

                 :
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Close stmt',''),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Prepare','SELECT * FROM .....'),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Execute','SELECT * FROM .....'),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Close stmt',''),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Prepare','SELECT * FROM .....),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Execute','SELECT * FROM .....'),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Close stmt',''),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Prepare','SELECT * FROM .....'),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Execute','SELECT * FROM .....'),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Close stmt',''),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Prepare','SELECT * FROM .....'),
('2015-06-03 07:15:25','root[root] @ localhost []',1081,1791318620,'Execute','SELECT * FROM .....'),
('2015-06-03 07:17:11','[root] @ localhost []',2,1791318620,'Connect','root@localhost on mydb'),
('2015-06-03 07:17:11','[root] @ localhost []',3,1791318620,'Connect','root@localhost on mydb'),
('2015-06-03 07:17:32','root[root] @ localhost []',2,1791318620,'Query','set autocommit=1'),
('2015-06-03 07:17:32','root[root] @ localhost []',3,1791318620,'Query','set autocommit=1'),
('2015-06-03 07:17:32','root[root] @ localhost []',1,1791318620,'Query','set autocommit=1'),
('2015-06-03 07:17:32','root[root] @ localhost []',3,1791318620,'Query','SET sql_mode=\'STRICT_TRANS_TABLES\''),
('2015-06-03 07:17:32','root[root] @ localhost []',2,1791318620,'Query','SET sql_mode=\'STRICT_TRANS_TABLES\''),
('2015-06-03 07:17:32','root[root] @ localhost []',1,1791318620,'Query','SET sql_mode=\'STRICT_TRANS_TABLES\''),
('2015-06-03 07:17:32','root[root] @ localhost []',3,1791318620,'Query','commit'),
('2015-06-03 07:17:32','root[root] @ localhost []',2,1791318620,'Query','commit'),
('2015-06-03 07:17:32','root[root] @ localhost []',1,1791318620,'Query','commit'),
('2015-06-03 07:17:32','root[root] @ localhost []',3,1791318620,'Query','SET NAMES utf8mb4'),
('2015-06-03 07:17:32','root[root] @ localhost []',2,1791318620,'Query','SET NAMES utf8mb4'),
('2015-06-03 07:17:32','root[root] @ localhost []',1,1791318620,'Query','SET NAMES utf8mb4'),
('2015-06-03 07:17:32','[root] @ localhost []',4,1791318620,'Connect','root@localhost on mydb'),
('2015-06-03 07:17:32','[root] @ localhost []',5,1791318620,'Connect','root@localhost on mydb'),
('2015-06-03 07:17:33','root[root] @ localhost []',5,1791318620,'Query','set autocommit=1'),
('2015-06-03 07:17:33','root[root] @ localhost []',4,1791318620,'Query','set autocommit=1'),
('2015-06-03 07:17:33','root[root] @ localhost []',5,1791318620,'Query','SET sql_mode=\'STRICT_TRANS_TABLES\''),
('2015-06-03 07:17:33','root[root] @ localhost []',4,1791318620,'Query','SET sql_mode=\'STRICT_TRANS_TABLES\''),
('2015-06-03 07:17:33','root[root] @ localhost []',5,1791318620,'Query','commit'),
('2015-06-03 07:17:33','root[root] @ localhost []',4,1791318620,'Query','commit'),
('2015-06-03 07:17:33','root[root] @ localhost []',5,1791318620,'Query','SET NAMES utf8mb4'),
                 :

从07:15:25到07:17:11没有日志但我的应用程序发出查询并且没有问题。 围绕general_log恢复(07:17或07:18),我的应用程序停滞不前,show processlist显示“等待表元数据锁定。”

我知道DDL导致“等待表元数据锁定。”,但我确信我没有执行任何DDL。

我的猜测是丢失了general_log导致“等待表元数据锁定。”,但我不确定为什么会发生日志丢失。

我猜对了吗?如果是这样,为什么会发生损失? 或者还有其他原因吗?

[更新] show processlist如下所示。

+----+------+-----------------+------+---------+------+---------------------------------+-------------------+
| Id | User | Host            | db   | Command | Time | State                           | Info              |
+----+------+-----------------+------+---------+------+---------------------------------+-------------------+
|  1 | root | localhost       | mydb | Execute |  335 | Waiting for table metadata lock | SELECT * FROM ... |
|  2 | root | localhost       | mydb | Execute |  358 | Waiting for table metadata lock | SELECT * FROM ... |
|  4 | root | localhost       | mydb | Prepare |  359 | Opening table                   | NULL              |
|  6 | root | localhost       | mydb | Prepare |  347 | Waiting for table metadata lock | NULL              |
|  7 | root | localhost       | mydb | Execute |  346 | Waiting for table metadata lock | SELECT * FROM ... |
|  8 | root | localhost       | mydb | Execute |  335 | Waiting for table metadata lock | SELECT ...        |
|  9 | root | localhost       | mydb | Execute |  320 | Waiting for table metadata lock | SELECT ...        |
| 11 | root | localhost       | mydb | Execute |  299 | Waiting for table metadata lock | SELECT * FROM ... |
| 12 | root | localhost       | mydb | Prepare |  299 | Waiting for table metadata lock | NULL              |
| 13 | root | localhost       | mydb | Execute |  279 | Waiting for table metadata lock | SELECT * FROM ... |
| 14 | root | localhost       | mydb | Execute |  269 | Waiting for table metadata lock | SELECT * FROM ... |
| 16 | root | localhost       | mydb | Sleep   |  240 |                                 | NULL              |
| 17 | root | localhost       | mydb | Execute |  209 | Waiting for table metadata lock | SELECT * FROM ... |
| 19 | root | localhost       | mydb | Execute |  203 | Waiting for table metadata lock | SELECT ...        |
| 21 | root | localhost       | mydb | Execute |  200 | Waiting for table metadata lock | SELECT * FROM ... |

0 个答案:

没有答案