From 7fa12b1e34d3d561baed9e7f2aacb0d6a3eb7062 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 12 Apr 2021 21:18:14 +0530 Subject: [PATCH] MDEV-23026 purge fails with assert !rw_lock_own_flagged(lock, RW_LOCK_FLAG_X | RW_LOCK_FLAG_S) InnoDB purge thread locks the root page of clustered index while accessing the undo log records and later same thread tries to open the table, initialize statistics and tries to lock the clustered index root page while doing virtual column computation. Solution: ========= InnoDB should prevent statistics initialization when the table is being opened by purge thread --- storage/innobase/handler/ha_innodb.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index fc876e6f753c5..b837aec396baf 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -6261,8 +6261,10 @@ ha_innobase::open(const char* name, int, uint) innobase_copy_frm_flags_from_table_share(ib_table, table->s); - /* No point to init any statistics if tablespace is still encrypted. */ - if (ib_table->is_readable()) { + /* No point to init any statistics if tablespace is still encrypted + or if table is being opened by background thread */ + if (THDVAR(thd, background_thread)) { + } else if (ib_table->is_readable()) { dict_stats_init(ib_table); } else { ib_table->stat_initialized = 1;