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

System tablespace autoshrink fails with "User table exists in system tablespace" error due to legacy SYS_DATAFILES and SYS_TABLESPACES tables

    XMLWordPrintable

Details

    • Can result in unexpected behaviour
    • Hide
      Fixed an issue where the InnoDB system tablespace failed to shrink due to legacy internal tables. MariaDB now automatically detects and removes these orphaned entries during startup, allowing for successful defragmentation and reduction of the tablespace size.
      Show
      Fixed an issue where the InnoDB system tablespace failed to shrink due to legacy internal tables. MariaDB now automatically detects and removes these orphaned entries during startup, allowing for successful defragmentation and reduction of the tablespace size.
    • Q2/2026 Server Maintenance

    Description

      Description:

      We're using the `autoshrink` option of the `innodb_data_file_path`, but after each restart, we encounter the following message:

      User table exists in the system tablespace.Please try to move the data from system tablespace to separate tablespace before defragment the system tablespace.
      

      Root Cause Analysis:

      After detailed inspection, I found that the tables SYS_DATAFILES and SYS_TABLESPACES still exist in our system tablespace, although these tables should have been removed according to this commit: https://github.com/MariaDB/server/commit/5407117a59a87a1e0042581bc9c258cd2e743c85
      The issue originates in the code here:
      https://github.com/MariaDB/server/blob/mariadb-11.8.5/storage/innobase/include/dict0dict.h#L1508
      This statement ignores the IDs of these tables during the check. This would not be a problem if these tables were not present in the system tablespace.

      Environment:

      Our project has been using MariaDB for years and has been continuously updated through multiple versions. I attempted to locate a migration script responsible for removing these legacy tables, but either such a script does not exist, or it was missed during previous upgrades.

      Expected Behavior:

      The autoshrink operation should complete successfully without errors.

      Actual Behavior:

      The autoshrink operation fails due to the presence of legacy system tables.

      Question:

      Is there a documented migration procedure or upgrade path that should have removed these tables? If so, is it safe to manually remove them now, or should there be a fix to handle this scenario gracefully?

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              Smutný Jan
              Thirunarayanan Balathandayuthapani Thirunarayanan Balathandayuthapani
              Votes:
              1 Vote for this issue
              Watchers:
              5 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.