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

            aryanarora Aryan Arora added a comment -

            Can I take this up?

            I plan to start by creating a testcase which confirms the races.
            I've figured out DEBUG_SYNC macro can be used to create the testcase, but I am unsure about how to access thread context in init_setup_actor_hash function.
            Any clue on this?

            aryanarora Aryan Arora added a comment - Can I take this up? I plan to start by creating a testcase which confirms the races. I've figured out DEBUG_SYNC macro can be used to create the testcase, but I am unsure about how to access thread context in init_setup_actor_hash function. Any clue on this?

            You can, sure.

            No, DEBUG_SYNC will hardly help. The description above says "The compiler or CPU can reorder setup_actor_hash_inited initialization before lf_hash_init call", so unless they do no amount of DEBUG_SYNC will help.

            serg Sergei Golubchik added a comment - You can, sure. No, DEBUG_SYNC will hardly help. The description above says "The compiler or CPU can reorder setup_actor_hash_inited initialization before lf_hash_init call", so unless they do no amount of DEBUG_SYNC will help.

            People

              nikitamalyavin Nikita Malyavin
              nikitamalyavin Nikita Malyavin
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.