Commit c26eae0c authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-23456 fixup: Fix mtr_t::get_fix_count()

Before commit 05fa4558 (MDEV-22110)
we have slot->type == MTR_MEMO_MODIFY that are unrelated to
incrementing the buffer-fix count.

FindBlock::operator(): In debug builds, skip MTR_MEMO_MODIFY entries.

Also, simplify the code a little.

This fixes an infinite loop in the tests
innodb.innodb_defragment and innodb.innodb_wl6326_big.
parent b1009ae5
...@@ -313,25 +313,17 @@ mini-transaction */ ...@@ -313,25 +313,17 @@ mini-transaction */
struct FindBlock struct FindBlock
{ {
int32_t num_fix; int32_t num_fix;
buf_block_t *block; const buf_block_t *const block;
FindBlock(const buf_block_t *block_buf): num_fix(0), block(block_buf) {}
FindBlock(buf_block_t *block_buf): num_fix(0), block(block_buf) {}
bool operator()(const mtr_memo_slot_t* slot) bool operator()(const mtr_memo_slot_t* slot)
{ {
if (slot->object != NULL) if (slot->object == block)
{ ut_d(if (slot->type != MTR_MEMO_MODIFY))
buf_block_t *mtr_block= reinterpret_cast<buf_block_t*>(slot->object); num_fix++;
if (mtr_block == block)
num_fix++;
}
return true; return true;
} }
int32_t get_num_fix()
{
return num_fix;
}
}; };
/** Release a resource acquired by the mini-transaction. */ /** Release a resource acquired by the mini-transaction. */
...@@ -832,10 +824,9 @@ mtr_t::release_free_extents(ulint n_reserved) ...@@ -832,10 +824,9 @@ mtr_t::release_free_extents(ulint n_reserved)
int32_t mtr_t::get_fix_count(buf_block_t *block) int32_t mtr_t::get_fix_count(buf_block_t *block)
{ {
struct FindBlock find_block(block); Iterate<FindBlock> iteration((FindBlock(block)));
Iterate<FindBlock> iteration(find_block);
if (m_memo.for_each_block(iteration)) if (m_memo.for_each_block(iteration))
return iteration.functor.get_num_fix(); return iteration.functor.num_fix;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment