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

ALTER on Aria table with aria_encrypt_tables=ON without encryption plugin corrupts table

Details

    Description

      Test 1, without partitioning

      SET GLOBAL ARIA_ENCRYPT_TABLES= 1;
      CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=Aria;
      INSERT INTO t1 VALUES (1);
      --error 0,192
      ALTER TABLE t1 FORCE;
      CHECK TABLE t1 EXTENDED;
      INSERT INTO t1 (pk) VALUES (2);
       
      # Cleanup
      DROP TABLE t1;
      SET GLOBAL ARIA_ENCRYPT_TABLES= 0;
      

      10.2 b22285e4

      CHECK TABLE t1 EXTENDED;
      Table	Op	Msg_type	Msg_text
      test.t1	check	error	Failed to flush data or index file
      test.t1	check	error	Size of indexfile is: 8192         Expected: 16384
      test.t1	check	Error	Unknown key id 1. Can't continue!
      test.t1	check	error	Corrupt
      INSERT INTO t1 (pk) VALUES (2);
      bug.protocol1                            [ fail ]
              Test ended at 2021-01-21 19:10:42
       
      CURRENT_TEST: bug.protocol1
      mysqltest: At line 9: query 'INSERT INTO t1 (pk) VALUES (2)' failed: 192: failed to decrypt './test/t1'  rc: -1  dstlen: 0  size: 9
      

      Test 2, with partitioning

      --source include/have_partition.inc
       
      SET GLOBAL ARIA_ENCRYPT_TABLES= 1;
      CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=Aria PARTITION BY HASH(pk);
      INSERT INTO t1 VALUES (1);
      --error 0,192
      ALTER TABLE t1 FORCE;
      CHECK TABLE t1 EXTENDED;
      INSERT INTO t1 (pk) VALUES (2);
       
      # Cleanup
      DROP TABLE t1;
      SET GLOBAL ARIA_ENCRYPT_TABLES= 0;
      

      10.2 b22285e4 non-debug

      CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=Aria PARTITION BY HASH(pk);
      INSERT INTO t1 VALUES (1);
      ALTER TABLE t1 FORCE;
      CHECK TABLE t1 EXTENDED;
      Table	Op	Msg_type	Msg_text
      test.t1	check	warning	Table is marked as crashed
      test.t1	check	error	Size of indexfile is: 8192         Expected: 16384
      test.t1	check	error	Partition p0 returned error
      test.t1	check	error	Corrupt
      INSERT INTO t1 (pk) VALUES (2);
      DROP TABLE t1;
      

      10.2 b22285e4 debug

      2021-01-21 19:14:28 139971983902464 [ERROR] mysqld: Unknown key id 1. Can't continue!
      2021-01-21 19:14:28 139971983902464 [ERROR] mysqld: Unknown key id 1. Can't continue!
      2021-01-21 19:14:28 139971983902464 [ERROR] mysqld: Table './test/t1#P#p0' is marked as crashed and should be repaired
      2021-01-21 19:14:28 139971983902464 [ERROR] mysqld: Table 't1' is marked as crashed and should be repaired
      2021-01-21 19:14:28 139971983902464 [Warning] Recovering table: './test/t1'
      2021-01-21 19:14:28 139971983902464 [ERROR] mysqld: Unknown key id 1. Can't continue!
      mysqld: /data/src/10.2/sql/protocol.cc:599: void Protocol::end_statement(): Assertion `0' failed.
      210121 19:14:28 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f4dc9cb4f36 in __GI___assert_fail (assertion=0x55f17c6274f0 "0", file=0x55f17c6271c0 "/data/src/10.2/sql/protocol.cc", line=599, function=0x55f17c627410 "void Protocol::end_statement()") at assert.c:101
      #8  0x000055f17baf6b53 in Protocol::end_statement (this=0x7f4da8001348) at /data/src/10.2/sql/protocol.cc:599
      #9  0x000055f17bbd4109 in dispatch_command (command=COM_QUERY, thd=0x7f4da8000d90, packet=0x7f4da8008b51 "INSERT INTO t1 (pk) VALUES (2)", packet_length=30, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:2385
      #10 0x000055f17bbd10fd in do_command (thd=0x7f4da8000d90) at /data/src/10.2/sql/sql_parse.cc:1381
      #11 0x000055f17bd2b872 in do_handle_one_connection (connect=0x55f17eaba920) at /data/src/10.2/sql/sql_connect.cc:1336
      #12 0x000055f17bd2b5d7 in handle_one_connection (arg=0x55f17eaba920) at /data/src/10.2/sql/sql_connect.cc:1241
      #13 0x000055f17c553bc4 in pfs_spawn_thread (arg=0x55f17ea9dcb0) at /data/src/10.2/storage/perfschema/pfs.cc:1869
      #14 0x00007f4dca1c4609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #15 0x00007f4dc9da0293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Test case 3, with partitioning, different location of ARIA_ENCRYPT_TABLES

      --source include/have_partition.inc
       
      CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=Aria PARTITION BY HASH(pk);
      INSERT INTO t1 VALUES (1);
      SET GLOBAL ARIA_ENCRYPT_TABLES= 1;
      --error 0,192
      ALTER TABLE t1 FORCE;
      CHECK TABLE t1 EXTENDED;
      INSERT INTO t1 (pk) VALUES (2);
       
      # Cleanup
      DROP TABLE t1;
      SET GLOBAL ARIA_ENCRYPT_TABLES= 0;
      

      10.2 b22285e4

      2021-01-21 19:18:40 140068050495232 [ERROR] mysqld: Unknown key id 1. Can't continue!
      mysqld: /data/src/10.2/sql/sql_error.cc:380: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
      210121 19:18:40 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f64284f3f36 in __GI___assert_fail (assertion=0x564f30ef4c08 "!is_set() || (m_status == DA_OK_BULK && is_bulk_op())", file=0x564f30ef49f0 "/data/src/10.2/sql/sql_error.cc", line=380, function=0x564f30ef4bc0 "void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*)") at assert.c:101
      #8  0x0000564f3045cd9f in Diagnostics_area::set_ok_status (this=0x7f6410005f40, affected_rows=1, last_insert_id=0, message=0x7f642264b6b0 "Records: 1  Duplicates: 0  Warnings: 1") at /data/src/10.2/sql/sql_error.cc:380
      #9  0x0000564f3040e5c3 in my_ok (thd=0x7f6410000d90, affected_rows=1, id=0, message=0x7f642264b6b0 "Records: 1  Duplicates: 0  Warnings: 1") at /data/src/10.2/sql/sql_class.h:4568
      #10 0x0000564f305665c2 in mysql_alter_table (thd=0x7f6410000d90, new_db=0x7f6410012de0 "test", new_name=0x0, create_info=0x7f642264c290, table_list=0x7f64100127c8, alter_info=0x7f642264c1e0, order_num=0, order=0x0, ignore=false) at /data/src/10.2/sql/sql_table.cc:9923
      #11 0x0000564f305e3e7c in Sql_cmd_alter_table::execute (this=0x7f6410012de8, thd=0x7f6410000d90) at /data/src/10.2/sql/sql_alter.cc:333
      #12 0x0000564f30492311 in mysql_execute_command (thd=0x7f6410000d90) at /data/src/10.2/sql/sql_parse.cc:5994
      #13 0x0000564f30497329 in mysql_parse (thd=0x7f6410000d90, rawbuf=0x7f64100126f8 "ALTER TABLE t1 FORCE", length=20, parser_state=0x7f642264d5f0, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7763
      #14 0x0000564f30485602 in dispatch_command (command=COM_QUERY, thd=0x7f6410000d90, packet=0x7f6410008b51 "", packet_length=20, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1827
      #15 0x0000564f304840fd in do_command (thd=0x7f6410000d90) at /data/src/10.2/sql/sql_parse.cc:1381
      #16 0x0000564f305de872 in do_handle_one_connection (connect=0x564f3295c920) at /data/src/10.2/sql/sql_connect.cc:1336
      #17 0x0000564f305de5d7 in handle_one_connection (arg=0x564f3295c920) at /data/src/10.2/sql/sql_connect.cc:1241
      #18 0x0000564f30e06bc4 in pfs_spawn_thread (arg=0x564f3293fcb0) at /data/src/10.2/storage/perfschema/pfs.cc:1869
      #19 0x00007f6428a03609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #20 0x00007f64285df293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Attachments

        Issue Links

          Activity

            I should have probably added all this to MDEV-20436 instead of filing a new one, but didn't find MDEV-20436 in time.

            elenst Elena Stepanova added a comment - I should have probably added all this to MDEV-20436 instead of filing a new one, but didn't find MDEV-20436 in time.
            Roel Roel Van de Paar added a comment - - edited

            Also please test any fixes with

            USE test;
            CREATE TABLE t(c1 INT,KEY(c1))ENGINE=InnoDB;
            INSERT INTO t VALUES(55997),(3942);
            ALTER TABLE t ENGINE=Aria;
            SET GLOBAL aria_encrypt_tables=1;
            REPAIR TABLE t USE_FRM;
            

            10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug)

            10.7.0-dbg>REPAIR TABLE t USE_FRM;
            +--------+--------+----------+-------------------------------------+
            | Table  | Op     | Msg_type | Msg_text                            |
            +--------+--------+----------+-------------------------------------+
            | test.t | repair | info     | Wrong directory entry   0 at page 1 |
            | test.t | repair | warning  | Number of rows changed from 0 to 1  |
            | test.t | repair | Error    | Unknown key id 1. Can't continue!   |
            | test.t | repair | status   | OK                                  |
            +--------+--------+----------+-------------------------------------+
            4 rows in set (0.018 sec)
            

            And

            USE test;
            SET GLOBAL aria_encrypt_tables=1;
            CREATE TABLE t1(id int,key GEN_CLUST_INDEX(id))engine=Aria;
            INSERT INTO t1 SELECT timediff(timestamp'2008-12-31 23:59:59.000001',timestamp'2008-12-30 01:01:01.000002');
            

            10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug)

            10.7.0-dbg>INSERT INTO t1 SELECT timediff(timestamp'2008-12-31 23:59:59.000001',timestamp'2008-12-30 01:01:01.000002');
            ERROR 192 (HY000): Unknown key id 1. Can't continue!
            

            And

            USE test;
            SET GLOBAL aria_encrypt_tables=ON;
            CREATE TABLE t1(id int AUTO_INCREMENT PRIMARY KEY, stat_id int NOT NULL, acct_id int DEFAULT NULL, INDEX idx1 (stat_id, acct_id), INDEX idx2 (acct_id)) ENGINE=Aria;
            INSERT INTO t1 VALUES (1, 1, 1);
            REPAIR TABLE t1; 
            

            10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug)

            10.7.0-dbg>REPAIR TABLE t1; 
            +---------+--------+----------+------------------------------------------------------------+
            | Table   | Op     | Msg_type | Msg_text                                                   |
            +---------+--------+----------+------------------------------------------------------------+
            | test.t1 | repair | error    | 126 when reading last record                               |
            | test.t1 | repair | Error    | Unknown key id 1. Can't continue!                          |
            | test.t1 | repair | Error    | Unknown key id 1. Can't continue!                          |
            | test.t1 | repair | Error    | Unknown key id 1. Can't continue!                          |
            | test.t1 | repair | Error    | failed to decrypt './test/t1'  rc: -1  dstlen: 0  size: 9 |
            | test.t1 | repair | status   | OK                                                         |
            +---------+--------+----------+------------------------------------------------------------+
            6 rows in set (0.013 sec)
            

            And

            USE test;
            SET GLOBAL table_open_cache=FALSE;
            SET default_storage_engine=Aria;
            SET GLOBAL aria_encrypt_tables=ON;
            CREATE TABLE t(GRADE DECIMAL PRIMARY KEY);
            INSERT INTO t VALUES(0);
            CREATE TEMPORARY TABLE t SELECT 1 f1;
            CREATE USER a@localhost IDENTIFIED WITH '';
            DROP TABLE t,t2;
            ANALYZE NO_WRITE_TO_BINLOG TABLE t;
            

            10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug)

            10.6.4-dbg>DROP TABLE t,t2;
            ERROR 192 (HY000): Unknown key id 1. Can't continue!
            10.6.4-dbg>ANALYZE NO_WRITE_TO_BINLOG TABLE t;
            +--------+---------+----------+------------------------------------------------+
            | Table  | Op      | Msg_type | Msg_text                                       |
            +--------+---------+----------+------------------------------------------------+
            | test.t | analyze | error    | Wrong base information on indexpage at page: 1 |
            | test.t | analyze | error    | Corrupt                                        |
            +--------+---------+----------+------------------------------------------------+
            2 rows in set (0.004 sec)
            

            And

            SET SQL_MODE='';
            SET global aria_encrypt_tables=1;
            CREATE TABLE ti (a INT) ENGINE=InnoDB;
            CREATE TEMPORARY TABLE t1(a INT PRIMARY KEY, b INT, KEY(b)) ENGINE=Aria;
            INSERT INTO t1 VALUES(0,0);
            DELETE FROM t1 WHERE a BETWEEN 0 AND 20 OR b BETWEEN 10 AND 20;
            INSERT INTO t1 SELECT a, b+8192    FROM t1;
            INSERT INTO ti VALUES(1);
            INSERT INTO t1 VALUES(2,2);
            

            10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug)

            10.7.0-dbg>INSERT INTO t1 SELECT a, b+8192    FROM t1;
            ERROR 192 (HY000): Unknown key id 1. Can't continue!
            10.7.0-dbg>INSERT INTO ti VALUES(1);
            Query OK, 1 row affected (0.004 sec)
             
            10.7.0-dbg>INSERT INTO t1 VALUES(2,2);
            ERROR 1030 (HY000): Got error 175 "File too short; Expected more data in file" from storage engine Aria
            

            And

            # mysqld options required for replay: --log-bin
            SET SQL_MODE='',tmp_table_size = 65535;
            CREATE TABLE t1(c INT) ENGINE=InnoDB;
            CREATE TABLE t2(c INT) ENGINE=MyISAM;
            XA BEGIN 'a';
            SET GLOBAL aria_encrypt_tables=1;
            INSERT INTO t1 SELECT * FROM t1;
            CREATE TEMPORARY TABLE t1(a INT PRIMARY KEY) ENGINE=Aria;
            INSERT INTO t1 VALUES (1);
            LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
            SELECT * FROM INFORMATION_SCHEMA.user_privileges LIMIT 1;
            INSERT INTO t1 VALUES (1);
            

            10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug)

            10.7.0-dbg>LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
            +---------+--------------+----------+--------------------------------------------+
            | Table   | Op           | Msg_type | Msg_text                                   |
            +---------+--------------+----------+--------------------------------------------+
            | test.t1 | preload_keys | error    | Failed to read from index file (errno: 11) |
            | test.t1 | preload_keys | Error    | Unknown key id 1. Can't continue!          |
            | test.t1 | preload_keys | status   | Operation failed                           |
            +---------+--------------+----------+--------------------------------------------+
            3 rows in set (0.001 sec)
             
            10.7.0-dbg>SELECT * FROM INFORMATION_SCHEMA.user_privileges LIMIT 1;
            +----------------+---------------+----------------+--------------+
            | GRANTEE        | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
            +----------------+---------------+----------------+--------------+
            | ''@'qa-roel-2' | def           | USAGE          | NO           |
            +----------------+---------------+----------------+--------------+
            1 row in set (0.007 sec)
             
            10.7.0-dbg>INSERT INTO t1 VALUES (1);
            ERROR 1034 (HY000): Index for table 't1' is corrupt; try to repair it
            

            The last testcase above slightly modified can also introduce a crash/assert, ref the second comment in MDEV-26258

            Roel Roel Van de Paar added a comment - - edited Also please test any fixes with USE test; CREATE TABLE t(c1 INT,KEY(c1))ENGINE=InnoDB; INSERT INTO t VALUES(55997),(3942); ALTER TABLE t ENGINE=Aria; SET GLOBAL aria_encrypt_tables=1; REPAIR TABLE t USE_FRM; 10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug) 10.7.0-dbg>REPAIR TABLE t USE_FRM; +--------+--------+----------+-------------------------------------+ | Table | Op | Msg_type | Msg_text | +--------+--------+----------+-------------------------------------+ | test.t | repair | info | Wrong directory entry 0 at page 1 | | test.t | repair | warning | Number of rows changed from 0 to 1 | | test.t | repair | Error | Unknown key id 1. Can't continue! | | test.t | repair | status | OK | +--------+--------+----------+-------------------------------------+ 4 rows in set (0.018 sec) And USE test; SET GLOBAL aria_encrypt_tables=1; CREATE TABLE t1(id int,key GEN_CLUST_INDEX(id))engine=Aria; INSERT INTO t1 SELECT timediff(timestamp'2008-12-31 23:59:59.000001',timestamp'2008-12-30 01:01:01.000002'); 10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug) 10.7.0-dbg>INSERT INTO t1 SELECT timediff(timestamp'2008-12-31 23:59:59.000001',timestamp'2008-12-30 01:01:01.000002'); ERROR 192 (HY000): Unknown key id 1. Can't continue! And USE test; SET GLOBAL aria_encrypt_tables=ON; CREATE TABLE t1(id int AUTO_INCREMENT PRIMARY KEY, stat_id int NOT NULL, acct_id int DEFAULT NULL, INDEX idx1 (stat_id, acct_id), INDEX idx2 (acct_id)) ENGINE=Aria; INSERT INTO t1 VALUES (1, 1, 1); REPAIR TABLE t1; 10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug) 10.7.0-dbg>REPAIR TABLE t1; +---------+--------+----------+------------------------------------------------------------+ | Table | Op | Msg_type | Msg_text | +---------+--------+----------+------------------------------------------------------------+ | test.t1 | repair | error | 126 when reading last record | | test.t1 | repair | Error | Unknown key id 1. Can't continue! | | test.t1 | repair | Error | Unknown key id 1. Can't continue! | | test.t1 | repair | Error | Unknown key id 1. Can't continue! | | test.t1 | repair | Error | failed to decrypt './test/t1' rc: -1 dstlen: 0 size: 9 | | test.t1 | repair | status | OK | +---------+--------+----------+------------------------------------------------------------+ 6 rows in set (0.013 sec) And USE test; SET GLOBAL table_open_cache=FALSE; SET default_storage_engine=Aria; SET GLOBAL aria_encrypt_tables=ON; CREATE TABLE t(GRADE DECIMAL PRIMARY KEY); INSERT INTO t VALUES(0); CREATE TEMPORARY TABLE t SELECT 1 f1; CREATE USER a@localhost IDENTIFIED WITH ''; DROP TABLE t,t2; ANALYZE NO_WRITE_TO_BINLOG TABLE t; 10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug) 10.6.4-dbg>DROP TABLE t,t2; ERROR 192 (HY000): Unknown key id 1. Can't continue! 10.6.4-dbg>ANALYZE NO_WRITE_TO_BINLOG TABLE t; +--------+---------+----------+------------------------------------------------+ | Table | Op | Msg_type | Msg_text | +--------+---------+----------+------------------------------------------------+ | test.t | analyze | error | Wrong base information on indexpage at page: 1 | | test.t | analyze | error | Corrupt | +--------+---------+----------+------------------------------------------------+ 2 rows in set (0.004 sec) And SET SQL_MODE=''; SET global aria_encrypt_tables=1; CREATE TABLE ti (a INT) ENGINE=InnoDB; CREATE TEMPORARY TABLE t1(a INT PRIMARY KEY, b INT, KEY(b)) ENGINE=Aria; INSERT INTO t1 VALUES(0,0); DELETE FROM t1 WHERE a BETWEEN 0 AND 20 OR b BETWEEN 10 AND 20; INSERT INTO t1 SELECT a, b+8192 FROM t1; INSERT INTO ti VALUES(1); INSERT INTO t1 VALUES(2,2); 10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug) 10.7.0-dbg>INSERT INTO t1 SELECT a, b+8192 FROM t1; ERROR 192 (HY000): Unknown key id 1. Can't continue! 10.7.0-dbg>INSERT INTO ti VALUES(1); Query OK, 1 row affected (0.004 sec)   10.7.0-dbg>INSERT INTO t1 VALUES(2,2); ERROR 1030 (HY000): Got error 175 "File too short; Expected more data in file" from storage engine Aria And # mysqld options required for replay: --log-bin SET SQL_MODE='',tmp_table_size = 65535; CREATE TABLE t1(c INT) ENGINE=InnoDB; CREATE TABLE t2(c INT) ENGINE=MyISAM; XA BEGIN 'a'; SET GLOBAL aria_encrypt_tables=1; INSERT INTO t1 SELECT * FROM t1; CREATE TEMPORARY TABLE t1(a INT PRIMARY KEY) ENGINE=Aria; INSERT INTO t1 VALUES (1); LOAD INDEX INTO CACHE t1 IGNORE LEAVES; SELECT * FROM INFORMATION_SCHEMA.user_privileges LIMIT 1; INSERT INTO t1 VALUES (1); 10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug) 10.7.0-dbg>LOAD INDEX INTO CACHE t1 IGNORE LEAVES; +---------+--------------+----------+--------------------------------------------+ | Table | Op | Msg_type | Msg_text | +---------+--------------+----------+--------------------------------------------+ | test.t1 | preload_keys | error | Failed to read from index file (errno: 11) | | test.t1 | preload_keys | Error | Unknown key id 1. Can't continue! | | test.t1 | preload_keys | status | Operation failed | +---------+--------------+----------+--------------------------------------------+ 3 rows in set (0.001 sec)   10.7.0-dbg>SELECT * FROM INFORMATION_SCHEMA.user_privileges LIMIT 1; +----------------+---------------+----------------+--------------+ | GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE | +----------------+---------------+----------------+--------------+ | ''@'qa-roel-2' | def | USAGE | NO | +----------------+---------------+----------------+--------------+ 1 row in set (0.007 sec)   10.7.0-dbg>INSERT INTO t1 VALUES (1); ERROR 1034 (HY000): Index for table 't1' is corrupt; try to repair it The last testcase above slightly modified can also introduce a crash/assert, ref the second comment in MDEV-26258

            I see here at least 2 bugs:
            1) problem with error reporting or malforming Diagnostic_area
            2) problem with alter table

            sanja Oleksandr Byelkin added a comment - I see here at least 2 bugs: 1) problem with error reporting or malforming Diagnostic_area 2) problem with alter table
            Roel Roel Van de Paar added a comment - - edited

            SET sql_mode='';
            SET GLOBAL aria_encrypt_tables=1;
            SET SESSION enforce_storage_engine=Aria;
            CREATE TEMPORARY TABLE t (a INT KEY,b INT,KEY(b));
            INSERT INTO t VALUES (1,REPEAT (1,6));
            INSERT INTO t VALUES (412,1);
            LOAD INDEX INTO CACHE t KEY(PRIMARY);
            SELECT a FROM t;
            

            Leads to:

            10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Optimized)

            10.8.0-opt>LOAD INDEX INTO CACHE t KEY(PRIMARY);
            +--------+--------------+----------+--------------------------------------------+
            | Table  | Op           | Msg_type | Msg_text                                   |
            +--------+--------------+----------+--------------------------------------------+
            | test.t | preload_keys | error    | Failed to read from index file (errno: 11) |
            | test.t | preload_keys | Error    | Unknown key id 1. Can't continue!          |
            | test.t | preload_keys | Error    | Unknown key id 1. Can't continue!          |
            | test.t | preload_keys | status   | Operation failed                           |
            +--------+--------------+----------+--------------------------------------------+
            4 rows in set (0.000 sec)
             
            10.8.0-opt>SELECT a FROM t;
            ERROR 1034 (HY000): Index for table 't' is corrupt; try to repair it
            

            10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Optimized)

            2021-11-13 18:39:08 0 [Note] /test/MD121121-mariadb-10.8.0-linux-x86_64-opt/bin/mysqld: ready for connections.
            Version: '10.8.0-MariaDB'  socket: '/test/MD121121-mariadb-10.8.0-linux-x86_64-opt/socket.sock'  port: 23132  MariaDB Server
            2021-11-13 18:39:15 4 [ERROR] mysqld: Unknown key id 1. Can't continue!
            2021-11-13 18:39:15 4 [ERROR] mysqld: Unknown key id 1. Can't continue!
            2021-11-13 18:39:15 4 [ERROR] Got error 126 when reading table '/test/MD121121-mariadb-10.8.0-linux-x86_64-opt/data/#sql-temptable-cb423-4-0'
            2021-11-13 18:39:15 4 [ERROR] mysqld: Index for table 't' is corrupt; try to repair it
            

            Roel Roel Van de Paar added a comment - - edited SET sql_mode= '' ; SET GLOBAL aria_encrypt_tables=1; SET SESSION enforce_storage_engine=Aria; CREATE TEMPORARY TABLE t (a INT KEY ,b INT , KEY (b)); INSERT INTO t VALUES (1,REPEAT (1,6)); INSERT INTO t VALUES (412,1); LOAD INDEX INTO CACHE t KEY ( PRIMARY ); SELECT a FROM t; Leads to: 10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Optimized) 10.8.0-opt>LOAD INDEX INTO CACHE t KEY(PRIMARY); +--------+--------------+----------+--------------------------------------------+ | Table | Op | Msg_type | Msg_text | +--------+--------------+----------+--------------------------------------------+ | test.t | preload_keys | error | Failed to read from index file (errno: 11) | | test.t | preload_keys | Error | Unknown key id 1. Can't continue! | | test.t | preload_keys | Error | Unknown key id 1. Can't continue! | | test.t | preload_keys | status | Operation failed | +--------+--------------+----------+--------------------------------------------+ 4 rows in set (0.000 sec)   10.8.0-opt>SELECT a FROM t; ERROR 1034 (HY000): Index for table 't' is corrupt; try to repair it 10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Optimized) 2021-11-13 18:39:08 0 [Note] /test/MD121121-mariadb-10.8.0-linux-x86_64-opt/bin/mysqld: ready for connections. Version: '10.8.0-MariaDB' socket: '/test/MD121121-mariadb-10.8.0-linux-x86_64-opt/socket.sock' port: 23132 MariaDB Server 2021-11-13 18:39:15 4 [ERROR] mysqld: Unknown key id 1. Can't continue! 2021-11-13 18:39:15 4 [ERROR] mysqld: Unknown key id 1. Can't continue! 2021-11-13 18:39:15 4 [ERROR] Got error 126 when reading table '/test/MD121121-mariadb-10.8.0-linux-x86_64-opt/data/#sql-temptable-cb423-4-0' 2021-11-13 18:39:15 4 [ERROR] mysqld: Index for table 't' is corrupt; try to repair it

            CREATE DATABASE d2;
            SET GLOBAL aria_encrypt_tables=1;
            SET default_storage_engine=Aria;
            SET sql_select_limit=1;
            CREATE TABLE t (c INT KEY,c2 INT,KEY(c2));
            INSERT INTO t VALUES (11,1),(12,1),(13,1),(14,2),(15,6);
            FLUSH TABLES;
            SELECT * FROM t ORDER BY c;
            

            Leads to:

            10.8.1 0c5d1342ae6b5ab3256848be7a83e5c3b1f21566 (Optimized)

            10.8.1-opt>FLUSH TABLES;
            ERROR 192 (HY000): Unknown key id 1. Can't continue!
            10.8.1-opt>SELECT * FROM t ORDER BY c;
            ERROR 1034 (HY000): Index for table 't' is corrupt; try to repair it
            

            Roel Roel Van de Paar added a comment - CREATE DATABASE d2; SET GLOBAL aria_encrypt_tables=1; SET default_storage_engine=Aria; SET sql_select_limit=1; CREATE TABLE t (c INT KEY ,c2 INT , KEY (c2)); INSERT INTO t VALUES (11,1),(12,1),(13,1),(14,2),(15,6); FLUSH TABLES; SELECT * FROM t ORDER BY c; Leads to: 10.8.1 0c5d1342ae6b5ab3256848be7a83e5c3b1f21566 (Optimized) 10.8.1-opt>FLUSH TABLES; ERROR 192 (HY000): Unknown key id 1. Can't continue! 10.8.1-opt>SELECT * FROM t ORDER BY c; ERROR 1034 (HY000): Index for table 't' is corrupt; try to repair it
            Roel Roel Van de Paar added a comment - - edited

            Interestingly, the last testcase, on debug, consistently crashes on the FLUSH TABLES with:

            10.8.1 0c5d1342ae6b5ab3256848be7a83e5c3b1f21566 (Debug)

            mysqld: /test/10.8_dbg/sql/sql_error.cc:335: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
            

            10.8.1 0c5d1342ae6b5ab3256848be7a83e5c3b1f21566 (Debug)

            Core was generated by `/test/MD290122-mariadb-10.8.1-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
            Program terminated with signal SIGABRT, Aborted.
            #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
            [Current thread is 1 (Thread 0x1537c5756700 (LWP 312049))]
            (gdb) bt
            #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
            #1  0x00001537e51eb859 in __GI_abort () at abort.c:79
            #2  0x00001537e51eb729 in __assert_fail_base (fmt=0x1537e5381588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55e793f50cb8 "!is_set() || (m_status == DA_OK_BULK && is_bulk_op())", file=0x55e793f50b98 "/test/10.8_dbg/sql/sql_error.cc", line=335, function=<optimized out>) at assert.c:92
            #3  0x00001537e51fcf36 in __GI___assert_fail (assertion=assertion@entry=0x55e793f50cb8 "!is_set() || (m_status == DA_OK_BULK && is_bulk_op())", file=file@entry=0x55e793f50b98 "/test/10.8_dbg/sql/sql_error.cc", line=line@entry=335, function=function@entry=0x55e793f50cf0 "void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*)") at assert.c:101
            #4  0x000055e79322d77d in Diagnostics_area::set_ok_status (this=0x153770006d20, affected_rows=affected_rows@entry=0, last_insert_id=last_insert_id@entry=0, message=message@entry=0x0) at /test/10.8_dbg/sql/sql_error.h:1031
            #5  0x000055e79328bc03 in my_ok (message=0x0, id=0, affected_rows_arg=0, thd=0x153770000db8) at /test/10.8_dbg/sql/sql_class.h:5531
            #6  mysql_execute_command (thd=thd@entry=0x153770000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.8_dbg/sql/sql_parse.cc:5498
            #7  0x000055e793273db7 in mysql_parse (thd=thd@entry=0x153770000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1537c5755400) at /test/10.8_dbg/sql/sql_parse.cc:8027
            #8  0x000055e793282a53 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x153770000db8, packet=packet@entry=0x15377000b889 "FLUSH TABLES", packet_length=packet_length@entry=12, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_class.h:1362
            #9  0x000055e793285e9a in do_command (thd=0x153770000db8, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_parse.cc:1402
            #10 0x000055e793401110 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55e7965abf08, put_in_cache=put_in_cache@entry=true) at /test/10.8_dbg/sql/sql_connect.cc:1418
            #11 0x000055e793401715 in handle_one_connection (arg=arg@entry=0x55e7965abf08) at /test/10.8_dbg/sql/sql_connect.cc:1312
            #12 0x000055e79388ac8e in pfs_spawn_thread (arg=0x55e7964bfd38) at /test/10.8_dbg/storage/perfschema/pfs.cc:2201
            #13 0x00001537e56fa609 in start_thread (arg=<optimized out>) at pthread_create.c:477
            #14 0x00001537e52e8293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            Roel Roel Van de Paar added a comment - - edited Interestingly, the last testcase, on debug, consistently crashes on the FLUSH TABLES with: 10.8.1 0c5d1342ae6b5ab3256848be7a83e5c3b1f21566 (Debug) mysqld: /test/10.8_dbg/sql/sql_error.cc:335: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed. 10.8.1 0c5d1342ae6b5ab3256848be7a83e5c3b1f21566 (Debug) Core was generated by `/test/MD290122-mariadb-10.8.1-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'. Program terminated with signal SIGABRT, Aborted. #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 [Current thread is 1 (Thread 0x1537c5756700 (LWP 312049))] (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00001537e51eb859 in __GI_abort () at abort.c:79 #2 0x00001537e51eb729 in __assert_fail_base (fmt=0x1537e5381588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55e793f50cb8 "!is_set() || (m_status == DA_OK_BULK && is_bulk_op())", file=0x55e793f50b98 "/test/10.8_dbg/sql/sql_error.cc", line=335, function=<optimized out>) at assert.c:92 #3 0x00001537e51fcf36 in __GI___assert_fail (assertion=assertion@entry=0x55e793f50cb8 "!is_set() || (m_status == DA_OK_BULK && is_bulk_op())", file=file@entry=0x55e793f50b98 "/test/10.8_dbg/sql/sql_error.cc", line=line@entry=335, function=function@entry=0x55e793f50cf0 "void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*)") at assert.c:101 #4 0x000055e79322d77d in Diagnostics_area::set_ok_status (this=0x153770006d20, affected_rows=affected_rows@entry=0, last_insert_id=last_insert_id@entry=0, message=message@entry=0x0) at /test/10.8_dbg/sql/sql_error.h:1031 #5 0x000055e79328bc03 in my_ok (message=0x0, id=0, affected_rows_arg=0, thd=0x153770000db8) at /test/10.8_dbg/sql/sql_class.h:5531 #6 mysql_execute_command (thd=thd@entry=0x153770000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.8_dbg/sql/sql_parse.cc:5498 #7 0x000055e793273db7 in mysql_parse (thd=thd@entry=0x153770000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1537c5755400) at /test/10.8_dbg/sql/sql_parse.cc:8027 #8 0x000055e793282a53 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x153770000db8, packet=packet@entry=0x15377000b889 "FLUSH TABLES", packet_length=packet_length@entry=12, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_class.h:1362 #9 0x000055e793285e9a in do_command (thd=0x153770000db8, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_parse.cc:1402 #10 0x000055e793401110 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55e7965abf08, put_in_cache=put_in_cache@entry=true) at /test/10.8_dbg/sql/sql_connect.cc:1418 #11 0x000055e793401715 in handle_one_connection (arg=arg@entry=0x55e7965abf08) at /test/10.8_dbg/sql/sql_connect.cc:1312 #12 0x000055e79388ac8e in pfs_spawn_thread (arg=0x55e7964bfd38) at /test/10.8_dbg/storage/perfschema/pfs.cc:2201 #13 0x00001537e56fa609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #14 0x00001537e52e8293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

            Another testcase to test any fixes with

            SET SESSION sql_mode='',GLOBAL aria_encrypt_tables=1;
            CREATE OR REPLACE VIEW v1 AS SELECT 2 XOR 3 > 3, 2 XOR (3 > 3),(2 XOR 3) > 3;
            CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=Aria;
            INSERT INTO t1 VALUES ('a'),('b');
            ALTER TABLE t1 ENGINE=MERGE UNION (t_not_exists,t1);
            DELETE FROM t1 USING v1, t1 WHERE v1.a=t2.a;
            

            thd->is_error()|SIGABRT|Sql_cmd_dml::prepare|Sql_cmd_dml::execute|mysql_execute_command|mysql_parse
            

            Roel Roel Van de Paar added a comment - Another testcase to test any fixes with SET SESSION sql_mode= '' , GLOBAL aria_encrypt_tables=1; CREATE OR REPLACE VIEW v1 AS SELECT 2 XOR 3 > 3, 2 XOR (3 > 3),(2 XOR 3) > 3; CREATE TABLE t1 (f1 INT PRIMARY KEY ) ENGINE=Aria; INSERT INTO t1 VALUES ( 'a' ),( 'b' ); ALTER TABLE t1 ENGINE=MERGE UNION (t_not_exists,t1); DELETE FROM t1 USING v1, t1 WHERE v1.a=t2.a; thd->is_error()|SIGABRT|Sql_cmd_dml::prepare|Sql_cmd_dml::execute|mysql_execute_command|mysql_parse

            People

              sanja Oleksandr Byelkin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.