Hi Folks,
I'm relatively new to MySQL, and I have some Python unit tests (Python 3.3.1, MySQL Connector/Python 1.0.11) that are hanging when running against a local MySQL server ("Server version: 5.6.12 MySQL Community Server") due to 'Waiting for table metadata lock'. I've not been able to winnow the tests down to a small repeatable case, so I'm sorry I can't include code. However, autocommit is False (the default), and I'm managing transactions explicitly, so maybe I should find a list of uncommitted transactions.
Below are some MySQL meta queries I hope will provide some starting information to get some much-appreciated help from you: SHOW PROCESSLIST, INFORMATION_SCHEMA tables, and SHOW ENGINE INNODB STATUS. Please let me know what else I can provide.
Thanks so much! -- matt
================
mysql> show processlist;
+-----+------+-----------------+------+---------+------+---------------------------------+---------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-----+------+-----------------+------+---------+------+---------------------------------+---------------------+
| 75 | test | localhost:57237 | test | Sleep | 807 | | NULL |
| 76 | test | localhost:57238 | test | Sleep | 807 | | NULL |
| 77 | test | localhost:57239 | test | Sleep | 807 | | NULL |
| 78 | test | localhost:57240 | test | Sleep | 807 | | NULL |
| 82 | root | localhost | NULL | Query | 0 | init | show processlist |
| 84 | test | localhost:57244 | test | Sleep | 762 | | NULL |
| 86 | test | localhost:57246 | test | Sleep | 738 | | NULL |
| 87 | test | localhost:57247 | test | Sleep | 738 | | NULL |
| 88 | test | localhost:57248 | test | Sleep | 735 | | NULL |
| 91 | test | localhost:57274 | test | Sleep | 696 | | NULL |
| 96 | test | localhost:57290 | test | Sleep | 641 | | NULL |
| 98 | test | localhost:57292 | test | Sleep | 616 | | NULL |
| 99 | test | localhost:57295 | test | Sleep | 600 | | NULL |
| 100 | test | localhost:57296 | test | Sleep | 587 | | NULL |
| 101 | test | localhost:57297 | test | Sleep | 576 | | NULL |
| 104 | test | localhost:57300 | test | Sleep | 541 | | NULL |
| 106 | test | localhost:57302 | test | Sleep | 512 | | NULL |
| 107 | test | localhost:57334 | test | Sleep | 512 | | NULL |
| 109 | test | localhost:57571 | test | Sleep | 466 | | NULL |
| 110 | test | localhost:57679 | test | Query | 465 | Waiting for table metadata lock | DROP TABLE memberof |
+-----+------+-----------------+------+---------+------+---------------------------------+---------------------+
20 rows in set (0.00 sec)
mysql>
================
mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;
Empty set (0.07 sec)
mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;
Empty set (0.00 sec)
mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX;Empty set (0.00 sec)
mysql>
================
mysql> SHOW ENGINE INNODB STATUS \G;
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
2013-07-29 11:25:56 12be0d000 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 47 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 365 srv_active, 0 srv_shutdown, 1862 srv_idle
srv_master_thread log flush and writes: 2227
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 1456
OS WAIT ARRAY INFO: signal count 1525
Mutex spin waits 637, rounds 13084, OS waits 338
RW-shared spins 900, rounds 27063, OS waits 900
RW-excl spins 248, rounds 7903, OS waits 218
Spin rounds per wait: 20.54 mutex, 30.07 RW-shared, 31.87 RW-excl
------------
TRANSACTIONS
------------
Trx id counter 1382556
Purge done for trx's n:o < 1382556 undo n:o < 0 state: running but idle
History list length 2170
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 111, OS thread handle 0x12be0d000, query id 17416 localhost root init
SHOW ENGINE INNODB STATUS
---TRANSACTION 0, not started
MySQL thread id 110, OS thread handle 0x12bd87000, query id 17343 localhost 127.0.0.1 test Waiting for table metadata lock
DROP TABLE memberof
---TRANSACTION 1382494, not started
MySQL thread id 109, OS thread handle 0x12bdca000, query id 17324 localhost 127.0.0.1 test cleaning up
---TRANSACTION 0, not started
MySQL thread id 107, OS thread handle 0x12bd01000, query id 16528 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1377552, not started
MySQL thread id 106, OS thread handle 0x12bd44000, query id 16502 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1372458, not started
MySQL thread id 104, OS thread handle 0x12bcbe000, query id 15525 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1365986, not started
MySQL thread id 101, OS thread handle 0x12bc7b000, query id 14560 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1364010, not started
MySQL thread id 100, OS thread handle 0x12bc38000, query id 14249 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1361914, not started
MySQL thread id 99, OS thread handle 0x12b184000, query id 13935 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1359291, not started
MySQL thread id 98, OS thread handle 0x12bbf5000, query id 13486 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1355113, not started
MySQL thread id 96, OS thread handle 0x12b141000, query id 12857 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1346418, not started
MySQL thread id 91, OS thread handle 0x1287d3000, query id 11547 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1340336, not started
MySQL thread id 88, OS thread handle 0x128790000, query id 10669 localhost 127.0.0.1 test cleaning up
---TRANSACTION 0, not started
MySQL thread id 87, OS thread handle 0x12870a000, query id 10595 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1339919, not started
MySQL thread id 86, OS thread handle 0x12874d000, query id 10569 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1335683, not started
MySQL thread id 84, OS thread handle 0x1286c7000, query id 9937 localhost 127.0.0.1 test cleaning up
---TRANSACTION 0, not started
MySQL thread id 75, OS thread handle 0x1260eb000, query id 8619 localhost 127.0.0.1 test cleaning up
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
1540 OS file reads, 31739 OS file writes, 30458 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 276671, node heap has 1 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 367753964
Log flushed up to 367753964
Pages flushed up to 367753964
Last checkpoint at 367753964
0 pending log writes, 0 pending chkp writes
27121 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 137363456; in additional pool allocated 0
Dictionary memory allocated 186772
Buffer pool size 8191
Free buffers 3988
Database pages 4202
Old database pages 1531
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 504, created 3698, written 1522
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 4202, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Main thread id 4914806784, state: sleeping
Number of rows inserted 2543, updated 257, deleted 34, read 2696
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
1 row in set (0.00 sec)
ERROR:
No query specified
mysql>
================
I'm relatively new to MySQL, and I have some Python unit tests (Python 3.3.1, MySQL Connector/Python 1.0.11) that are hanging when running against a local MySQL server ("Server version: 5.6.12 MySQL Community Server") due to 'Waiting for table metadata lock'. I've not been able to winnow the tests down to a small repeatable case, so I'm sorry I can't include code. However, autocommit is False (the default), and I'm managing transactions explicitly, so maybe I should find a list of uncommitted transactions.
Below are some MySQL meta queries I hope will provide some starting information to get some much-appreciated help from you: SHOW PROCESSLIST, INFORMATION_SCHEMA tables, and SHOW ENGINE INNODB STATUS. Please let me know what else I can provide.
Thanks so much! -- matt
================
mysql> show processlist;
+-----+------+-----------------+------+---------+------+---------------------------------+---------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-----+------+-----------------+------+---------+------+---------------------------------+---------------------+
| 75 | test | localhost:57237 | test | Sleep | 807 | | NULL |
| 76 | test | localhost:57238 | test | Sleep | 807 | | NULL |
| 77 | test | localhost:57239 | test | Sleep | 807 | | NULL |
| 78 | test | localhost:57240 | test | Sleep | 807 | | NULL |
| 82 | root | localhost | NULL | Query | 0 | init | show processlist |
| 84 | test | localhost:57244 | test | Sleep | 762 | | NULL |
| 86 | test | localhost:57246 | test | Sleep | 738 | | NULL |
| 87 | test | localhost:57247 | test | Sleep | 738 | | NULL |
| 88 | test | localhost:57248 | test | Sleep | 735 | | NULL |
| 91 | test | localhost:57274 | test | Sleep | 696 | | NULL |
| 96 | test | localhost:57290 | test | Sleep | 641 | | NULL |
| 98 | test | localhost:57292 | test | Sleep | 616 | | NULL |
| 99 | test | localhost:57295 | test | Sleep | 600 | | NULL |
| 100 | test | localhost:57296 | test | Sleep | 587 | | NULL |
| 101 | test | localhost:57297 | test | Sleep | 576 | | NULL |
| 104 | test | localhost:57300 | test | Sleep | 541 | | NULL |
| 106 | test | localhost:57302 | test | Sleep | 512 | | NULL |
| 107 | test | localhost:57334 | test | Sleep | 512 | | NULL |
| 109 | test | localhost:57571 | test | Sleep | 466 | | NULL |
| 110 | test | localhost:57679 | test | Query | 465 | Waiting for table metadata lock | DROP TABLE memberof |
+-----+------+-----------------+------+---------+------+---------------------------------+---------------------+
20 rows in set (0.00 sec)
mysql>
================
mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;
Empty set (0.07 sec)
mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;
Empty set (0.00 sec)
mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX;Empty set (0.00 sec)
mysql>
================
mysql> SHOW ENGINE INNODB STATUS \G;
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
2013-07-29 11:25:56 12be0d000 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 47 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 365 srv_active, 0 srv_shutdown, 1862 srv_idle
srv_master_thread log flush and writes: 2227
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 1456
OS WAIT ARRAY INFO: signal count 1525
Mutex spin waits 637, rounds 13084, OS waits 338
RW-shared spins 900, rounds 27063, OS waits 900
RW-excl spins 248, rounds 7903, OS waits 218
Spin rounds per wait: 20.54 mutex, 30.07 RW-shared, 31.87 RW-excl
------------
TRANSACTIONS
------------
Trx id counter 1382556
Purge done for trx's n:o < 1382556 undo n:o < 0 state: running but idle
History list length 2170
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 111, OS thread handle 0x12be0d000, query id 17416 localhost root init
SHOW ENGINE INNODB STATUS
---TRANSACTION 0, not started
MySQL thread id 110, OS thread handle 0x12bd87000, query id 17343 localhost 127.0.0.1 test Waiting for table metadata lock
DROP TABLE memberof
---TRANSACTION 1382494, not started
MySQL thread id 109, OS thread handle 0x12bdca000, query id 17324 localhost 127.0.0.1 test cleaning up
---TRANSACTION 0, not started
MySQL thread id 107, OS thread handle 0x12bd01000, query id 16528 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1377552, not started
MySQL thread id 106, OS thread handle 0x12bd44000, query id 16502 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1372458, not started
MySQL thread id 104, OS thread handle 0x12bcbe000, query id 15525 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1365986, not started
MySQL thread id 101, OS thread handle 0x12bc7b000, query id 14560 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1364010, not started
MySQL thread id 100, OS thread handle 0x12bc38000, query id 14249 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1361914, not started
MySQL thread id 99, OS thread handle 0x12b184000, query id 13935 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1359291, not started
MySQL thread id 98, OS thread handle 0x12bbf5000, query id 13486 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1355113, not started
MySQL thread id 96, OS thread handle 0x12b141000, query id 12857 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1346418, not started
MySQL thread id 91, OS thread handle 0x1287d3000, query id 11547 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1340336, not started
MySQL thread id 88, OS thread handle 0x128790000, query id 10669 localhost 127.0.0.1 test cleaning up
---TRANSACTION 0, not started
MySQL thread id 87, OS thread handle 0x12870a000, query id 10595 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1339919, not started
MySQL thread id 86, OS thread handle 0x12874d000, query id 10569 localhost 127.0.0.1 test cleaning up
---TRANSACTION 1335683, not started
MySQL thread id 84, OS thread handle 0x1286c7000, query id 9937 localhost 127.0.0.1 test cleaning up
---TRANSACTION 0, not started
MySQL thread id 75, OS thread handle 0x1260eb000, query id 8619 localhost 127.0.0.1 test cleaning up
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
1540 OS file reads, 31739 OS file writes, 30458 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 276671, node heap has 1 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 367753964
Log flushed up to 367753964
Pages flushed up to 367753964
Last checkpoint at 367753964
0 pending log writes, 0 pending chkp writes
27121 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 137363456; in additional pool allocated 0
Dictionary memory allocated 186772
Buffer pool size 8191
Free buffers 3988
Database pages 4202
Old database pages 1531
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 504, created 3698, written 1522
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 4202, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Main thread id 4914806784, state: sleeping
Number of rows inserted 2543, updated 257, deleted 34, read 2696
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
1 row in set (0.00 sec)
ERROR:
No query specified
mysql>
================