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

Stale data remains in userstat upon renaming table

    XMLWordPrintable

Details

    Description

      When a table is renamed, the previously collected statistics remain in userstat under the old table name.
      If later a new table with the same name is created, the statistics are still not reset, but continue being updated as if it is still the same table.
      The test case shows the effect for table_statistics, at least to some extent the same applies to index_statistics.

      set @userstat.save= @@userstat;
      set global userstat= 1;
       
      create table t (a int);
      insert into t values (1),(2);
      select * from t;
      select table_name, rows_read from information_schema.table_statistics;
       
      rename table t to t2;
      create table t (b varchar(8));
      select table_name, rows_read from information_schema.table_statistics;
      insert into t values ('foo'),('bar'),('baz');
      select * from t;
      select table_name, rows_read from information_schema.table_statistics;
       
      # Cleanup
      drop table t, t2;
      set global userstat= @userstat.save;
      

      10.4 23101304887e9e1987c45f001377382e3fdfd88f

      select table_name, rows_read from information_schema.table_statistics;
      table_name	rows_read
      t	2
      rename table t to t2;
      create table t (b varchar(8));
      select table_name, rows_read from information_schema.table_statistics;
      table_name	rows_read
      t	2
      insert into t values ('foo'),('bar'),('baz');
      select * from t;
      b
      foo
      bar
      baz
      select table_name, rows_read from information_schema.table_statistics;
      table_name	rows_read
      t	5
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.