1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge 10.3 into 10.4

This commit is contained in:
Marko Mäkelä
2022-12-13 11:37:33 +02:00
171 changed files with 1861 additions and 469 deletions

View File

@ -0,0 +1,50 @@
CREATE TABLE t1 (
pkey int NOT NULL PRIMARY KEY,
c int
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1,1);
CREATE TABLE t2 (
pkey int NOT NULL PRIMARY KEY,
c int
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t2 VALUES (2, NULL);
CREATE TABLE t3 (c int) engine = InnoDB;
INSERT INTO t3 VALUES (10), (20), (30), (40), (50);
connect con1, localhost,root,,;
connection default;
START TRANSACTION;
UPDATE t3 SET c=c+1000;
SELECT * FROM t1 FOR UPDATE;
pkey c
1 1
connection con1;
START TRANSACTION;
DELETE FROM t2 WHERE c NOT IN (SELECT ref_0.pkey FROM t1 AS ref_0 INNER JOIN t1 AS ref_1 ON ref_0.c = ref_0.pkey);
connection default;
SELECT * FROM t2 FOR UPDATE;
pkey c
2 NULL
COMMIT;
connection con1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
connection default;
START TRANSACTION;
UPDATE t3 SET c=c+1000;
SELECT * FROM t1 FOR UPDATE;
pkey c
1 1
connection con1;
START TRANSACTION;
UPDATE t2 SET pkey=pkey+10 WHERE c NOT IN (SELECT ref_0.pkey FROM t1 AS ref_0 INNER JOIN t1 AS ref_1 ON ref_0.c = ref_0.pkey);
connection default;
SELECT * FROM t2 FOR UPDATE;
pkey c
2 NULL
COMMIT;
connection con1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
disconnect con1;
connection default;
DROP TABLE t1,t2,t3;

View File

@ -0,0 +1,26 @@
#
# MDEV-29144 ER_TABLE_SCHEMA_MISMATCH or crash on DISCARD/IMPORT
#
CREATE TABLE t (pk int PRIMARY KEY, c varchar(1024))
ENGINE=InnoDB CHARSET latin1;
INSERT INTO t SELECT seq, 'x' FROM seq_1_to_100;
connect con1,localhost,root,,test;
BEGIN NOT ATOMIC
DECLARE a INT DEFAULT 0;
REPEAT
SET a= a+1;
UPDATE t SET c = 'xx' WHERE pk = a;
UNTIL a = 100
END REPEAT;
END
$
connection default;
ALTER TABLE t NOWAIT ADD INDEX (c);
connection con1;
connection default;
FLUSH TABLE t FOR EXPORT;
UNLOCK TABLES;
DROP TABLE t;
ALTER TABLE t DISCARD TABLESPACE;
ALTER TABLE t IMPORT TABLESPACE;
DROP TABLE t;

View File

@ -460,10 +460,26 @@ SET DEBUG_SYNC = 'now WAIT_FOR created';
UPDATE t1 SET f = REPEAT('a', 20000);
SET DEBUG_SYNC = 'now SIGNAL updated';
connection con1;
disconnect con1;
connection default;
DROP TABLE t1;
SET DEBUG_SYNC = 'RESET';
#
# MDEV-29977 Memory leak in row_log_table_apply_update
#
CREATE TABLE t1(f1 longtext, f2 int, KEY(f1(1024)), KEY(f2, f1(20))) ENGINE=InnoDB;
INSERT INTO t1 VALUES('a', 1);
connection con1;
set DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con_default WAIT_FOR con1_signal";
ALTER TABLE t1 FORCE;
connection default;
SET DEBUG_SYNC="now WAIT_FOR con_default";
UPDATE t1 SET f1 = NULL;
UPDATE t1 SET f1 = REPEAT('b', 9000);
SET DEBUG_SYNC="now SIGNAL con1_signal";
connection con1;
DROP TABLE t1;
connection default;
SET DEBUG_SYNC=RESET;
disconnect con1;
SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig;
SET GLOBAL innodb_monitor_enable = default;
SET GLOBAL innodb_monitor_disable = default;

View File

@ -795,3 +795,19 @@ DROP DATABASE testdb_wl5522;
call mtr.add_suppression("Got error -1 when reading table '.*'");
call mtr.add_suppression("InnoDB: Error: tablespace id and flags in file '.*'.*");
call mtr.add_suppression("InnoDB: The table .* doesn't have a corresponding tablespace, it was discarded");
#
# MDEV-27882 Innodb - recognise MySQL-8.0 innodb flags and give a specific error message
#
#
CREATE TABLE `t1` (`i` int(11) NOT NULL, PRIMARY KEY (`i`) ) ENGINE=InnoDB;
FLUSH TABLES t1 FOR EXPORT;
backup: t1
UNLOCK TABLES;
ALTER TABLE t1 DISCARD TABLESPACE;
call mtr.add_suppression("InnoDB: unsupported MySQL tablespace");
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR 42000: Table 't1' uses an extension that doesn't exist in this MariaDB version
DROP TABLE t1;
#
# End of 10.3 tests
#

View File

@ -448,7 +448,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_reset_space_and_lsn_failure";
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Internal error: Cannot reset LSNs in table `test`.`t1` : Too many concurrent transactions
ERROR HY000: Internal error: Error importing tablespace for table `test`.`t1` : Too many concurrent transactions
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug=@saved_debug_dbug;
SET SESSION debug_dbug="+d,ib_import_open_tablespace_failure";
@ -867,7 +867,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,ib_import_trigger_corruption_1";
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Internal error: Cannot reset LSNs in table `test`.`t1` : Data structure corruption
ERROR HY000: Internal error: Error importing tablespace for table `test`.`t1` : Data structure corruption
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE t1;
unlink: t1.ibd
@ -879,7 +879,7 @@ ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
SET SESSION debug_dbug="+d,buf_page_import_corrupt_failure";
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Internal error: Cannot reset LSNs in table `test`.`t1` : Data structure corruption
ERROR HY000: Internal error: Error importing tablespace for table `test`.`t1` : Data structure corruption
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE t1;
unlink: t1.ibd

View File

@ -3,6 +3,8 @@
#
# FIXME: Unlike MySQL, maybe MariaDB should not read the .ibd files
# of tables with .isl file or DATA DIRECTORY attribute.
call mtr.add_suppression("\\[ERROR\\] InnoDB: MySQL-8\\.0 tablespace in ");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Restart in MySQL for migration/recovery\\.");
# FIXME: This is much more noisy than MariaDB 10.1!
call mtr.add_suppression("\\[ERROR\\] InnoDB: Tablespace flags are invalid in datafile: .*test.t[rcd]\\.ibd");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Operating system error number .* in a file operation\\.");
@ -41,3 +43,11 @@ Warning 1210 innodb_buffer_pool_size must be at least MIN_VAL for innodb_page_si
Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size);
SET GLOBAL innodb_buffer_pool_size = @innodb_buffer_pool_size_orig;
#
# MDEV-27882 Innodb - recognise MySQL-8.0 innodb flags and give a specific error message
#
FOUND 1 /InnoDB: MySQL-8\.0 tablespace in \./ibdata1/ in attempted_start.err
# restart
#
# End of 10.3 tests
#

