[MDEV-32899] InnoDB is holding shared dict_sys.latch while waiting for FOREIGN KEY child table lock on DDL Created: 2023-11-28 Updated: 2024-02-08 Resolved: 2024-02-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.6.5, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0, 11.1, 11.2, 11.3 |
| Fix Version/s: | 10.6.18, 10.11.8, 11.0.6, 11.1.5, 11.2.4, 11.3.3 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | foreign-keys, performance, regression | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
In order to fix the race conditions This bug can be fixed by changing lock_table_for_trx() so that whenever the caller is holding a shared dict_sys.latch, it will be released and reacquired around the call to lock_wait(). In this way, the lock object will be created or released while the table is protected by the shared dict_sys.latch. It is safe to temporarily release the dict_sys.latch, because tables on which lock objects exist cannot be evicted or dropped. In the callers, we have to take special care to ensure that dict_table_t::referenced_set is safe to traverse if dict_sys.latch was temporarily released. |
| Comments |
| Comment by Marko Mäkelä [ 2024-01-19 ] |
|
I reverted this due to the regression |
| Comment by Marko Mäkelä [ 2024-01-19 ] |
|
To avoid reintroducing a bug like |
| Comment by Marko Mäkelä [ 2024-01-19 ] |
|
A metadata lock can be acquired by invoking dict_acquire_mdl_shared<false>() in lock_table_children() while holding shared dict_sys.latch. Because that function will temporarily release dict_sys.latch while waiting for MDL, we had better rescan table->referenced_set after each call, in case a constraint or a child table had been dropped meanwhile. We will have to keep track of the tables on which dict_acquire_mdl_shared<false>() was already invoked. |
| Comment by Matthias Leich [ 2024-01-25 ] |
|
origin/10.6- |
| Comment by Matthias Leich [ 2024-02-01 ] |
|
origin/10.6- |
| Comment by Debarun Banerjee [ 2024-02-07 ] |
|
https://github.com/MariaDB/server/pull/3021 looks good to me. |