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

Fix check-then-act races in PFS

    XMLWordPrintable

Details

    Description

      Performance schema suffers from check-then act anti-pattern
      For example init_setup_actor_hash:

        if ((! setup_actor_hash_inited) && (param->m_setup_actor_sizing != 0))
        {
          lf_hash_init(&setup_actor_hash, sizeof(PFS_setup_actor*), LF_HASH_UNIQUE,
                       0, 0, setup_actor_hash_get_key, &my_charset_bin);
          /* setup_actor_hash.size= param->m_setup_actor_sizing; */
          setup_actor_hash_inited= true;
        }
      

      The compiler or CPU can reorder setup_actor_hash_inited initialization before lf_hash_init call.
      At the same time, get_setup_actor_hash_pins

          if (! setup_actor_hash_inited)
            return NULL;
          thread->m_setup_actor_hash_pins= lf_hash_get_pins(&setup_actor_hash);
      

      can be called in parallel, resulting, in fact, in having garbage in setup_actor_hash.

      Same for the other modules. Basically, everything called in
      initialize_performance_schema is worth checking.

      Probably, PFS_buffer_scalable_container's m_initialized is not affected.

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              nikitamalyavin Nikita Malyavin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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