[MDEV-3891] Deadlock with statistics tables and ANALYZE Created: 2012-11-28 Updated: 2017-05-08 Resolved: 2014-04-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
(Initially found by Elena) I'll attach a testcase, which eventually gets three threads to be stuck in "Waiting for table level lock" state. The testcase must be run like this: ./mysql-test-run t/t45.test --repeat=100 (can also add --testcase-timeout=600 to ease debugging). Execution will get stuck after a minute. On my machine (pylon-fedora15), only release build gets stuck, and only when the server is started by MTR. Being stuck looks like this:
|
| Comments |
| Comment by Sergei Petrunia [ 2012-11-28 ] | |||||||||||||||||
|
Debugging results #1 *****************************************************************************
We're stuck when locking table #0, table_stat. We are: We're waiting on: table_stat, READ lock. (gdb) p * data->lock->write->data->owner ***************************************************************************** ** Thread 5 ***************************************************************************** "ANALYZE TABLE E" lock_count=3, all TL_WRITE, { table_stat, column_stat, index_stat }, we're locking 0th table. (gdb) up #2 wait_for_lock (wait=0x7f868c02d640, data=0x7f868c023ce0, in_wait_list=0 '\000', lock_wait_timeout=<optimized out>) at /home/psergey/dev2/maria-5.5-mwl248/mysys/thr_lock.c:569 (gdb) p data->lock->name $378 = 0x7f868c02a510 "table_stat" (gdb) p thd->lock_info $400 = {thread = 140216257812224, thread_id = 24} (gdb) p *data->lock->write->data->owner $397 = {thread = 140216257513216, thread_id = 25} Ok, we're thread 24 and we're waiting for "table_stat" because thread 25 has it. | |||||||||||||||||
| Comment by Sergei Petrunia [ 2012-11-28 ] | |||||||||||||||||
|
A hypothesis: Deadlock is caused by this sequence of events: SELECT takes a read lock on {mysql.index_stat, E}ANALYZE TABLE A tries to take write locks on {table_stat, column_stat, index_stat} it gets locks on table_stat and column_stat SELECT tries to load statistics data for the tables it is using. (The other ANALYZE command is also waiting, but it not actually pariticipating | |||||||||||||||||
| Comment by Elena Stepanova [ 2012-12-12 ] | |||||||||||||||||
|
Info requested by Igor: I observed the problem on maria-5.5-mwl248 revno 3569 (and AFAIR also double-checked later on 3570). | |||||||||||||||||
| Comment by Elena Stepanova [ 2014-04-08 ] | |||||||||||||||||
|
The bug was fixed in maria-5.5-mwl248 by the following revision:
|