Skip to content

statistics: skip stale stats metadata during initialization #69115

Closed

Description

@winoros

Enhancement

Statistics initialization should skip stale records in mysql.stats_meta when the corresponding physical table no longer exists in the current InfoSchema.

When a table is dropped, its statistics metadata can remain until stats GC removes it. During stats initialization, TiDB currently rebuilds the in-memory stats cache from mysql.stats_meta. If a stale physical table ID is loaded into the cache, later stats operations can observe statistics for an object that is no longer present in the schema.

The initialization path should validate each physical table ID against the current InfoSchema before adding it to the cache:

  • keep normal table IDs that still exist;
  • keep partition physical IDs that still exist;
  • skip dropped table or partition IDs whose stats metadata has not been garbage collected yet.

This keeps the stats cache aligned with the visible schema while preserving valid partition statistics.

Activity

  1. added a commit that references this issue on Jun 23, 2026
    69b0177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions