Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-31256

fil_node_open_file() releases fil_system.mutex allowing other thread to open its file node

    XMLWordPrintable

Details

    Description

      There is room between mutex_exit(&fil_system.mutex) and mutex_enter(&fil_system.mutex) calls in the following function.

      static bool fil_node_open_file(fil_node_t *node)                                                                                  
      {                                                                               
        ...                                                                           
        for (ulint count= 0; fil_system.n_open >= srv_max_n_open_files; count++)      
        {                                                                             
          if (fil_space_t::try_to_close(count > 1))                                   
            count= 0;                                                                 
          else if (count >= 2)                                                        
          {                                                                           
          ...                                                                         
          }                                                                           
          else                                                                        
          {                                                                           
            mutex_exit(&fil_system.mutex);                                            
            os_thread_sleep(20000);                                                   
            /* Flush tablespaces so that we can close modified files. */              
            fil_flush_file_spaces();                                                  
            mutex_enter(&fil_system.mutex);                                           
          }                                                                           
        }                                                                             
                                                                                      
        return fil_node_open_file_low(node);                                          
      }
      

      During this room another thread can open the node, and ut_ad(!node->is_open()) assertion in fil_node_open_file_low() can fail.

      Attachments

        Issue Links

          Activity

            People

              vlad.lesin Vladislav Lesin
              vlad.lesin Vladislav Lesin
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.