Bug #47249 | assert in MDL_global_lock::is_lock_type_compatible | ||
---|---|---|---|
Submitted: | 10 Sep 2009 13:15 | Modified: | 7 Mar 2010 1:39 |
Reporter: | Matthias Leich | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Locking | Severity: | S3 (Non-critical) |
Version: | 5.4 | OS: | Any |
Assigned to: | Jon Olav Hauglid | CPU Architecture: | Any |
Tags: | locking, mdl |
[10 Sep 2009 13:15]
Matthias Leich
[15 Sep 2009 14:45]
Jon Olav Hauglid
I've tried to reproduce the bug with the current version of mysql-next-bugfixing. I've found that the assertion is triggered depending on the LOCK TABLES statement issued in connection "con_1". Of the possible combinations of READ and WRITE locks and different locking order, only the following result in the assert: LOCK TABLES t1 WRITE, v1 READ; LOCK TABLES v1 WRITE, t1 READ; So, for example, LOCK TABLES t1 READ, v1 WRITE; LOCK TABLES v1 READ, t1 WRITE; both work fine. The use of transactional or non-transactional locks make no difference. So LOCK TABLES v1 IN EXCLUSIVE MODE, t1 IN SHARE MODE; cause an assert while LOCK TABLES t1 IN SHARE MODE, v1 IN EXCLUSIVE MODE; does not. This makes sense as the transactional locks are converted to non-transactional.
[18 Sep 2009 11:32]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/83712 2824 Jon Olav Hauglid 2009-09-18 Bug #47249 assert in MDL_global_lock::is_lock_type_compatible This assert could be triggered if LOCK TABLES were used to lock both a table and a view that used the same table. The table would have to be first WRITE locked and then READ locked. So "LOCK TABLES v1 WRITE, t1 READ" would eventually trigger the assert, "LOCK TABLES v1 READ, t1 WRITE" would not. The reason is that the ordering of locks in the interal representation made a difference when executing FLUSH TABLE on the table. During FLUSH TABLE, a lock was upgraded to exclusive. If this lock is of type MDL_SHARED and not MDL_SHARED_UPGRADABLE, an internal counter in the MDL subsystem would get out of sync. This would happen if the *last* mention of the table in LOCK TABLES was a READ lock. The counter in question is the number exclusive locks (active or intention). This is used to make sure a global metadata lock is only taken when the counter is zero (= no conflicts). The counter was increased when a MDL_EXCLUSIVE or MDL_SHARED_UPGRADABLE lock is taken, but not when upgrade_shared_lock_to_exclusive() was used to upgrade directly from MDL_SHARED to MDL_EXCLUSIVE. This patch fixed the problem by increasing the counter if a MDL_SHARED lock is upgraded to MDL_EXCLUSIVE. Test case added to mdl_sync.test.
[23 Sep 2009 6:32]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/84241 2834 Jon Olav Hauglid 2009-09-23 Bug #47249 assert in MDL_global_lock::is_lock_type_compatible This assert could be triggered if LOCK TABLES were used to lock both a table and a view that used the same table. The table would have to be first WRITE locked and then READ locked. So "LOCK TABLES v1 WRITE, t1 READ" would eventually trigger the assert, "LOCK TABLES v1 READ, t1 WRITE" would not. The reason is that the ordering of locks in the interal representation made a difference when executing FLUSH TABLE on the table. During FLUSH TABLE, a lock was upgraded to exclusive. If this lock was of type MDL_SHARED and not MDL_SHARED_UPGRADABLE, an internal counter in the MDL subsystem would get out of sync. This would happen if the *last* mention of the table in LOCK TABLES was a READ lock. The counter in question is the number exclusive locks (active or intention). This is used to make sure a global metadata lock is only taken when the counter is zero (= no conflicts). The counter is increased when a MDL_EXCLUSIVE or MDL_SHARED_UPGRADABLE lock is taken, but not when upgrade_shared_lock_to_exclusive() is used to upgrade directly from MDL_SHARED to MDL_EXCLUSIVE. This patch fixes the problem by searching for a TABLE instance locked with MDL_SHARED_UPGRADABLE or MDL_EXCLUSIVE before calling upgrade_shared_lock_to_exclusive(). The patch also adds an assert checking that only MDL_SHARED_UPGRADABLE locks are upgraded to exclusive. Test case added to lock_multi.test.
[23 Sep 2009 8:42]
Jon Olav Hauglid
Pushed to mysql-6.0-codebase-bugfixing (version 6.0.14-alpha)
[30 Sep 2009 8:19]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20090929093622-1mooerbh12e97zux) (version source revid:alik@sun.com-20090923103200-kyo2bakdo6tfb2fb) (merge vers: 6.0.14-alpha) (pib:11)
[1 Oct 2009 17:16]
Paul DuBois
Noted in 6.0.14 changelog. Using LOCK TABLES to lock a table and a view with the same name could raise an assertion. Setting report to NDI pending push into 5.4.x.
[9 Dec 2009 9:46]
Jon Olav Hauglid
Pushed to mysql-next-4284 (5.6.0-beta)
[16 Feb 2010 16:50]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100216101445-2ofzkh48aq2e0e8o) (version source revid:kostja@sun.com-20091211154405-c9yhiewr9o5d20rq) (merge vers: 6.0.14-alpha) (pib:16)
[16 Feb 2010 17:00]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100216101208-33qkfwdr0tep3pf2) (version source revid:kostja@sun.com-20091209094613-abuml0vrrr90nvxt) (pib:16)
[16 Feb 2010 19:26]
Dmitry Lenev
Since this bug is not repeatable in any publicly available tree with version < 6.0 there is nothing to document. So I am simply closing this bug.
[6 Mar 2010 11:06]
Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@mysql.com-20100216221947-luyhph0txl2c5tc8) (merge vers: 5.5.99-m3) (pib:16)
[7 Mar 2010 1:39]
Paul DuBois
No changelog entry needed.