MDEV-29518 ASAN Failure on i_s query when tablespace does rename operation

- InnoDB information schema query access the tablespace name after
getting freed by concurrent rename operation. To avoid this, InnoDB
should take exclusive tablespace latch during rename operation
and I_S query should take shared tablespace latch before accessing
the name
parent e3a5a695
...@@ -1488,6 +1488,7 @@ dict_table_t::rename_tablespace(span<const char> new_name, bool replace) const ...@@ -1488,6 +1488,7 @@ dict_table_t::rename_tablespace(span<const char> new_name, bool replace) const
err= DB_TABLESPACE_EXISTS; err= DB_TABLESPACE_EXISTS;
else else
{ {
space->x_lock();
err= space->rename(path, true, replace); err= space->rename(path, true, replace);
if (data_dir) if (data_dir)
{ {
...@@ -1495,6 +1496,7 @@ dict_table_t::rename_tablespace(span<const char> new_name, bool replace) const ...@@ -1495,6 +1496,7 @@ dict_table_t::rename_tablespace(span<const char> new_name, bool replace) const
new_name= {name.m_name, strlen(name.m_name)}; new_name= {name.m_name, strlen(name.m_name)};
RemoteDatafile::delete_link_file(new_name); RemoteDatafile::delete_link_file(new_name);
} }
space->x_unlock();
} }
ut_free(path); ut_free(path);
......
...@@ -6491,7 +6491,9 @@ static int i_s_sys_tablespaces_fill_table(THD *thd, TABLE_LIST *tables, Item*) ...@@ -6491,7 +6491,9 @@ static int i_s_sys_tablespaces_fill_table(THD *thd, TABLE_LIST *tables, Item*)
{ {
space.reacquire(); space.reacquire();
mysql_mutex_unlock(&fil_system.mutex); mysql_mutex_unlock(&fil_system.mutex);
space.s_lock();
err= i_s_sys_tablespaces_fill(thd, space, tables->table); err= i_s_sys_tablespaces_fill(thd, space, tables->table);
space.s_unlock();
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
space.release(); space.release();
if (err) if (err)
...@@ -6719,8 +6721,10 @@ i_s_tablespaces_encryption_fill_table( ...@@ -6719,8 +6721,10 @@ i_s_tablespaces_encryption_fill_table(
&& !space.is_stopping()) { && !space.is_stopping()) {
space.reacquire(); space.reacquire();
mysql_mutex_unlock(&fil_system.mutex); mysql_mutex_unlock(&fil_system.mutex);
space.s_lock();
err = i_s_dict_fill_tablespaces_encryption( err = i_s_dict_fill_tablespaces_encryption(
thd, &space, tables->table); thd, &space, tables->table);
space.s_unlock();
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
space.release(); space.release();
if (err) { if (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment