Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Critical
-
Resolution: Incomplete
-
Affects Version/s: 5.5.36
-
Fix Version/s: N/A
-
Component/s: None
-
Labels:None
-
Environment:Linux FC11
Description
Hi Guys, im having a query that takes like 2-5 seconds to execute, but sometimes is causing a deadlock...
Like 1 thread is "Sending data" indefinitely (>3 hours) and everything else is waiting in "Waiting for table metadata lock", this query would take only a couple of seconds, it's issued eg. 5000 times in short period of time (with very short wait between the queries)
From spec i'm seeing this:
>To ensure transaction serializability, the server must not permit one session to perform a data definition language (DDL) statement on a table that is used in an uncompleted transaction in another session.
Question is why all threads are waiting for "DDL" lock while no DDL operations are running (does lock table for write requires metadata lock?)
(A) Here is the offending query, after killing it everything gets processed.
http://screencast.com/t/Pg7fbNXZo
(B) There is another query like this, this was issued after the first one...
http://screencast.com/t/0QqRi8fZMWXQ
General states:
http://screencast.com/t/XOvtlqp4egB
Everything is waiting for metadata, one replication, one send thread.
The questions are ...
1. Bug?
2. Could the second query (B) issued after (A) cause deadlock because it's accessing similar tables?
3. CREATE TEMPORARY ... SELECT ... FROM A, B, C will grab DDL WRITE (not read) lock no only on the temp table but also on ABC?
4. If server picked only one thread to "run" why it isn't able to get any data (if it's sending, all locks should be acquired already?)
For reproducing, i can only send SHOW PROCESSLIST dump, because this happens like once every month, so no idea how more info about the issue can be extracted...
Thanks as always...
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
I was able to fix it by issuing
SET GLOBAL table_open_cache=64 (lowering from 400)
There was like 900 queries, all waiting for 1200 seconds, after issuing that, all the queries were instantly executed (after 2-3 seconds there were no waiting queries)
When it was at 400 - just one thread from 32 was at 100% CPU usage, with vmstat giving no read / writes ... is that possible that some OS limit prevented files from being open and mysql isn't reporting it in error log / dmesg?
Or it may be some problem with table cache (as changing it caused the problem to perish)? Is there possibility to add some timeout for opening files?