0

This is a question about code internal to the InnoDB storage engine in MySQL 8.0 source.

In the 'ReadView::prepare' method (file read/read0read.c):

m_up_limit_id = !m_ids.empty() ? m_ids.front() : m_low_limit_id;

in the 'changes_visible' method (file include/read0types.h):

if (id < m_up_limit_id || id == m_creator_trx_id) {
  return (true);
}
...
if (id >= m_low_limit_id) {
 return (false);
} else if (m_ids.empty()) {
  return (true);
}

The logic of m_ids.empty() is useless, id cannot be less than m_up_limit_id and greater than or equal to m_low_limit_id, because m_ids.empty(), then m_up_limit_id == m_low_limit_id, I don't know if my understanding is accurate, I hope to get an answer

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
JACK
  • 3
  • 1
  • Can you give a github link to these lines so it's clear which file and lines you are looking at? – Bill Karwin Apr 09 '22 at 17:33
  • changes_visible : https://github.com/mysql/mysql-server/blob/8.0/storage/innobase/include/read0types.h#L162 – JACK Apr 10 '22 at 10:44
  • 'ReadView::prepare : https://github.com/mysql/mysql-server/blob/8.0/storage/innobase/read/read0read.cc#L464 – JACK Apr 10 '22 at 10:45

1 Answers1

0

I think the call to empty() is important. The set of active transactions might be empty. In other words, the ReadView is prepared at a time when there are no active transactions.

If that is the case, the front() function cannot return a valid transaction id. The code in front() throws a debug assertion if it is called on an empty set.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • I don't understand why you think this is a problem. – Bill Karwin Apr 11 '22 at 02:53
  • but,In the 'ReadView::prepare' method (file read/read0read.c): ``` m_up_limit_id = !m_ids.empty() ? m_ids.front() : m_low_limit_id; ``` If m_ids.empty(), then m_up_limit_id == m_low_limit_id, so 'else if (m_ids.empty())' is not called – JACK Apr 11 '22 at 02:55
  • Are you seeing any problem in the behavior of MySQL because of this code? Or does it only seem redundant? – Bill Karwin Apr 11 '22 at 02:57