[MDEV-25512] Deadlock between sux_lock::u_x_upgrade() and sux_lock::u_lock() Created: 2021-04-25 Updated: 2021-04-25 Resolved: 2021-04-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.6.0 |
| Fix Version/s: | 10.6.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | hang, regression | ||
| Environment: |
Not Linux, OpenBSD or Microsoft Windows (using SUX_LOCK_GENERIC) |
||
| Issue Links: |
|
||||||||
| Description |
|
A unit test program revealed a deadlock between sux_lock::u_x_upgrade() and sux_lock::u_lock() operations. The u_x_upgrade() operation is very rarely used, and contention with u_lock() is very rare. It has only been observed when using the non-default setting innodb_adaptive_hash_index=ON. The futex-based implementation in the 10.6.0 server works correctly. Only the fallback to POSIX mutex and condition variables is affected. The following patch fixes the issue:
The cause of the problem is that this implementation cannot remember more than one pending exclusive lock request. If multiple requests have been enqueued, the WRITER_WAITING flag will be cleared when the first waiting writer acquires the exclusive lock. If the other waiting writers are not woken up, the flag would not be set. The refinement of the futex-based implementation (Linux, OpenBSD, Microsoft Windows) in |