summaryrefslogtreecommitdiff
path: root/sql/mdl.h
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@sun.com>2009-12-09 10:44:01 +0100
committerJon Olav Hauglid <jon.hauglid@sun.com>2009-12-09 10:44:01 +0100
commitfcae99271a82b8ab16883a135fa679711ce97b62 (patch)
treef4d748210ba947d843a9dd5f10b45f4cc19ca921 /sql/mdl.h
parent59f82702a18799621a19f1a880e9f80cb374b1ce (diff)
downloadmariadb-git-fcae99271a82b8ab16883a135fa679711ce97b62.tar.gz
Backport of revno: 2617.68.39
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.
Diffstat (limited to 'sql/mdl.h')
-rw-r--r--sql/mdl.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/sql/mdl.h b/sql/mdl.h
index 87982bc6af1..03631bb9dd6 100644
--- a/sql/mdl.h
+++ b/sql/mdl.h
@@ -254,6 +254,10 @@ public:
mdl_cached_object_release_hook release_hook);
const MDL_context *get_ctx() const { return m_ctx; }
bool is_shared() const { return m_type < MDL_EXCLUSIVE; }
+ bool is_upgradable_or_exclusive() const
+ {
+ return m_type == MDL_SHARED_UPGRADABLE || m_type == MDL_EXCLUSIVE;
+ }
bool upgrade_shared_lock_to_exclusive();
void downgrade_exclusive_lock();
private: