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

LP:677407 - Stale data in INFORMATION_SCHEMA.INNODB_LOCKS

Details

    Description

      This is MySQL Bug#48883 (http://bugs.mysql.com/bug.php?id=48883).

      The XtraDB INFORMATION_SCHEMA.INNODB_PLUGIN table is populated in a two-step
      procedure. First, a table cache is filled with the real information, under the
      kernel_mutex. This is only done if at least 100 milliseconds has passed since
      last filling the cache. Second, the MySQL table data is populated from the
      cache, which may thus be up to 100 milliseconds old.

      There is a bug in the accounting for how often to do the first step. The
      timestamp for last update is updated in step 2, not in step 1. This has two
      consequences:

      1. If the INNODB_PLUGIN table is queried very frequently repeatedly (with less
      than 100 milliseconds interval in-between), stale data can be returned
      indefinitely, as the "last updated" timestamp is reset even though step 1 is
      not run. This is the problem seen in Bug#48883, and in MariaDB Buildbot.

      2. If multiple queries against INNODB_PLUGIN start at around the same time,
      they can all cause the cache to be updated, as the "last updated" timestamp
      is not reset immediately after updating the cache. This can cause extra
      unnecessary contention on kernel_mutex.

      The failure is easy to repeat by changing the sleep in
      mysql-test/include/wait_condition.inc from 0.1 to 0.01 seconds, and running
      the innodb_information_schema.test.

      I will attach a patch that fixes it.

      Attachments

        Activity

          Re: Stale data in INFORMATION_SCHEMA.INNODB_LOCKS
          http://lists.mysql.com/commits/131567

          ratzpo Rasmus Johansson (Inactive) added a comment - Re: Stale data in INFORMATION_SCHEMA.INNODB_LOCKS http://lists.mysql.com/commits/131567

          Re: Stale data in INFORMATION_SCHEMA.INNODB_LOCKS
          Couldn't we make a similar solution without a magic "100msec" timeout?

          For example, have something similar to a refcount on the cache, which counts the number of active statements that accessed the tables. The refcount would be incremented on first use of one of the tables in a statement, and decremented at statement end. And we would only refresh the cache if the refcount was zero. Or something like that, what do you think?

          knielsen Kristian Nielsen added a comment - Re: Stale data in INFORMATION_SCHEMA.INNODB_LOCKS Couldn't we make a similar solution without a magic "100msec" timeout? For example, have something similar to a refcount on the cache, which counts the number of active statements that accessed the tables. The refcount would be incremented on first use of one of the tables in a statement, and decremented at statement end. And we would only refresh the cache if the refcount was zero. Or something like that, what do you think?

          Re: Stale data in INFORMATION_SCHEMA.INNODB_LOCKS
          Hi,

          I need to look at the API again, but I think it is very limited - MySQL just calls a "fill" function for a given I_S table. I was thinking about finding out the SQL statement string and parsing it to see if it is a JOIN but then decided this would be an infinite source of bugs and abandoned the idea

          ratzpo Rasmus Johansson (Inactive) added a comment - Re: Stale data in INFORMATION_SCHEMA.INNODB_LOCKS Hi, I need to look at the API again, but I think it is very limited - MySQL just calls a "fill" function for a given I_S table. I was thinking about finding out the SQL statement string and parsing it to see if it is a JOIN but then decided this would be an infinite source of bugs and abandoned the idea

          Launchpad bug id: 677407

          ratzpo Rasmus Johansson (Inactive) added a comment - Launchpad bug id: 677407

          fixed upstream and merged

          serg Sergei Golubchik added a comment - fixed upstream and merged

          People

            knielsen Kristian Nielsen
            knielsen Kristian Nielsen
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.