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

InnoDB persistent stats analyze forces full scan forcing lock crash

    XMLWordPrintable

Details

    Description

      MDEV-23991 reduced ANALYZE TABLE/background analyze lock scope. In doing so btr_get_size(index, BTR_N_LEAF_PAGES, &mtr) was stored temporarily into result.n_leaf_pages instead of index->stat_n_leaf_pages to avoid needing lock.

      But the following compare is still using index->stat_n_leaf_pages to determine whether a full table scan is necessary. This variable is neither protected by a lock, nor calculated correctly, reading as 1 no matter how many leaf pages the index has.

      This causes an unnecessary full scan of the table, locking the index for write access. At least when a replication thread attempts to write into a larger table, 600 second semaphore wait triggers server crash for coredump. Because the table analysis does not complete, automated table analysis will be re-triggered after crash recovery, causing an endless crash loop.

      The fix appears to be using result.n_leaf_pages instead of index->stat_n_leaf_pages in the comparison for whether sampling whole table has been requested, as it is local to the running thread and holds the value used previous to the patch.

      if (root_level == 0

      N_SAMPLE_PAGES(index) * n_uniq > result.n_leaf_pages) {

      Attachments

        Issue Links

          Activity

            People

              kevg Eugene Kosov (Inactive)
              jsantala Jukka Santala
              Votes:
              0 Vote for this issue
              Watchers:
              7 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.