[MDEV-5089] possible deadlocks between rwlocks and mutexes Created: 2013-10-01 Updated: 2014-10-02 Resolved: 2014-10-02 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | OTHER |
| Fix Version/s: | 5.5.40 |
| Type: | Task | Priority: | Major |
| Reporter: | Sergei Golubchik | Assignee: | Sergey Vojtovich |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Description |
|
safe_mutex has built-in deadlock detection, but it only works for mutexes. When done, safe_mutex reports new locking order violations, the server doesn't even start. |
| Comments |
| Comment by Sergey Vojtovich [ 2014-02-13 ] | ||||||||||||
|
SHOW VARIABLES may acquire LOCK_system_variables_hash read lock twice: in fill_variables() and then in intern_sys_var_ptr(). According to pthread_rwlock_rdlock() manual it seems to be acceptable: "A thread may hold multiple concurrent read locks on rwlock (that is, successfully call the pthread_rwlock_rdlock() function n times)." The same functions also have mixed lock order: The above should also be acceptable because we don't acquire any locks while we're under wrlock(&LOCK_system_variables_hash). Will keep this code intact. | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-03-14 ] | ||||||||||||
|
Pushed one minor revision to 5.5.37: Pre-MDL versions had direct relationship between LOCK_open and With MDL this relationship was removed, but mutex order was still Removed LOCK_open and LOCK_global_system_variables order recording, This solves only one of many problems detected with | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-04-25 ] | ||||||||||||
|
There is read-lock in reverse order in Aria:
Which may conflict with write-lock e.g. in maria_write():
But since repair code is executed with protection of exclusive lock (TL_WRITE) deadlock doesn't seem to be possible. | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-09-16 ] | ||||||||||||
|
In 5.5 there is possible deadlock between 3 mutexes and 2 rwlocks:
But threads are serialized by table-level locks. E.g. GRANT/etc acquires write-lock and FLUSH PRIVILEGES acquires read-lock. No actual deadlock possible. In 10.0 things are even better: there is no LOCK_open -> LOCK_grant order. | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-10-02 ] | ||||||||||||
|
All issues found in 5.5 are reported/fixed. No extra problems were detected in 10.0 and 10.1. |