diff options
author | Dmitry Lenev <dlenev@mysql.com> | 2010-02-28 07:35:09 +0300 |
---|---|---|
committer | Dmitry Lenev <dlenev@mysql.com> | 2010-02-28 07:35:09 +0300 |
commit | 6b5c4a9ef61eff4768c6fdf04857ae8a1b219a6c (patch) | |
tree | 72819bde0c313c8ef3b67a20ff9ac4fe00833093 /sql/mdl.h | |
parent | 093106f552ae890a0c6b4b183899a5d0affa1629 (diff) | |
download | mariadb-git-6b5c4a9ef61eff4768c6fdf04857ae8a1b219a6c.tar.gz |
Fix for bug #51105 "MDL deadlock in rqg_mdl_stability test
on Windows".
On platforms where read-write lock implementation does not
prefer readers by default (Windows, Solaris) server might
have deadlocked while detecting MDL deadlock.
MDL deadlock detector relies on the fact that read-write
locks which are used in its implementation prefer readers
(see new comment for MDL_lock::m_rwlock for details).
So far MDL code assumed that default implementation of
read/write locks for the system has this property.
Indeed, this turned out ot be wrong, for example, for
Windows or Solaris. Thus MDL deadlock detector might have
deadlocked on these systems.
This fix simply adds portable implementation of read/write
lock which prefer readers and changes MDL code to use this
new type of synchronization primitive.
No test case is added as existing rqg_mdl_stability test can
serve as one.
config.h.cmake:
Check for presence of pthread_rwlockattr_setkind_np to be
able to determine if system natively supports read-write
locks for which we can specify if readers or writers should
be preferred.
configure.cmake:
Check for presence of pthread_rwlockattr_setkind_np to be
able to determine if system natively supports read-write
locks for which we can specify if readers or writers should
be preferred.
configure.in:
Check for presence of pthread_rwlockattr_setkind_np to be
able to determine if system natively supports read-write
locks for which we can specify if readers or writers should
be preferred.
include/my_pthread.h:
Added support for portable read-write locks which prefer
readers.
To do so extended existing my_rw_lock_t implementation to
support selection of whom to prefer depending on a flag.
mysys/thr_rwlock.c:
Extended existing my_rw_lock_t implementation to support
selection of whom to prefer depending on a flag.
Added rw_pr_init() function implementing initialization of
read-write locks preferring readers.
sql/mdl.cc:
Use portable read-write locks which prefer readers instead of
relying on that system implementation of read-write locks has
this property (this was true for Linux/NPTL but was false,
for example, for Windows and Solaris).
Added comment explaining why preferring readers is important
for MDL deadlock detector (thanks to Serg for example!).
sql/mdl.h:
Use portable read-write locks which prefer readers instead of
relying on that system implementation of read-write locks has
this property (this was true for Linux/NPTL but was false,
for example, for Windows and Solaris).
Diffstat (limited to 'sql/mdl.h')
-rw-r--r-- | sql/mdl.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sql/mdl.h b/sql/mdl.h index 59bc1f64762..42461f6ac2f 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -624,10 +624,11 @@ private: /** Read-write lock protecting m_waiting_for member. - TODO/FIXME: Replace with RW-lock which will prefer readers - on all platforms and not only on Linux. + @note The fact that this read-write lock prefers readers is + important as deadlock detector won't work correctly + otherwise. @sa Comment for MDL_lock::m_rwlock. */ - rw_lock_t m_waiting_for_lock; + rw_pr_lock_t m_waiting_for_lock; MDL_ticket *m_waiting_for; uint m_deadlock_weight; /** @@ -651,9 +652,9 @@ private: void will_wait_for(MDL_ticket *pending_ticket) { - rw_wrlock(&m_waiting_for_lock); + rw_pr_wrlock(&m_waiting_for_lock); m_waiting_for= pending_ticket; - rw_unlock(&m_waiting_for_lock); + rw_pr_unlock(&m_waiting_for_lock); } void set_deadlock_weight(uint weight) @@ -669,9 +670,9 @@ private: void stop_waiting() { - rw_wrlock(&m_waiting_for_lock); + rw_pr_wrlock(&m_waiting_for_lock); m_waiting_for= NULL; - rw_unlock(&m_waiting_for_lock); + rw_pr_unlock(&m_waiting_for_lock); } void wait_reset() |