Skip to content

Commit

Permalink
MDEV-29612 ReadViewBase::snapshot() misses an optimization
Browse files Browse the repository at this point in the history
ReadViewBase::snapshot(): In case m_low_limit_no==m_low_limit_id
and m_ids would include everything between that and m_up_limit_id,
set all fields to m_up_limit_id and clear m_ids, to speed up
changes_visible() and append().

rw_trx_hash_t::debug_iterator(): Add an assertion.
  • Loading branch information
dr-m committed Oct 6, 2022
1 parent 3e9e377 commit 959ad2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions storage/innobase/include/trx0sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ class rw_trx_hash_t
if (element->trx)
validate_element(element->trx);
element->mutex.wr_unlock();
ut_ad(element->id < element->no);
return arg->action(element, arg->argument);
}
#endif
Expand Down
15 changes: 14 additions & 1 deletion storage/innobase/read/read0read.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,22 @@ For details see: row_vers_old_has_index_entry() and row_purge_poss_sec()
inline void ReadViewBase::snapshot(trx_t *trx)
{
trx_sys.snapshot_ids(trx, &m_ids, &m_low_limit_id, &m_low_limit_no);
if (m_ids.empty())
{
m_up_limit_id= m_low_limit_id;
return;
}

std::sort(m_ids.begin(), m_ids.end());
m_up_limit_id= m_ids.empty() ? m_low_limit_id : m_ids.front();
m_up_limit_id= m_ids.front();
ut_ad(m_up_limit_id <= m_low_limit_id);

if (m_low_limit_no == m_low_limit_id &&
m_low_limit_id == m_up_limit_id + m_ids.size())
{
m_ids.clear();
m_low_limit_id= m_low_limit_no= m_up_limit_id;
}
}


Expand Down

0 comments on commit 959ad2f

Please sign in to comment.