Commit 1862273c authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-30209 Race condition between fil_node_open_file() and renaming files

mtr_t::commit_file(): Protect the rename operation with fil_system.mutex
like we used to do before commit 2e43af69
in order to prevent fil_node_open_file() from running concurrently.
In other words, fil_system.mutex will protect the consistency of
fil_node_t::name and the file name in the file system.

This race condition should be very hard to trigger. We would need
a low value of innodb_open_files or table_cache limit so that
fil_space_t::try_to_close() will be invoked frequently. Simultaneously
with a RENAME operation, something (such as a write of a data page)
would have to try to open the file.
parent cf437f6b
......@@ -385,15 +385,15 @@ bool mtr_t::commit_file(fil_space_t &space, const char *name)
if (name)
{
char *new_name= mem_strdup(name);
mysql_mutex_lock(&fil_system.mutex);
success= os_file_rename(innodb_data_file_key, old_name, name);
if (success)
{
mysql_mutex_lock(&fil_system.mutex);
space.chain.start->name= mem_strdup(name);
mysql_mutex_unlock(&fil_system.mutex);
ut_free(old_name);
}
space.chain.start->name= new_name;
else
old_name= new_name;
mysql_mutex_unlock(&fil_system.mutex);
ut_free(old_name);
}
else
{
......
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