MDEV-26755 innodb.undo_truncate: ilink::assert_linked(): Assertion `prev != 0 && next != 0' failed

close_connections() in mysqld.cc sends a signal to all threads.
But InnoDB is too busy purging, doesn't react immediately.
close_connections() waits 20 seconds, which isn't enough in this
particular case, and then unlinks all threads from
the list and forcibly closes their vio connection.

InnoDB background  threads have no vio connection to close, but
they're unlinked all the same. So when later they finally notice
the shutdown request and try to unlink themselves, they fail to
assert that they're still linked.

Fix: don't assert_linked, as another thread can unlink this THD anytime
This commit is contained in:
Sergei Golubchik 2021-11-03 15:34:28 +01:00
parent 4ba7478553
commit a96b428269

View file

@ -4557,12 +4557,10 @@ inline void add_to_active_threads(THD *thd)
/*
This should be called when you want to delete a thd that was not
running any queries.
This function will assert that the THD is linked.
*/
inline void unlink_not_visible_thd(THD *thd)
{
thd->assert_linked();
mysql_mutex_lock(&LOCK_thread_count);
thd->unlink();
mysql_mutex_unlock(&LOCK_thread_count);