Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL)
Description
The only purpose of ibuf_bitmap_mutex is to prevent a deadlock between two concurrent invocations of ibuf_update_free_bits_for_two_pages_low(a,b,mtr1) and ibuf_update_free_bits_for_two_pages_low(b,a,mtr2). The mutex is unnecessarily serializing the execution of the function. To avoid deadlocks, the following should suffice:
/* Avoid a deadlock by acquiring multiple bitmap page latches in |
a consistent order (smaller page identifier first). */
|
if (block1->page.id() > block2->page.id()) |
std::swap(block1, block2);
|
|
ibuf_set_free_bits_low(block1, ibuf_index_page_calc_free(block1), mtr);
|
ibuf_set_free_bits_low(block2, ibuf_index_page_calc_free(block2), mtr);
|
It occurred to me that we can compare the pointers directly. What matters is that every code path that could acquire and hold multiple change buffer bitmap page latches will acquire them in a deterministic order.
std::swap(block1, block2);
I think that most of the time we would have block1 == block2. Exclusive page latches can be acquired recursively.