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

InnoDB Index Corruption (Error 180) on Virtual Columns derived from Off-Page JSON BLOBs during concurrent Purge and Update

    XMLWordPrintable

Details

    Description

      There's a recurrent index corruption on InnoDB tables containing LONGTEXT (JSON) columns and VIRTUAL generated columns indexed via a secondary index.

      The corruption manifests as Error 180 and InnoDB: tried to purge non-delete-marked record in the error log.

      Analysis: The issue appears to be a race condition between the InnoDB Purge Thread and Concurrent Updates affecting Off-Page BLOBs.

      The table contains a large JSON document stored in a LONGTEXT column (>8KB, forcing Off-Page/BLOB storage).

      Virtual Columns extract values from this JSON.

      A secondary index is defined on these Virtual Columns.

      When a workload performs concurrent updates:

      Thread A updates keys inside the JSON (changing the Virtual Column values).

      Thread B updates non-indexed parts of the JSON (changing the BLOB size/location, causing page modification/relocation).

      The Purge Thread attempts to clean up old index entries created by Thread A.

      The Purge Thread reads an inconsistent state of the Off-Page JSON BLOB while calculating the virtual value for removal, resulting in a mismatch between the calculated value and the index entry.

      Workaround: Changing the generated columns from VIRTUAL to STORED eliminates the corruption immediately. This confirms the issue is specific to the read-on-demand nature of Virtual Columns during the Purge phase interacting with Off-Page storage.

      Environment:
      MariaDB Version: 10.6.22, 10.11.13, and Enterprise 11.4.7

      Steps to reproduce:

      1. Download attached scripts
      2. chmod +x repro-corruption-json.sh
      3. Edit repro-corruption-json.sh and set connection parameters and mariadb client executable path
      4. ./repro-corruption-json.sh

      Expected output:

      root@fedora:/var/opt/data/myharem/instances/mariadb-enterprise-11.4.7-4-rhel-9-x86_64.54321# ./repro-json-corruption.sh 
      --- Setting up database and table ---
      --- Starting Stress Test ---
      Using Client: /var/opt/data/myharem/instances/mariadb-enterprise-11.4.7-4-rhel-9-x86_64.54320/bin/mariadb
      !!!!! CORRUPTION DETECTED !!!!!
      Check error logs for Error 180.
      

      In the error log this should be seen:

      2025-11-20 11:31:09 0 [ERROR] InnoDB: tried to purge non-delete-marked record in index `ix_result_complete` of table `test_corruption`.`table_json`: tuple: TUPLE (info_bits=0, 3 fields): {[7]SUCCESS(0x53554343455353),[1] (0x81),[4]    (0x00000001)}, record: COMPACT RECORD(info_bits=0, 3 fields): {[7]SUCCESS(0x53554343455353),[1] (0x81),[4]    (0x00000001)}
      2025-11-20 11:31:09 0 [ERROR] InnoDB: Flagged corruption of `ix_result_complete` in table `test_corruption`.`table_json` in purge
      2025-11-20 11:31:09 788 [ERROR] Got error 180 when reading table './test_corruption/table_json'
      

      Attachments

        Issue Links

          Activity

            People

              marko Marko Mäkelä
              claudio.nanni Claudio Nanni
              Votes:
              1 Vote for this issue
              Watchers:
              3 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.