MDEV-32269 InnoDB after ALTER TABLE…IMPORT TABLESPACE may not be crash safe

mtr_t::commit(): If IMPORT TABLESPACE is first-time-dirtying blocks,
acquire both log_sys.mutex and log_sys.flush_order_mutex to assign
a valid m_commit_lsn so that the block will be inserted into the
correct position of buf_pool.flush_list.

This fixes occasional debug assertion failures when running the
regression test suite.

Reviewed by: Vladislav Lesin
This commit is contained in:
Marko Mäkelä 2023-11-30 09:43:36 +02:00
parent 968061fd9c
commit 89a5a8d234

View file

@ -453,10 +453,16 @@ void mtr_t::commit()
{
ut_ad(m_log_mode == MTR_LOG_NO_REDO);
ut_ad(m_log.size() == 0);
m_commit_lsn= log_sys.get_lsn();
lsns= { m_commit_lsn, PAGE_FLUSH_NO };
if (UNIV_UNLIKELY(m_made_dirty)) /* This should be IMPORT TABLESPACE */
{
mysql_mutex_lock(&log_sys.mutex);
m_commit_lsn= log_sys.get_lsn();
mysql_mutex_lock(&log_sys.flush_order_mutex);
mysql_mutex_unlock(&log_sys.mutex);
}
else
m_commit_lsn= log_sys.get_lsn();
lsns= { m_commit_lsn, PAGE_FLUSH_NO };
}
if (m_freed_pages)