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

mariadb-backup fails on encrypted partitioned Aria tables with Error 176

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 13.0, 12.3.3
    • 10.11, 11.4, 11.8, 12.3, 13.0
    • Encryption, mariabackup
    • None

    Description

      `mariadb-backup` successfully backs up an encrypted, transactional,
      page-format Aria table when it is not partitioned. The equivalent two-partition
      table is readable by the server, but backup aborts while reading the second
      partition with Error 176.

      Steps to reproduce

      set -eu
      IMAGE='mariadb@sha256:dd9b303aed4f4890ed09f766d8ca9ddfd176c0c6f6267feff53b3192ec65a979'
      C='mdev-aria-partition-backup-repro'
      D=$(mktemp -d)
      SECRET='MDEV_SYNTHETIC_ARIA_KEY_20260908'
      cleanup() {
        docker rm -f "$C" >/dev/null 2>&1 || true
        rm -r "$D" >/dev/null 2>&1 || true
      }
      trap cleanup EXIT
       
      printf '%s\n' '1;0123456789ABCDEF0123456789ABCDEF' > "$D/keys.plain"
      printf '%s\n' "$SECRET" > "$D/filekey.txt"
      openssl enc -aes-256-cbc -md sha1 -salt \
        -pass file:"$D/filekey.txt" -in "$D/keys.plain" -out "$D/keys.enc"
      chmod 0644 "$D/keys.enc" "$D/filekey.txt"
       
      docker run --detach --name "$C" \
        --mount type=bind,src="$D/keys.enc",dst=/keys.enc,readonly \
        --mount type=bind,src="$D/filekey.txt",dst=/filekey.txt,readonly \
        --env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 \
        "$IMAGE" \
        --plugin-load-add=file_key_management.so \
        --file-key-management-filename=/keys.enc \
        --file-key-management-filekey=FILE:/filekey.txt \
        --aria-encrypt-tables=ON
       
      for i in $(seq 1 90); do
        if docker exec "$C" mariadb --protocol=socket -uroot -NBe \
             "SELECT @@port" 2>/dev/null | grep -qx 3306; then
          break
        fi
        sleep 1
      done
       
      # Unpartitioned encrypted control.
      docker exec "$C" mariadb --protocol=socket -uroot -e "
        CREATE DATABASE edbf;
        CREATE TABLE edbf.t_control(
          id INT PRIMARY KEY, pad VARCHAR(200)
        ) ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
        INSERT INTO edbf.t_control
          SELECT seq, REPEAT('x',40 + seq MOD 40) FROM seq_1_to_200;
        FLUSH TABLES edbf.t_control;
        SELECT COUNT(*) FROM edbf.t_control;
      "
      docker exec "$C" mariadb-backup --backup --user=root \
        --socket=/run/mysqld/mysqld.sock --target-dir=/tmp/backup-control
       
      # Add an equivalent two-partition encrypted table.
      docker exec "$C" mariadb --protocol=socket -uroot -e "
        CREATE TABLE edbf.t_partitioned(
          id INT PRIMARY KEY, pad VARCHAR(200)
        ) ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1
          PARTITION BY HASH(id) PARTITIONS 2;
        INSERT INTO edbf.t_partitioned
          SELECT seq, REPEAT('x',40 + seq MOD 40) FROM seq_1_to_200;
        FLUSH TABLES edbf.t_partitioned;
        SELECT COUNT(*) FROM edbf.t_partitioned;
        SELECT COUNT(*) FROM INFORMATION_SCHEMA.PARTITIONS
         WHERE TABLE_SCHEMA='edbf' AND TABLE_NAME='t_partitioned'
           AND PARTITION_NAME IS NOT NULL;
      "
       
      set +e
      docker exec "$C" mariadb-backup --backup --user=root \
        --socket=/run/mysqld/mysqld.sock --target-dir=/tmp/backup-trigger \
        >"$D/trigger.out" 2>&1
      RC=$?
      set -e
      echo "backup_rc=$RC"
      grep -Ei 'Error 176|aria_read' "$D/trigger.out"
       
      docker exec "$C" mariadb-admin --protocol=socket -uroot ping
      

      Actual result

      Both tables contain 200 readable rows and the trigger table has two
      partitions. The unpartitioned control backup exits 0 and prints
      `completed OK!`. The backup containing the partitioned table exits 1. In the
      original isolated trigger run, the relevant output was:

      aria table file ./edbf/t#P#p1.MAI is copied successfully.
      mariadb-backup: Error 176 reading index file `edbf`.`t` block 1
      error: aria_read index from ./edbf/t#P#p0.MAI failed with error 176
      

      The server remains alive after the failed backup.

      Expected result

      `mariadb-backup` should use the correct per-partition Aria encryption metadata
      and complete a backup of a readable encrypted partitioned table, just as it
      does for the equivalent unpartitioned encrypted table.

      Impact and boundary

      Backups abort when this table shape is present, preventing a complete backup.
      Because the trigger backup is incomplete, restore was not attempted and this
      report does not claim restored-data corruption or server crash. Only MariaDB
      12.3.3 was tested. This report is researcher-reproduced and not yet maintainer-confirmed.

      Attachments

        1. mdev-41057.opt
          0.3 kB
          Shipra Jain
        2. mdev-41057.test
          2 kB
          Shipra Jain

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              csfuzz csfuzz
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.