1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Bug #51355 handler stmt cause assertion in

bool MDL_context::try_acquire_lock(MDL_request*)

This assert was triggered in the following way:
1) HANDLER OPEN t1 from connection 1
2) DROP TABLE t1 from connection 2. This will block due to the metadata lock
held by the open handler in connection 1.
3) DML statement (e.g. INSERT) from connection 1. This will close the table
opened by the HANDLER in 1) and release its metadata lock. This is done due
to the pending exclusive metadata lock from 2). 
4) DROP TABLE t1 from connection 2 now completes and removes table t1.
5) HANDLER READ from connection 1. Since the handler table was closed in 3),
the handler code will try to reopen the table. First a new metadata lock on
t1 will be granted before the command fails since the table was removed in 4).
6) HANDLER READ from connection 1. This caused the assert.

The reason for the assert was that the MDL_request's pointer to the lock
ticket was not reset when the statement failed. HANDLER READ then tried to
acquire a lock using the same MDL_request object, triggering the assert.
This bug was only noticeable on debug builds and did not cause any problems
on release builds.

This patch fixes the problem by assuring that the pointer to the metadata 
lock ticket is reset when reopening of handler tables fails.

Test case added to handler.inc
This commit is contained in:
Jon Olav Hauglid
2010-02-25 18:08:12 +01:00
parent a52ad97e67
commit 3eead1f0f1
4 changed files with 107 additions and 0 deletions

View File

@ -1685,3 +1685,28 @@ unlock tables;
# already released by commit.
handler t1 close;
drop tables t1, t2;
#
# Bug#51355 handler stmt cause assertion in
# bool MDL_context::try_acquire_lock(MDL_request*)
#
DROP TABLE IF EXISTS t1;
# Connection default
CREATE TABLE t1(id INT, KEY id(id));
HANDLER t1 OPEN;
# Connection con51355
# Sending:
DROP TABLE t1;
# Connection default
# This I_S query will cause the handler table to be closed and
# the metadata lock to be released. This will allow DROP TABLE
# to proceed. Waiting for the table to be removed.
# Connection con51355
# Reaping: DROP TABLE t1
# Connection default
HANDLER t1 READ id NEXT;
ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 READ id NEXT;
ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 CLOSE;
# Connection con51355
# Connection default