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

Table corruption of partitioned encrypted Aria table after a sequence of valid DML

    XMLWordPrintable

    Details

      Description

      Run the test case with

      --mysqld=--file-key-management-filename=`pwd`/std_data/keys.txt --mysqld=--plugin-load-add=file_key_management
      

      Note that on some systems `pwd` may misbehave, change as needed to point at a valid key file.

      --source include/have_partition.inc
      --source include/have_sequence.inc
       
      SET @encrypt= @@aria_encrypt_tables;
      SET GLOBAL aria_encrypt_tables= ON;
       
      CREATE TABLE t01 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t02 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t03 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t04 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t05 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t06 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t07 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t08 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t09 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t10 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t11 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t12 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t13 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
       
      CREATE TABLE t (
        c01 INT DEFAULT 0,
        id BIGINT NOT NULL AUTO_INCREMENT,
        c02 CHAR(3) NOT NULL DEFAULT '',
        KEY idx1 (c01,c02),
        KEY (id)
      ) ENGINE=Aria CHARACTER SET utf8 PARTITION BY hash(id) partitions 2;
       
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_1045;
      INSERT INTO t (id) VALUES (59063);
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_37;
      INSERT INTO t (id) VALUES (3505);
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_31;
      INSERT INTO t (id) VALUES (50615);
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_27;
      ALTER TABLE t FORCE;
      INSERT INTO t () VALUES ();
      INSERT INTO t () VALUES ();
       
      INSERT INTO t13 () VALUES ();
      INSERT INTO t12 () VALUES ();
      INSERT INTO t04 () VALUES ();
      INSERT INTO t05 () VALUES ();
      INSERT INTO t11 () VALUES ();
      INSERT INTO t02 () VALUES ();
      INSERT INTO t10 () VALUES ();
      INSERT INTO t11 () VALUES ();
      INSERT INTO t01 () VALUES ();
      INSERT INTO t11 () VALUES ();
      INSERT INTO t04 () VALUES ();
      INSERT INTO t11 () VALUES ();
      INSERT INTO t08 () VALUES ();
      INSERT INTO t04 () VALUES ();
      INSERT INTO t06 () VALUES ();
      INSERT INTO t04 () VALUES ();
      INSERT INTO t02 () VALUES ();
      INSERT INTO t02 () VALUES ();
      INSERT INTO t03 () VALUES ();
      INSERT INTO t05 () VALUES ();
      INSERT INTO t11 () VALUES ();
      INSERT INTO t09 () VALUES ();
      INSERT INTO t10 () VALUES ();
      INSERT INTO t01 () VALUES ();
       
      SELECT * FROM t12;
      SELECT * FROM t11;
      SELECT * FROM t10;
      SELECT * FROM t13;
      SELECT * FROM t04;
      SELECT * FROM t;
      SELECT * FROM t08;
      SELECT * FROM t10;
      SELECT * FROM t09;
      SELECT * FROM t04;
      SELECT * FROM t08;
      SELECT * FROM t03;
      SELECT * FROM t04;
      SELECT * FROM t07;
      SELECT * FROM t13;
      SELECT * FROM t04;
      SELECT * FROM t11;
      SELECT * FROM t03;
      SELECT * FROM t01;
      SELECT * FROM t07;
      SELECT * FROM t12;
      SELECT * FROM t08;
      SELECT * FROM t01;
      SELECT * FROM t02;
      SELECT * FROM t02;
      SELECT * FROM t01;
      SELECT * FROM t13;
      SELECT * FROM t04;
      SELECT * FROM t09;
      SELECT * FROM t02;
      SELECT * FROM t11;
      SELECT * FROM t12;
      SELECT * FROM t07;
      SELECT * FROM t10;
      SELECT * FROM t03;
      SELECT * FROM t02;
      SELECT * FROM t13;
      SELECT * FROM t12;
      SELECT * FROM t13;
      SELECT * FROM t09;
      SELECT * FROM t09;
      SELECT * FROM t06;
      SELECT * FROM t06;
      SELECT * FROM t07;
      SELECT * FROM t04;
      SELECT * FROM t05;
      SELECT * FROM t11;
      SELECT * FROM t06;
      SELECT * FROM t09;
      SELECT * FROM t04;
      SELECT * FROM t03;
      SELECT * FROM t02;
      SELECT * FROM t11;
      SELECT * FROM t11;
      SELECT * FROM t;
      SELECT * FROM t08;
      SELECT * FROM t;
      SELECT * FROM t11;
      SELECT * FROM t13;
      SELECT * FROM t12;
      SELECT * FROM t10;
      SELECT * FROM t13;
      SELECT * FROM t09;
      SELECT * FROM t11;
      SELECT * FROM t07;
      SELECT * FROM t08;
      SELECT * FROM t04;
      SELECT * FROM t12;
      SELECT * FROM t04;
      SELECT * FROM t07;
      SELECT * FROM t10;
      SELECT * FROM t04;
      SELECT * FROM t03;
      SELECT * FROM t03;
      SELECT * FROM t01;
      SELECT * FROM t06;
      SELECT * FROM t05;
      SELECT * FROM t07;
      SELECT * FROM t;
      SELECT * FROM t08;
      SELECT * FROM t01;
      SELECT * FROM t13;
      SELECT * FROM t04;
      SELECT * FROM t12;
      SELECT * FROM t13;
      SELECT * FROM t12;
      SELECT * FROM t13;
      SELECT * FROM t12;
      SELECT * FROM t11;
      SELECT * FROM t03;
      SELECT * FROM t04;
      SELECT * FROM t06;
      SELECT * FROM t12;
      SELECT * FROM t12;
      SELECT * FROM t;
      SELECT * FROM t06;
      SELECT * FROM t07;
      SELECT * FROM t05;
      SELECT * FROM t02;
      SELECT * FROM t;
      SELECT * FROM t07;
       
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_79;
      INSERT INTO t (id) VALUES (22769);
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_7;
       
      FLUSH TABLES;
      CHECK TABLE t;
       
      # Cleanup
      DROP TABLE t, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13;
      SET GLOBAL aria_encrypt_tables= @encrypt;
      

      The test case above performs a chain of DML (INSERTs and SELECTs) on the table of interest t and a number of seemingly unrelated tables. There is also one table rebuild in there (ALTER .. FORCE). All tables are Aria and encrypted, table t is also partitioned.
      Then it runs FLUSH TABLES. At this point table t becomes corrupt:

      10.4 99c8aed0

      FLUSH TABLES;
      CHECK TABLE t;
      Table	Op	Msg_type	Msg_text
      test.t	check	error	Wrong base information on indexpage at page: 1
      test.t	check	error	Partition p1 returned error
      test.t	check	error	Corrupt
      

      Note that the test case does not fail, because CHECK only prints corruption, it doesn't fail upon it.

      If instead of CHECK TABLE we run some more DML, it ends with a debug assertion failure:

      Additional test case for assertion failure

      --source include/have_partition.inc
      --source include/have_sequence.inc
       
      SET @encrypt= @@aria_encrypt_tables;
      SET GLOBAL aria_encrypt_tables= ON;
       
      CREATE TABLE t01 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t02 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t03 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t04 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t05 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t06 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t07 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t08 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t09 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t10 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t11 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t12 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
      CREATE TABLE t13 (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)) ENGINE=Aria CHARACTER SET utf8;
       
      CREATE TABLE t (
        c01 INT DEFAULT 0,
        id BIGINT NOT NULL AUTO_INCREMENT,
        c02 CHAR(3) NOT NULL DEFAULT '',
        KEY idx1 (c01,c02),
        KEY (id)
      ) ENGINE=Aria CHARACTER SET utf8 PARTITION BY hash(id) partitions 2;
       
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_1045;
      INSERT INTO t (id) VALUES (59063);
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_37;
      INSERT INTO t (id) VALUES (3505);
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_31;
      INSERT INTO t (id) VALUES (50615);
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_27;
      ALTER TABLE t FORCE;
      INSERT INTO t () VALUES ();
      INSERT INTO t () VALUES ();
       
      INSERT INTO t13 () VALUES ();
      INSERT INTO t12 () VALUES ();
      INSERT INTO t04 () VALUES ();
      INSERT INTO t05 () VALUES ();
      INSERT INTO t11 () VALUES ();
      INSERT INTO t02 () VALUES ();
      INSERT INTO t10 () VALUES ();
      INSERT INTO t11 () VALUES ();
      INSERT INTO t01 () VALUES ();
      INSERT INTO t11 () VALUES ();
      INSERT INTO t04 () VALUES ();
      INSERT INTO t11 () VALUES ();
      INSERT INTO t08 () VALUES ();
      INSERT INTO t04 () VALUES ();
      INSERT INTO t06 () VALUES ();
      INSERT INTO t04 () VALUES ();
      INSERT INTO t02 () VALUES ();
      INSERT INTO t02 () VALUES ();
      INSERT INTO t03 () VALUES ();
      INSERT INTO t05 () VALUES ();
      INSERT INTO t11 () VALUES ();
      INSERT INTO t09 () VALUES ();
      INSERT INTO t10 () VALUES ();
      INSERT INTO t01 () VALUES ();
       
      SELECT * FROM t12;
      SELECT * FROM t11;
      SELECT * FROM t10;
      SELECT * FROM t13;
      SELECT * FROM t04;
      SELECT * FROM t;
      SELECT * FROM t08;
      SELECT * FROM t10;
      SELECT * FROM t09;
      SELECT * FROM t04;
      SELECT * FROM t08;
      SELECT * FROM t03;
      SELECT * FROM t04;
      SELECT * FROM t07;
      SELECT * FROM t13;
      SELECT * FROM t04;
      SELECT * FROM t11;
      SELECT * FROM t03;
      SELECT * FROM t01;
      SELECT * FROM t07;
      SELECT * FROM t12;
      SELECT * FROM t08;
      SELECT * FROM t01;
      SELECT * FROM t02;
      SELECT * FROM t02;
      SELECT * FROM t01;
      SELECT * FROM t13;
      SELECT * FROM t04;
      SELECT * FROM t09;
      SELECT * FROM t02;
      SELECT * FROM t11;
      SELECT * FROM t12;
      SELECT * FROM t07;
      SELECT * FROM t10;
      SELECT * FROM t03;
      SELECT * FROM t02;
      SELECT * FROM t13;
      SELECT * FROM t12;
      SELECT * FROM t13;
      SELECT * FROM t09;
      SELECT * FROM t09;
      SELECT * FROM t06;
      SELECT * FROM t06;
      SELECT * FROM t07;
      SELECT * FROM t04;
      SELECT * FROM t05;
      SELECT * FROM t11;
      SELECT * FROM t06;
      SELECT * FROM t09;
      SELECT * FROM t04;
      SELECT * FROM t03;
      SELECT * FROM t02;
      SELECT * FROM t11;
      SELECT * FROM t11;
      SELECT * FROM t;
      SELECT * FROM t08;
      SELECT * FROM t;
      SELECT * FROM t11;
      SELECT * FROM t13;
      SELECT * FROM t12;
      SELECT * FROM t10;
      SELECT * FROM t13;
      SELECT * FROM t09;
      SELECT * FROM t11;
      SELECT * FROM t07;
      SELECT * FROM t08;
      SELECT * FROM t04;
      SELECT * FROM t12;
      SELECT * FROM t04;
      SELECT * FROM t07;
      SELECT * FROM t10;
      SELECT * FROM t04;
      SELECT * FROM t03;
      SELECT * FROM t03;
      SELECT * FROM t01;
      SELECT * FROM t06;
      SELECT * FROM t05;
      SELECT * FROM t07;
      SELECT * FROM t;
      SELECT * FROM t08;
      SELECT * FROM t01;
      SELECT * FROM t13;
      SELECT * FROM t04;
      SELECT * FROM t12;
      SELECT * FROM t13;
      SELECT * FROM t12;
      SELECT * FROM t13;
      SELECT * FROM t12;
      SELECT * FROM t11;
      SELECT * FROM t03;
      SELECT * FROM t04;
      SELECT * FROM t06;
      SELECT * FROM t12;
      SELECT * FROM t12;
      SELECT * FROM t;
      SELECT * FROM t06;
      SELECT * FROM t07;
      SELECT * FROM t05;
      SELECT * FROM t02;
      SELECT * FROM t;
      SELECT * FROM t07;
       
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_79;
      INSERT INTO t (id) VALUES (22769);
      INSERT INTO t (id) SELECT NULL FROM seq_1_to_7;
       
      FLUSH TABLES;
       
      --error 0,ER_NOT_KEYFILE
      INSERT INTO t () VALUES ();
      --error 0,ER_NOT_KEYFILE
      INSERT INTO t () VALUES ();
      UPDATE t SET c02 = 'v' WHERE c01 = 27140;
       
      # Cleanup
      DROP TABLE t, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13;
      SET GLOBAL aria_encrypt_tables= @encrypt;
      

      10.4 99c8aed0

      mysqld: /data/src/10.4/storage/maria/ma_range.c:319: _ma_keynr: Assertion `0' failed.
      220528 21:42:33 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f59256c9662 in __GI___assert_fail (assertion=0x5627b4d8b5f2 "0", file=0x5627b4d8b508 "/data/src/10.4/storage/maria/ma_range.c", line=319, function=0x5627b4d8b608 <__PRETTY_FUNCTION__.0> "_ma_keynr") at assert.c:101
      #8  0x00005627b449645b in _ma_keynr (page=0x7f5920081110, keypos=0x7f5904085a0b "\r\n", ret_max_key=0x7f59200810cc) at /data/src/10.4/storage/maria/ma_range.c:319
      #9  0x00005627b4495fc9 in _ma_search_pos (info=0x7f5904084d50, key=0x7f59200811a0, nextflag=262241, pos=16384) at /data/src/10.4/storage/maria/ma_range.c:229
      #10 0x00005627b4495d51 in _ma_record_pos (info=0x7f5904084d50, key_data=0x7f590419ee30 "", keypart_map=1, search_flag=HA_READ_KEY_EXACT) at /data/src/10.4/storage/maria/ma_range.c:186
      #11 0x00005627b4495a50 in maria_records_in_range (info=0x7f5904084d50, inx=0, min_key=0x7f59200813a0, max_key=0x7f59200813c0) at /data/src/10.4/storage/maria/ma_range.c:98
      #12 0x00005627b440877f in ha_maria::records_in_range (this=0x7f59040e1098, inx=0, min_key=0x7f59200813a0, max_key=0x7f59200813c0) at /data/src/10.4/storage/maria/ha_maria.cc:3307
      #13 0x00005627b40679ce in handler::multi_range_read_info_const (this=0x7f59040e1098, keyno=0, seq=0x7f59041604a0, seq_init_param=0x7f5904046fe0, n_ranges_arg=1, bufsz=0x7f5920081454, flags=0x7f5920081450, cost=0x7f5920081560) at /data/src/10.4/sql/multi_range_read.cc:126
      #14 0x00005627b406b662 in DsMrr_impl::dsmrr_info_const (this=0x7f59040e1560, keyno=0, seq=0x7f59041604a0, seq_init_param=0x7f5904046fe0, n_ranges=1, bufsz=0x7f5904046f9c, flags=0x7f5920081508, cost=0x7f5920081560) at /data/src/10.4/sql/multi_range_read.cc:1546
      #15 0x00005627b4409df1 in ha_maria::multi_range_read_info_const (this=0x7f59040e1098, keyno=0, seq=0x7f59041604a0, seq_init_param=0x7f5904046fe0, n_ranges=1, bufsz=0x7f5904046f9c, flags=0x7f5920081508, cost=0x7f5920081560) at /data/src/10.4/storage/maria/ha_maria.cc:3950
      #16 0x00005627b44dfd65 in ha_partition::multi_range_read_info_const (this=0x7f590415fcc8, keyno=0, seq=0x7f5920081650, seq_init_param=0x7f5920081680, n_ranges=0, bufsz=0x7f5920081c08, mrr_mode=0x7f5920081c04, cost=0x7f5920081cf0) at /data/src/10.4/sql/ha_partition.cc:6473
      #17 0x00005627b43589a8 in check_quick_select (param=0x7f5920081f60, idx=0, index_only=false, tree=0x7f59041744b0, update_tbl_stats=true, mrr_flags=0x7f5920081c04, bufsize=0x7f5920081c08, cost=0x7f5920081cf0, is_ror_scan=0x7f5920081c02) at /data/src/10.4/sql/opt_range.cc:11242
      #18 0x00005627b434ef07 in get_key_scans_params (param=0x7f5920081f60, tree=0x7f5904174420, index_read_must_be_used=false, for_range_access=true, read_time=268.5) at /data/src/10.4/sql/opt_range.cc:7450
      #19 0x00005627b43439f2 in SQL_SELECT::test_quick_select (this=0x7f5904015788, thd=0x7f5904000d90, keys_to_use=..., prev_tables=0, limit=18446744073709551615, force_quick_range=false, ordered_output=false, remove_false_parts_of_where=false, only_single_index_range_scan=false) at /data/src/10.4/sql/opt_range.cc:2929
      #20 0x00005627b3fa62d6 in SQL_SELECT::check_quick (this=0x7f5904015788, thd=0x7f5904000d90, force_quick_range=false, limit=18446744073709551615) at /data/src/10.4/sql/opt_range.h:1654
      #21 0x00005627b3f9d058 in mysql_update (thd=0x7f5904000d90, table_list=0x7f59040148a0, fields=..., values=..., conds=0x7f5904015300, order_num=0, order=0x0, limit=18446744073709551615, ignore=false, found_return=0x7f5920082e20, updated_return=0x7f5920082ee0) at /data/src/10.4/sql/sql_update.cc:578
      #22 0x00005627b3e89f65 in mysql_execute_command (thd=0x7f5904000d90) at /data/src/10.4/sql/sql_parse.cc:4434
      #23 0x00005627b3e95e5c in mysql_parse (thd=0x7f5904000d90, rawbuf=0x7f59040147a8 "UPDATE t SET c02 = 'v' WHERE c01 = 27140", length=40, parser_state=0x7f5920083550, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7995
      #24 0x00005627b3e822fc in dispatch_command (command=COM_QUERY, thd=0x7f5904000d90, packet=0x7f590400ac01 "UPDATE t SET c02 = 'v' WHERE c01 = 27140", packet_length=40, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
      #25 0x00005627b3e80baf in do_command (thd=0x7f5904000d90) at /data/src/10.4/sql/sql_parse.cc:1378
      #26 0x00005627b400fcbf in do_handle_one_connection (connect=0x5627b6f93760) at /data/src/10.4/sql/sql_connect.cc:1420
      #27 0x00005627b400f967 in handle_one_connection (arg=0x5627b6f93760) at /data/src/10.4/sql/sql_connect.cc:1316
      #28 0x00005627b452c5cb in pfs_spawn_thread (arg=0x5627b6fd9130) at /data/src/10.4/storage/perfschema/pfs.cc:1869
      #29 0x00007f5925b95ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #30 0x00007f5925792def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Reproducible on 10.4+.
      Not reproducible with the provided test cases on 10.3 (neither the corruption nor the assertion).

        Attachments

          Activity

            People

            Assignee:
            monty Michael Widenius
            Reporter:
            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.