View File

@ -2,13 +2,6 @@
--source include/have_innodb.inc
--source include/have_symlink.inc
--disable_query_log
CALL mtr.add_suppression(".*Failed to set O_DIRECT on file.*");
# The below mtr suppression to avoid failure in solaris platform.
CALL mtr.add_suppression("\\[ERROR\\] InnoDB: Failed to set DIRECTIO_ON on file.*");
--enable_query_log
SHOW VARIABLES LIKE 'innodb_flush_method';
let MYSQLD_DATADIR=`SELECT @@datadir`;

View File

@ -0,0 +1,81 @@
--source include/have_innodb.inc
--source include/count_sessions.inc
CREATE TABLE t1 (
pkey int NOT NULL PRIMARY KEY,
c int
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1,1);
CREATE TABLE t2 (
pkey int NOT NULL PRIMARY KEY,
c int
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t2 VALUES (2, NULL);
# The following table is to increase tansaction weight on deadlock resolution
CREATE TABLE t3 (c int) engine = InnoDB;
INSERT INTO t3 VALUES (10), (20), (30), (40), (50);
--let $i= 2
--let $delete= 2
--let $update= 1
--connect(con1, localhost,root,,)
while($i) {
--connection default
START TRANSACTION; # trx 1
# The following update is necessary to increase the transaction weight, which is
# calculated as the number of locks + the number of undo records during deadlock
# report. Victim's transaction should have minimum weight. We need trx 2 to be
# choosen as victim, that's why we need to increase the current transaction
# weight.
UPDATE t3 SET c=c+1000;
SELECT * FROM t1 FOR UPDATE;
--connection con1
START TRANSACTION; # trx 2
# 1) read record from t2, lock it
# 2) check if the read record should be deleted, i.e. read record from t1,
# as the record from t1 is locked by trx 1, the subselect will be suspended.
# see 'while' loop in mysql_delete() or mysql_update() and
# select->skip_record(thd) call for details.
if ($i == $delete) {
--send DELETE FROM t2 WHERE c NOT IN (SELECT ref_0.pkey FROM t1 AS ref_0 INNER JOIN t1 AS ref_1 ON ref_0.c = ref_0.pkey)
}
if ($i == $update) {
--send UPDATE t2 SET pkey=pkey+10 WHERE c NOT IN (SELECT ref_0.pkey FROM t1 AS ref_0 INNER JOIN t1 AS ref_1 ON ref_0.c = ref_0.pkey)
}
--connection default
let $wait_condition=
SELECT count(*) = 1 FROM information_schema.processlist
WHERE (state = 'Sending data' OR state = "Updating")
AND (info LIKE 'delete from t2 where%' OR
info LIKE 'UPDATE t2 SET pkey=pkey+10 WHERE%');
--source include/wait_condition.inc
# The record from t2 is locked by the previous delete, so trx 2 is waiting for
# trx 1, and trx 1 will be blocked by trx 2 with the following SELECT. So we
# have deadlock here. And trx 2 is chosen as deadlock victim as trx 1 has
# greater weight.
SELECT * FROM t2 FOR UPDATE;
COMMIT;
--connection con1
# If the bug is not fixed, there will be assertion failure as
# mysql_delete()/mysql_update() will continue execution despite its subselect
# got deadlock error
--error ER_LOCK_DEADLOCK
--reap
COMMIT;
--dec $i
}
--disconnect con1
--connection default
DROP TABLE t1,t2,t3;
--source include/wait_until_count_sessions.inc

View File

@ -0,0 +1,54 @@
--source include/have_innodb.inc
--source include/have_sequence.inc
--echo #
--echo # MDEV-29144 ER_TABLE_SCHEMA_MISMATCH or crash on DISCARD/IMPORT
--echo #
CREATE TABLE t (pk int PRIMARY KEY, c varchar(1024))
ENGINE=InnoDB CHARSET latin1;
INSERT INTO t SELECT seq, 'x' FROM seq_1_to_100;
--connect (con1,localhost,root,,test)
--delimiter $
--send
BEGIN NOT ATOMIC
DECLARE a INT DEFAULT 0;
REPEAT
SET a= a+1;
UPDATE t SET c = 'xx' WHERE pk = a;
UNTIL a = 100
END REPEAT;
END
$
--delimiter ;
--connection default
--error 0,ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t NOWAIT ADD INDEX (c);
--connection con1
--reap
--connection default
--let $datadir= `select @@datadir`
FLUSH TABLE t FOR EXPORT;
--let $create= query_get_value(SHOW CREATE TABLE t, Create Table, 1)
--copy_file $datadir/test/t.cfg $MYSQL_TMP_DIR/t.cfg
--copy_file $datadir/test/t.ibd $MYSQL_TMP_DIR/t.ibd
UNLOCK TABLES;
DROP TABLE t;
--disable_query_log
eval $create;
--enable_query_log
ALTER TABLE t DISCARD TABLESPACE;
--move_file $MYSQL_TMP_DIR/t.cfg $datadir/test/t.cfg
--move_file $MYSQL_TMP_DIR/t.ibd $datadir/test/t.ibd
ALTER TABLE t IMPORT TABLESPACE;
# Cleanup
DROP TABLE t;

View File

@ -413,11 +413,28 @@ SET DEBUG_SYNC = 'now SIGNAL updated';
connection con1;
reap;
disconnect con1;
connection default;
DROP TABLE t1;
SET DEBUG_SYNC = 'RESET';
--echo #
--echo # MDEV-29977 Memory leak in row_log_table_apply_update
--echo #
CREATE TABLE t1(f1 longtext, f2 int, KEY(f1(1024)), KEY(f2, f1(20))) ENGINE=InnoDB;
INSERT INTO t1 VALUES('a', 1);
connection con1;
set DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con_default WAIT_FOR con1_signal";
send ALTER TABLE t1 FORCE;
connection default;
SET DEBUG_SYNC="now WAIT_FOR con_default";
UPDATE t1 SET f1 = NULL;
UPDATE t1 SET f1 = REPEAT('b', 9000);
SET DEBUG_SYNC="now SIGNAL con1_signal";
connection con1;
reap;
DROP TABLE t1;
connection default;
SET DEBUG_SYNC=RESET;
disconnect con1;
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.

View File

@ -932,3 +932,34 @@ call mtr.add_suppression("InnoDB: The table .* doesn't have a corresponding tabl
--remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd
--remove_file $MYSQLTEST_VARDIR/tmp/t1_fk.cfg
--remove_file $MYSQLTEST_VARDIR/tmp/t1_fk.ibd
--echo #
--echo # MDEV-27882 Innodb - recognise MySQL-8.0 innodb flags and give a specific error message
--echo #
--echo #
CREATE TABLE `t1` (`i` int(11) NOT NULL, PRIMARY KEY (`i`) ) ENGINE=InnoDB;
FLUSH TABLES t1 FOR EXPORT;
# We use the cfg file of ours.
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_backup_tablespaces("test", "t1");
EOF
UNLOCK TABLES;
ALTER TABLE t1 DISCARD TABLESPACE;
--move_file $MYSQLTEST_VARDIR/tmp/t1.cfg $MYSQLD_DATADIR/test/t1.cfg
--copy_file std_data/mysql80/t1.ibd $MYSQLD_DATADIR/test/t1.ibd
call mtr.add_suppression("InnoDB: unsupported MySQL tablespace");
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t1 IMPORT TABLESPACE;
DROP TABLE t1;
--remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd
--echo #
--echo # End of 10.3 tests
--echo #

View File

@ -15,6 +15,9 @@ let page_size= `select @@innodb_page_size`;
--echo # FIXME: Unlike MySQL, maybe MariaDB should not read the .ibd files
--echo # of tables with .isl file or DATA DIRECTORY attribute.
call mtr.add_suppression("\\[ERROR\\] InnoDB: MySQL-8\\.0 tablespace in ");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Restart in MySQL for migration/recovery\\.");
--echo # FIXME: This is much more noisy than MariaDB 10.1!
call mtr.add_suppression("\\[ERROR\\] InnoDB: Tablespace flags are invalid in datafile: .*test.t[rcd]\\.ibd");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Operating system error number .* in a file operation\\.");
@ -47,7 +50,7 @@ die unless open OUT, ">", "$ENV{datadir}/test/tc.ibd";
print OUT "bar " x $ENV{page_size};
close OUT or die;
die unless open OUT, ">", "$ENV{MYSQL_TMP_DIR}/test/td.ibd";
print OUT "xyz " x $ENV{page_size};
print OUT "Xyz " x $ENV{page_size};
close OUT or die;
EOF
@ -101,3 +104,60 @@ EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size
--source include/wait_condition.inc
SET GLOBAL innodb_buffer_pool_size = @innodb_buffer_pool_size_orig;
--echo #
--echo # MDEV-27882 Innodb - recognise MySQL-8.0 innodb flags and give a specific error message
--echo #
--let MYSQLD_DATADIR= `SELECT @@datadir`
--let SERVER_ID= `SELECT @@server_id`
--let EXPECT_FILE_NAME= $MYSQLTEST_VARDIR/tmp/mysqld.$SERVER_ID.expect
--source include/shutdown_mysqld.inc
--move_file $MYSQLD_DATADIR/ibdata1 $MYSQLD_DATADIR/ibdata1.bak
--copy_file std_data/mysql80/ibdata1_$page_size $MYSQLD_DATADIR/ibdata1
perl;
use IO::Handle;
my $size = 9 * 1048576;
if ($ENV{MTR_COMBINATION_32K}) {
$size *= 2;
}
if ($ENV{MTR_COMBINATION_64K}) {
$size *= 4;
}
$size -= $ENV{page_size};
die unless open(FILE, ">>", "$ENV{MYSQLD_DATADIR}/ibdata1");
binmode FILE;
print FILE chr(0) x $size;
close(FILE);
EOF
--let ibdata_size='9M'
if ($MTR_COMBINATION_32K)
{
--let ibdata_size='18M'
}
if ($MTR_COMBINATION_64K)
{
--let ibdata_size='36M'
}
--error 1
exec $MYSQLD --no-defaults --skip-networking --innodb_data_file_path=ibdata1:$ibdata_size --innodb-page-size=$page_size --datadir=$MYSQLD_DATADIR --log-error=$MYSQL_TMP_DIR/attempted_start.err;
let SEARCH_FILE= $MYSQL_TMP_DIR/attempted_start.err;
let SEARCH_PATTERN= InnoDB: MySQL-8\.0 tablespace in \./ibdata1;
source include/search_pattern_in_file.inc;
--remove_file $MYSQL_TMP_DIR/attempted_start.err
--remove_file $MYSQLD_DATADIR/ibdata1
--move_file $MYSQLD_DATADIR/ibdata1.bak $MYSQLD_DATADIR/ibdata1
--source include/start_mysqld.inc
--echo #
--echo # End of 10.3 tests
--echo #