|
I should have probably added all this to MDEV-20436 instead of filing a new one, but didn't find MDEV-20436 in time.
|
|
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
|
|
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
|
|
|
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
|
|