[MDEV-25051] Race condition between persistent statistics and RENAME TABLE or TRUNCATE Created: 2021-03-04 Updated: 2021-03-04 Resolved: 2021-03-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6 |
| Fix Version/s: | 10.2.38, 10.3.29, 10.4.19, 10.5.10 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | ASAN, race, rr-profile-analyzed, upstream | ||
| Issue Links: |
|
||||||||
| Description |
|
We observed the following:
At the same time, TRUNCATE TABLE was executing on the table. The reason for this heap-use-after-free is that the original table had been renamed to a temporary name, and that realloc() had freed the originally allocated memory:
The TRUNCATE TABLE itself was still waiting to drop the original table:
Because the persistent statistics code is not properly protected by MDL, the work-around dict_stats_wait_bg_to_stop_using_table() must be invoked in all code that is about to modify or free a table definition. Other DDL operations (including ALTER TABLE...DISCARD TABLESPACE) seem to do the right thing, but RENAME TABLE as well as the It seems that table eviction from the dictionary cache is protected by the table reference count. |