Debian Codegraph @

mysql-test/suite/large_tests/t/maria_recover_encrypted.test

raw
1 # MDEV-18187: If server crashes before flushing index pages in an
2 # encrypted Aria table, it could permanently fail to repair the table
3
4 --source include/have_maria.inc
5 --source include/default_charset.inc
6 --source include/not_embedded.inc
7 --source include/have_debug.inc
8
9 # Cleanup
10 --disable_warnings
11 DROP TABLE IF EXISTS t1;
12 DROP PROCEDURE IF EXISTS proc_insert_many;
13 --enable_warnings
14
15 # --------
16
17 # Configure encryption
18 --write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
19 --shutdown_server
20 --source include/wait_until_disconnected.inc
21
22 --write_file $MYSQLTEST_VARDIR/key.txt
23 1;76025E3ADC78D74819927DB02AAA4C35
24 EOF
25
26 --write_line "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/key.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
27 --enable_reconnect
28 --source include/wait_until_connected_again.inc
29
30 # Create table with many indexes so that its index size grows quickly
31 # and it can be grown to needed size without too many inserts
32 CREATE TABLE t1 (
33 field1 INTEGER NOT NULL,
34 field2 INTEGER NOT NULL,
35 field3 INTEGER NOT NULL,
36 KEY i_1 (field1),
37 KEY i_2 (field2),
38 KEY i_3 (field3),
39 KEY i_12 (field1, field2),
40 KEY i_13 (field1, field3),
41 KEY i_21 (field2, field1),
42 KEY i_23 (field2, field3),
43 KEY i_31 (field3, field1),
44 KEY i_32 (field3, field2),
45 KEY i_123 (field1, field2, field3),
46 KEY i_132 (field1, field3, field2),
47 KEY i_213 (field2, field1, field3),
48 KEY i_231 (field2, field3, field1),
49 KEY i_312 (field3, field1, field2),
50 KEY i_321 (field3, field2, field1)
51 ) ENGINE=Aria;
52
53 # Create procedures to insert many rows.
54 DELIMITER |;
55 CREATE PROCEDURE proc_insert_many()
56 BEGIN
57 DECLARE iRow INT DEFAULT 0;
58 insertRows: LOOP
59 IF (iRow = 70000) THEN
60 LEAVE insertRows;
61 END IF;
62
63 INSERT INTO t1 VALUES (1000000+iRow,2000000+iRow,3000000+iRow);
64 SET iRow = iRow + 1;
65 END LOOP insertRows;
66 END|
67 DELIMITER ;|
68
69 # Call the procedure to insert rows.
70 # Use 'LOCK TABLES' to make things a lot faster.
71 # Note that his code doesn't reproduce for some reason:
72 # INSERT INTO t1 SELECT 1000000+seq,2000000+seq,3000000+seq FROM seq_1_to_70000;
73 LOCK TABLES t1 WRITE;
74 CALL proc_insert_many();
75 UNLOCK TABLES;
76
77 # Crash and restart the server while it's still flushing index
78 --write_line "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/key.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
79 SET debug_dbug="d,crash_shutdown";
80 --error 2013
81 shutdown;
82 --enable_reconnect
83 --source include/wait_until_connected_again.inc
84
85 # Access the table to trigger repair; validate repaired data
86 SELECT * FROM t1 ORDER BY 1 DESC LIMIT 10;
87
88 # --------
89
90 # Cleanup
91 DROP TABLE IF EXISTS t1;
92 DROP PROCEDURE IF EXISTS proc_insert_many;