mariadb/storage
Marko Mäkelä 16d91f87ff MDEV-29930 Lock order inversion in ibuf_remove_free_page()
The function ibuf_remove_free_page() was waiting for ibuf_mutex
while holding ibuf.index->lock. This constitutes a lock order
inversion and may cause InnoDB to hang when innodb_change_buffering
is enabled and ibuf_merge_or_delete_for_page() is being executed
concurrently.

In fact, there is no need for ibuf_remove_free_page() to reacquire
ibuf_mutex if we make ibuf.seg_size and ibuf.free_list_len
protected by the ibuf.index->lock as well as the root page latch rather
than by ibuf_mutex.

ibuf.seg_size, ibuf.free_list_len: Instead of ibuf_mutex, let the
ibuf.index->lock and the root page latch protect these, like ibuf.empty.

ibuf_init_at_db_start(): Acquire the root page latch before updating
ibuf.seg_size. (The ibuf.index would be created later.)

ibuf_data_enough_free_for_insert(), ibuf_data_too_much_free():
Assert also ibuf.index->lock.have_u_or_x().

ibuf_remove_free_page(): Acquire the ibuf.index->lock and the root page
latch before accessing ibuf.free_list_len. Simplify the way how the
root page latch is released and reacquired. Acquire and release
ibuf_mutex only once.

ibuf_free_excess_pages(), ibuf_insert_low(): Acquire also ibuf.index->lock
before reading ibuf.free_list_len.

ibuf_print(): Acquire ibuf.index->lock before reading
ibuf.free_list_len and ibuf.seg_size.

Reviewed by: Vladislav Lesin
Tested by: Matthias Leich
2025-09-11 13:20:48 +03:00
..
archive Merge 10.5 into 10.6 2024-06-24 13:09:47 +03:00
blackhole MDEV-34348: my_hash_get_key fixes 2024-11-23 08:14:22 -07:00
columnstore ColumnStore 6.4.11-1 2025-07-25 12:28:30 +02:00
connect Fixed compiler warning from clang in connect/tabxcl.cpp 2025-06-02 14:02:53 +03:00
csv Fix clang-21 -Wunnecessary-virtual-specifier 2025-08-21 15:17:44 +03:00
example MDEV-36729: ha_example::show_func_example is incorrectly defined 2025-05-29 10:10:52 +10:00
federated Merge 10.5 into 10.6 2024-11-29 12:37:46 +02:00
federatedx MDEV-36341 UBSAN: FederatedX fill_server runtime error: applying non-zero offset to null pointer 2025-04-07 11:04:53 +02:00
heap Merge 10.5 into 10.6 2025-01-20 09:57:37 +02:00
innobase MDEV-29930 Lock order inversion in ibuf_remove_free_page() 2025-09-11 13:20:48 +03:00
maria MDEV-34914 maria.bulk_insert_crash fails on s390x (10.6+, Debug) 2025-09-04 17:15:50 +03:00
mroonga MDEV-34388: Stack overflow on Alpine Linux (postfix) mroonga+asan 2025-05-28 17:07:53 +10:00
myisam MDEV-37505 myisamchk -V crashes 2025-09-04 17:20:02 +02:00
myisammrg Remove dates from all rdiff files 2025-01-05 16:40:11 +02:00
oqgraph Merge 10.5 into 10.6 2024-11-29 12:37:46 +02:00
perfschema Fix clang-21 -Wuninitialized-const-pointer 2025-08-21 14:38:48 +03:00
rocksdb MDEV-34388: Stack overflow on Alpine Linux 2025-05-20 17:27:05 +03:00
sequence MDEV-33746 Supply missing override markings 2024-06-20 11:32:13 -04:00
sphinx Merge 10.5 into 10.6 2024-11-29 12:37:46 +02:00
spider MDEV-36723 Fix an MSAN caused by memcmp going over a string boundary 2025-09-05 11:03:49 +10:00
test_sql_discovery Merge 10.5 into 10.6 2024-06-24 13:09:47 +03:00