From bdc961acc7ae9d5a3661ac425e936cd03dc5ccbb Mon Sep 17 00:00:00 2001 From: Sachin Date: Wed, 10 Jul 2019 11:51:43 +0530 Subject: [PATCH 01/26] MDEV-17588 replicate-do filters cause errors when creating filtered-out tables on master with syntax unsupported on slave Add only test case for MDEV , because MDEV-19653 already fixed the issue. --- mysql-test/suite/rpl/r/mdev_17588.result | 32 +++++++++++++++++ mysql-test/suite/rpl/t/mdev_17588-slave.opt | 1 + mysql-test/suite/rpl/t/mdev_17588.test | 39 +++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 mysql-test/suite/rpl/r/mdev_17588.result create mode 100644 mysql-test/suite/rpl/t/mdev_17588-slave.opt create mode 100644 mysql-test/suite/rpl/t/mdev_17588.test diff --git a/mysql-test/suite/rpl/r/mdev_17588.result b/mysql-test/suite/rpl/r/mdev_17588.result new file mode 100644 index 00000000000..fea28a311b4 --- /dev/null +++ b/mysql-test/suite/rpl/r/mdev_17588.result @@ -0,0 +1,32 @@ +include/master-slave.inc +[connection master] +create table t1 (a int) engine=innodb; +create table t2 (a int); +create table t3 (a int) engine=innodb; +include/save_master_gtid.inc +include/wait_for_slave_sql_error.inc [errno=1286] +Last_Error = 'Error 'Unknown storage engine 'innodb'' on query. Default database: 'test'. Query: 'create table t1 (a int) engine=innodb'' +STOP SLAVE IO_THREAD; +include/wait_for_slave_to_stop.inc +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; +include/start_slave.inc +include/sync_with_master_gtid.inc +show tables; +Tables_in_test +t2 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table t1; +ERROR 42S02: Table 'test.t1' doesn't exist +show create table t3; +ERROR 42S02: Table 'test.t3' doesn't exist +drop table if exists t1; +drop table if exists t2; +drop table if exists t3; +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +CALL mtr.add_suppression('Slave: Unknown storage engine .* Error_code: 1286'); +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/mdev_17588-slave.opt b/mysql-test/suite/rpl/t/mdev_17588-slave.opt new file mode 100644 index 00000000000..d73dbeca51a --- /dev/null +++ b/mysql-test/suite/rpl/t/mdev_17588-slave.opt @@ -0,0 +1 @@ +--loose-disable-innodb --replicate-ignore-table=test.t3 diff --git a/mysql-test/suite/rpl/t/mdev_17588.test b/mysql-test/suite/rpl/t/mdev_17588.test new file mode 100644 index 00000000000..e9a340cbd25 --- /dev/null +++ b/mysql-test/suite/rpl/t/mdev_17588.test @@ -0,0 +1,39 @@ +--source include/master-slave.inc +--source include/have_innodb.inc + +--connection master +create table t1 (a int) engine=innodb; +create table t2 (a int); +create table t3 (a int) engine=innodb; +--source include/save_master_gtid.inc + +--connection slave +# Using ER_UNKNOWN_STORAGE_ENGINE wont work +let $slave_sql_errno= 1286; +--source include/wait_for_slave_sql_error.inc +--let $status_items= Last_Error +--source include/show_slave_status.inc +STOP SLAVE IO_THREAD; +source include/wait_for_slave_to_stop.inc; +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc +show tables; +show create table t2; +--error ER_NO_SUCH_TABLE +show create table t1; +--error ER_NO_SUCH_TABLE +show create table t3; + +--connection master +drop table if exists t1; +drop table if exists t2; +drop table if exists t3; +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + + +CALL mtr.add_suppression('Slave: Unknown storage engine .* Error_code: 1286'); +--source include/rpl_end.inc From 5d04391f58b404760c5254c8722c2da732ce2630 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 5 Jul 2019 08:37:44 +0200 Subject: [PATCH 02/26] MDEV-19726 MariaDB server or backup RPM install assumes mysql user exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also get rid of chown: cannot access ‘/var/lib/mysql’: No such file or directory before someone reports a bug that MariaDB server or backup RPM install assumes mysql datadir exists followup for bee24fe1818 --- support-files/rpm/server-postin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh index 0a5bac73f0b..deb27c98ac1 100644 --- a/support-files/rpm/server-postin.sh +++ b/support-files/rpm/server-postin.sh @@ -50,7 +50,7 @@ if [ $1 = 1 ] ; then # Change permissions so that the user that will run the MySQL daemon # owns all database files. - chown -R %{mysqld_user}:%{mysqld_group} $datadir + chown -R -f %{mysqld_user}:%{mysqld_group} $datadir if [ ! -e $datadir/mysql ]; then # Create data directory From a43edf73f38bb7ce6f20f7dd25240296108ae2d0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 8 Jul 2019 12:08:00 +0200 Subject: [PATCH 03/26] restore RESTRICT_SYMBOL_EXPORTS(zlib) that was lost in c54271723c6 remove zlib/libxml2 workaround in CONNECT --- storage/connect/CMakeLists.txt | 9 --------- zlib/CMakeLists.txt | 5 ++--- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 1d98d321486..0493e05a810 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -114,7 +114,6 @@ IF(CONNECT_WITH_LIBXML2) FIND_PACKAGE(LibXml2) IF (LIBXML2_FOUND) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) - SET(ZLIB_LIBRARY "z") # see ZLIB_INCLUDE_DIR below SET(XML_LIBRARY ${LIBXML2_LIBRARIES}) SET(CONNECT_SOURCES ${CONNECT_SOURCES} libdoc.cpp libdoc.h) add_definitions(-DLIBXML2_SUPPORT) @@ -333,14 +332,6 @@ IF(NOT TARGET connect) RETURN() ENDIF() -# Don't link with bundled zlib and systel libxml2 at the same time. -# System libxml2 uses system zlib, might conflict with the bundled one. -IF (XML_LIBRARY AND BUILD_BUNDLED_ZLIB) - GET_PROPERTY(INCS TARGET connect PROPERTY INCLUDE_DIRECTORIES) - LIST(REMOVE_ITEM INCS ${ZLIB_INCLUDE_DIR}) - SET_PROPERTY(TARGET connect PROPERTY INCLUDE_DIRECTORIES ${INCS}) -ENDIF() - IF(WIN32) IF (libmongoc-1.0_FOUND) SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index 5d58f9a42b6..f654f98bfc4 100644 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -124,6 +124,8 @@ string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" ADD_CONVENIENCE_LIBRARY(zlib STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +RESTRICT_SYMBOL_EXPORTS(zlib) + if(NOT CYGWIN) # This property causes shared libraries on Linux to have the full version @@ -142,7 +144,4 @@ if(CMAKE_SYSTEM_NAME MATCHES "SunOS") elseif(UNIX) # On unix-like platforms the library is almost always called libz set_target_properties(zlib PROPERTIES OUTPUT_NAME z) - if(NOT APPLE) - set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") - endif() endif() From d91dd2878acdc18cda0460354341617b31f0282a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 8 Jul 2019 18:15:47 +0200 Subject: [PATCH 04/26] MDEV-9409 workaround --- mysql-test/r/mysqld--help.result | 2 +- mysql-test/t/mysqld--help.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index db957e4c9ca..68aa84b6d18 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -1,4 +1,4 @@ -Windows bug: happens when a new line is exactly at the right offset. +Windows bug: new line disappears when it is exactly at the right offset. The following options may be given as the first argument: --print-defaults Print the program argument list and exit. --no-defaults Don't read default options from any option file. diff --git a/mysql-test/t/mysqld--help.test b/mysql-test/t/mysqld--help.test index 8b4674c140c..8924d2c45da 100644 --- a/mysql-test/t/mysqld--help.test +++ b/mysql-test/t/mysqld--help.test @@ -42,7 +42,7 @@ perl; $re2=join('|', @plugins); $skip=0; open(F, '<', "$ENV{MYSQL_TMP_DIR}/mysqld--help.txt") or die; - print "Windows bug: happens when a new line is exactly at the right offset.\n"; + print "Windows bug: new line disappears when it is exactly at the right offset.\n"; while () { next if 1../The following groups are read/; # formatting, skip line consisting entirely of dashes and blanks From e52fea3fe945b168bb25a0d33b2ca78092737d77 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Thu, 11 Jul 2019 02:55:04 -0700 Subject: [PATCH 05/26] Fix typo open_table_def() --- sql/table.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/table.cc b/sql/table.cc index 91b321930ab..94cd174ffd7 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -540,14 +540,14 @@ inline bool is_system_table_name(const char *name, uint length) SYNOPSIS open_table_def() - thd Thread handler + thd Thread handler share Fill this with table definition - db_flags Bit mask of the following flags: OPEN_VIEW + flags Bit mask of the following flags: OPEN_VIEW NOTES This function is called when the table definition is not cached in table definition cache - The data is returned in 'share', which is alloced by + The data is returned in 'share', which is allocated by alloc_table_share().. The code assumes that share is initialized. */ From aba2b41e9ed3a309bdbe8a1efe0f27c5b71cae8d Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 11 Jul 2019 18:24:27 +0530 Subject: [PATCH 06/26] MDEV-19978 Page read from tablespace is corrupted Problem: ======= Checksum fields can have value as zero. In that case, InnoDB falsely consider that page should be all zeroes. It leads to wrong detection of page corruption. Solution: ======== Remove the condition that checks if checksum fields are zero then page should be all zeroes. --- storage/innobase/buf/buf0buf.cc | 36 ++++++++++++++++----------------- storage/xtradb/buf/buf0buf.cc | 29 +++++++++++++------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 50a3c8b8b2d..73c757569ad 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -951,26 +951,26 @@ buf_page_is_corrupted( the first page of each file of the system tablespace. Ignore it for the system tablespace. */ if (!checksum_field1 && !checksum_field2) { - ulint i = 0; - do { - if (read_buf[i]) { - return true; - } - } while (++i < FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - + /* Checksum fields can have valid value as zero. + If the page is not empty then do the checksum + calculation for the page. */ + bool all_zeroes = true; + for (size_t i = 0; i < srv_page_size; i++) { #ifndef UNIV_INNOCHECKSUM - if (!space || !space->id) { - /* Skip FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION - in the system tablespace. */ - i += 8; - } -#endif - do { - if (read_buf[i]) { - return true; + if (i == FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + && (!space || !space->id)) { + i += 8; } - } while (++i < srv_page_size); - return false; +#endif + if (read_buf[i]) { + all_zeroes = false; + break; + } + } + + if (all_zeroes) { + return false; + } } switch (curr_algo) { diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 80fe62decc3..3326f734e45 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -950,24 +950,25 @@ buf_page_is_corrupted( the first page of each file of the system tablespace. Ignore it for the system tablespace. */ if (!checksum_field1 && !checksum_field2) { - ulint i = 0; - do { - if (read_buf[i]) { - return true; + /* Checksum fields can have valid value as zero. + If the page is not empty then do the checksum + calculation for the page. */ + bool all_zeroes = true; + for (size_t i = 0; i < srv_page_size; i++) { + if (i == FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + && (!space || space->id)) { + i += 8; } - } while (++i < FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - if (!space || !space->id) { - /* Skip FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION - in the system tablespace. */ - i += 8; - } - do { if (read_buf[i]) { - return true; + all_zeroes = false; + break; } - } while (++i < srv_page_size); - return false; + } + + if (all_zeroes) { + return false; + } } switch (curr_algo) { From 10ebdb7f1d7a3f6aa6a91b40a9d90f482da08e58 Mon Sep 17 00:00:00 2001 From: Sujatha Date: Mon, 15 Jul 2019 13:30:10 +0530 Subject: [PATCH 07/26] MDEV-11154: Write_on_release_cache(log_event.cc) function will not write "COMMIT", if use "mysqlbinlog ... | mysql ..." Problem: ======= Executing command, "mysqlbinlog --read-from-remote-server --host='xx.xx.xx.xx' --port=3306 --user=xxx --password=xxx --database=mysql --to-last-log mysql-bin.000001 --start-position=1098699 --stop-never |mysql -uxxx -pxxx", we found that last data read from remote couldn't commit. Analysis: ======== The purpose of 'Write_on_release_cache' is that the contents of the Cache will automatically be written to a dedicated result file on destruction. Flush operation on the result file is controlled by a flag 'FLUSH_F'. Events which require force flush upon their destruction will have to enable this 'Write_on_release_cache::FLUSH_F'. At present the 'FLUSH_F' flag is defined as an enum as shown below. enum flag { FLUSH_F }; Since 'FLUSH_F' is the first member without initialization it get the default value '0'. Because of this the following flush condition never succeeds. if (m_flags & FLUSH_F) fflush(m_file); At present the file gets flushed only during my_fclose(result_file) operation. When continuous streaming is enabled through --stop-never option it never gets flushed and hence events are not replicated. Fix: === Initialize the enum value to non zero value. --- .../r/binlog_mysqlbinlog_stop_never.result | 16 +++++ .../t/binlog_mysqlbinlog_stop_never.test | 66 +++++++++++++++++++ sql/log_event.cc | 2 +- 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/binlog/r/binlog_mysqlbinlog_stop_never.result create mode 100644 mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_stop_never.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_stop_never.result new file mode 100644 index 00000000000..e94f17b9489 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_stop_never.result @@ -0,0 +1,16 @@ +RESET MASTER; +include/stop_dump_threads.inc +# Step-1: Execute some dummy statements. +CREATE TABLE t1(i int); +INSERT INTO t1 values (1); +# Step-2: Disable binary log temporarily and drop the table 't1'. +set @@SESSION.SQL_LOG_BIN = 0; +DROP TABLE t1; +set @@SESSION.SQL_LOG_BIN = 1; +# Step-3: Execute MYSQL_BINLOG with --stop-never and source it to mysql client. +# Step-4: Wait till dump thread transfer is completed. +# Step-5: Check that the data is there. +# Step-6: Cleanup +# kill the dump thread serving the mysqlbinlog --stop-never process +include/stop_dump_threads.inc +DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test new file mode 100644 index 00000000000..d73e453ce96 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test @@ -0,0 +1,66 @@ +# ==== Purpose ==== +# +# Test verifies that continuous streaming of binary log content using the +# "mysqlbinlog --stop-never" option and sourcing it to mysql client works +# fine. +# +# ==== Implementation ==== +# +# Steps: +# 1 - Create a table on a server on which binary log is enabled and insert +# a row. +# 2 - Disable the binary log on the server and drop the table. +# 3 - Capture the binary log output using "mysqlbinlog --stop_never" option +# and source it to mysql client. +# 4 - Query the PROCESSLIST table to ensure that the dump thread which is +# serving "stop_never" option has read entire binlog. +# 5 - Verify that the table is populated on the server. +# 6 - Cleanup. +# +# ==== References ==== +# +# MDEV-11154: Write_on_release_cache(log_event.cc) function will not write +# "COMMIT", if use "mysqlbinlog ... | mysql ..." + +--source include/not_windows.inc + +# Test is not specific to any binlog format. Hence Running only for 'row'. +--source include/have_binlog_format_row.inc + +# binlog file name is needed in the test. To use master-bin.000001, +# RESET MASTER is needed. +RESET MASTER; +# kill the dump threads if there any dump threads (may be from previous test) +--source include/stop_dump_threads.inc + +--echo # Step-1: Execute some dummy statements. +CREATE TABLE t1(i int); +INSERT INTO t1 values (1); + +--echo # Step-2: Disable binary log temporarily and drop the table 't1'. +set @@SESSION.SQL_LOG_BIN = 0; +DROP TABLE t1; +set @@SESSION.SQL_LOG_BIN = 1; + +--echo # Step-3: Execute MYSQL_BINLOG with --stop-never and source it to mysql client. +--write_file $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh +(`$MYSQL_BINLOG --read-from-remote-server --stop-never --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 | $MYSQL --user=root --protocol=tcp --host=127.0.0.1 --port=$MASTER_MYPORT`) < /dev/null > /dev/null 2>&1 & +EOF +--exec /bin/bash $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh + +--echo # Step-4: Wait till dump thread transfer is completed. +let $wait_condition= SELECT id from information_schema.processlist where processlist.command like '%Binlog%' and state like '%Master has sent%'; +--source include/wait_condition.inc + +--echo # Step-5: Check that the data is there. +let $count= 1; +let $table= test.t1; +source include/wait_until_rows_count.inc; + +--echo # Step-6: Cleanup +--echo # kill the dump thread serving the mysqlbinlog --stop-never process +--source include/stop_dump_threads.inc + +DROP TABLE t1; +--remove_file $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh + diff --git a/sql/log_event.cc b/sql/log_event.cc index 61748799a54..65f29441e1a 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -296,7 +296,7 @@ class Write_on_release_cache public: enum flag { - FLUSH_F + FLUSH_F= 1 }; typedef unsigned short flag_set; From 537893b072473f44147af91c75233b62af32b6b9 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 16 Jul 2019 11:07:46 +0300 Subject: [PATCH 08/26] Fix rocksdb.tbl_opt_data_index_dir on a mac Part #2: also replace error text in SHOW WARNINGS --- .../rocksdb/mysql-test/rocksdb/t/tbl_opt_data_index_dir.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_data_index_dir.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_data_index_dir.test index 9f70dbe40ec..6fcfd491af1 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_data_index_dir.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_data_index_dir.test @@ -20,11 +20,13 @@ DROP TABLE IF EXISTS t1; --replace_result error: error --error ER_CANT_CREATE_TABLE CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb DATA DIRECTORY = '/foo/bar/data'; +--replace_result error: error show warnings; --replace_result error: error --error ER_CANT_CREATE_TABLE CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb INDEX DIRECTORY = '/foo/bar/index'; +--replace_result error: error show warnings; # @@ -41,6 +43,7 @@ CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY) ENGINE=rocksdb PARTITION BY RANGE DATA DIRECTORY = '/foo/bar/data/', PARTITION P2 VALUES LESS THAN (MAXVALUE) ); +--replace_result error: error show warnings; --replace_result error: error @@ -53,4 +56,5 @@ CREATE TABLE t1 (id int not null primary key) ENGINE=rocksdb PARTITION BY RANGE INDEX DIRECTORY = '/foo/bar/data/', PARTITION P2 VALUES LESS THAN (MAXVALUE) ); +--replace_result error: error show warnings; From 143fede177a9efd46bc805494ba446bd126ff2a9 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 16 Jul 2019 11:10:59 +0300 Subject: [PATCH 09/26] Disable rocksdb.force_shutdown, rocksdb.shutdown is fine Fix this patch (two csets before): Disable rocksdb.shutdown test It was introduced by this patch in fb/mysql-5.6: Author: Yoshinori Matsunobu Date: Mon Jun 10 14:09:28 2019 -0700 Extending SHUTDOWN query to support read_only/aborting Summary: This diff extends SHUTDOWN query to support the following features. - Aborting with any specified exit code (range is 0..255). If nothing is specified or 0 is given, it does default clean shutdown. If 1+ is given, exits with the given error code immediately. This is helpful to shutting down instance even if it is stuck somewhere. MariaDB doesn't support SHUTDOWN statement or have any other way to exit the server process. --- storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def index 4cff7e1e9eb..45e19bf88e8 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def @@ -38,7 +38,7 @@ rocksdb_read_free_rpl_stress : Read-Free replication is not supported blind_delete_rr : Read-Free replication is not supported blind_delete_rc : Read-Free replication is not supported -shutdown: requires support for SHUTDOWN statement which calls exit(). +force_shutdown: requires support for SHUTDOWN statement which calls exit(). ## ## Tests that do not fit MariaDB's test environment. Upstream seems to test From 612f4908d2f048ef5db45b184875af8d21c9fd4d Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 16 Jul 2019 12:23:52 +0300 Subject: [PATCH 10/26] rocksdb.unique_check: attempt to remove race condtitions from the test --- .../mysql-test/rocksdb/r/unique_check.result | 12 ++++++------ .../mysql-test/rocksdb/t/unique_check.test | 15 ++++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb/r/unique_check.result b/storage/rocksdb/mysql-test/rocksdb/r/unique_check.result index 8de94e0297e..db9b119043a 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/unique_check.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/unique_check.result @@ -66,13 +66,14 @@ id id2 value 2 1 2 truncate table t2; connection con1; -set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked1 WAIT_FOR go1'; +set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked1 WAIT_FOR go'; insert into t1 values (1,1); -connection con2; -set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked2 WAIT_FOR go2'; -insert into t2 values (1,1,1); connection default; set debug_sync='now WAIT_FOR parked1'; +connection con2; +set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked2 WAIT_FOR go'; +insert into t2 values (1,1,1); +connection default; set debug_sync='now WAIT_FOR parked2'; connection con3; set session rocksdb_lock_wait_timeout=1; @@ -81,8 +82,7 @@ ERROR HY000: Lock wait timeout exceeded; try restarting transaction insert into t2 values (2,1,2); ERROR HY000: Lock wait timeout exceeded; try restarting transaction connection default; -set debug_sync='now SIGNAL go1'; -set debug_sync='now SIGNAL go2'; +set debug_sync='now SIGNAL go'; connection con1; connection con2; connection default; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/unique_check.test b/storage/rocksdb/mysql-test/rocksdb/t/unique_check.test index 26f34f86f73..e2520388ea7 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/unique_check.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/unique_check.test @@ -102,15 +102,17 @@ truncate table t2; # 4) simulating T1 GetForUpdate() -> T2 GetForUpdate(). T2 should fail with lock wait timeout. connection con1; -set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked1 WAIT_FOR go1'; +set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked1 WAIT_FOR go'; send insert into t1 values (1,1); -connection con2; -set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked2 WAIT_FOR go2'; -send insert into t2 values (1,1,1); - connection default; set debug_sync='now WAIT_FOR parked1'; + +connection con2; +set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked2 WAIT_FOR go'; +send insert into t2 values (1,1,1); + +connection default; set debug_sync='now WAIT_FOR parked2'; connection con3; @@ -121,8 +123,7 @@ insert into t1 values (1,2); insert into t2 values (2,1,2); connection default; -set debug_sync='now SIGNAL go1'; -set debug_sync='now SIGNAL go2'; +set debug_sync='now SIGNAL go'; connection con1; reap; From e9a191837671442260426f256c4c3ab5c073b40a Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 16 Jul 2019 16:50:05 +0300 Subject: [PATCH 11/26] Disable rocksdb.rpl_row_not_found It requires slave_exec_mode='SEMI_STRICT' --- storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def index 45e19bf88e8..7847815c6c9 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def @@ -70,6 +70,8 @@ gap_lock_raise_error: MDEV-11735: MyRocks: Gap Lock detector support show_engine : MariaRocks: MariaDB doesnt support SHOW ENGINE rocksdb TRANSACTION STATUS issue243_transactionStatus: MariaDB doesnt support SHOW ENGINE rocksdb TRANSACTION STATUS rpl_row_not_found : MariaDB doesnt support slave_exec_mode='SEMI_STRICT' +rpl_row_not_found_rc : MariaDB doesnt support slave_exec_mode='SEMI_STRICT' + ddl_high_priority: Needs fractional @@lock_wait_timeout deadlock_tracking : Needs SHOW ENGINE ROCKSDB TRANSACTION STATUS bytes_written: Needs I_S.TABLE_STATISTICS.IO_WRITE_BYTES From a2dc3b94617fd6e3ed9d7d0ea36f8dc845832419 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 16 Jul 2019 17:16:59 +0300 Subject: [PATCH 12/26] Disable rocksdb_rpl.optimize_myrocks_replace_into It requires @@enable_blind_replace which MariaDB doesn't support --- storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def index b0fc68b84b2..05e5ae0ed46 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def @@ -11,6 +11,7 @@ rpl_gtid_rocksdb_sys_header : MariaDB doesn't support printing "RocksDB: Last My singledelete_idempotent_recovery: MariaDB doesn't support --slave-use-idempotent-for-recovery rpl_mts_dependency_unique_key_conflicts: MariaDB doesn't support --slave-use-idempotent-for-recovery rpl_missing_columns_sk_update : Uses log_column_names=ON feature which is only present in FB/MySQL +optimize_myrocks_replace_into: requires @@enable_blind_replace support. ## ## Tests that do not fit MariaDB's test environment (Functional tests only, From 52f6aa1c548b80cb93f9ec49c85adb843f7a5082 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 16 Jul 2019 18:42:19 +0300 Subject: [PATCH 13/26] Disable rocksdb_rpl.rpl_gtid_crash_safe_optimized It uses slave_gtid_info=optimized which is not supported in MariaDB --- storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def index 05e5ae0ed46..2147e3e086d 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def @@ -12,6 +12,7 @@ singledelete_idempotent_recovery: MariaDB doesn't support --slave-use-idempotent rpl_mts_dependency_unique_key_conflicts: MariaDB doesn't support --slave-use-idempotent-for-recovery rpl_missing_columns_sk_update : Uses log_column_names=ON feature which is only present in FB/MySQL optimize_myrocks_replace_into: requires @@enable_blind_replace support. +rpl_gtid_crash_safe_optimized: requires slave_gtid_info=optimized ## ## Tests that do not fit MariaDB's test environment (Functional tests only, From 4e02e502f6f9622a84942fd3329241e790acab66 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 16 Jul 2019 11:33:11 +0200 Subject: [PATCH 14/26] MDEV-18565: Galera mtr-suite fails if galera library is not installed Currently, running mtr with an incorrect (for example, new or obsolete) version of wsrep_provider (for example, with the 26 version of libgalera_smm.so) leads to the failure of tests in several suites with vague error diagnostics. As for the galera_3nodes suite, the mtr also does not effectively check all the prerequisites after merge with MDEV-18426 fixes. For example, tests that using mariabackup do not check for presence of ss and socat/nc. This is due to improper handling of relative paths in mtr scripts. In addition, some tests in different suites can be run without setting the environment variables such as MTR_GALERA_TFMT, XBSTREAM, and so on. To eliminate all these issues, this patch makes the following changes: 1. Added auxiliary wsrep_mtr_check utility (which located in the mysql-test/lib/My/SafeProcess subdirectory), which compares the versions of the wsrep API that used by the server and by the wsrep provider library, and it does this comparison safely, without accessing the API if the versions do not match. 2. All checks related to the presence of mariabackup and utilities that necessary for its operation transferred from the local directories of different mtr suites (from the suite.pm files) to the main suite.pm file. This not only reduces the amount of code and eliminates duplication of identical code fragments, but also avoids problems due to the inability of mtr to consider relative paths to include files when checking skip combinations. 3. Setting the values of auxiliary environment variables that are necessary for Galera, SST scripts and mariabackup (to work properly) is moved to the main mysql-test-run.pl script, so as not to duplicate this code in different suites, and to avoid partial corrections of the same errors for different suites (while other suites remain uncorrected). 4. Fixed duplication of the have_file_key_management.inc and have_filekeymanagement.inc files between different suites, these checks are also transferred to the top level. 5. Added garbd presence check and garbd path variable. https://jira.mariadb.org/browse/MDEV-18565 --- .../include/have_file_key_management.inc | 0 .../have_garbd.inc} | 0 .../have_mariabackup.inc} | 0 mysql-test/include/have_xtrabackup.inc | 4 + mysql-test/lib/My/SafeProcess.pm | 6 + mysql-test/lib/My/SafeProcess/CMakeLists.txt | 10 +- .../lib/My/SafeProcess/wsrep_check_version.c | 123 ++++++++++++++ mysql-test/mysql-test-run.pl | 157 ++++++++++++++++++ mysql-test/suite.pm | 21 +++ .../galera/include/have_filekeymanagement.inc | 3 - mysql-test/suite/galera/suite.pm | 51 +----- .../galera_sst_mariabackup_table_options.test | 2 +- mysql-test/suite/galera_3nodes/suite.pm | 51 +----- .../suite/galera_3nodes/t/galera_garbd.test | 3 +- .../t/galera_innobackupex_backup.test | 2 +- .../t/galera_ipv6_mariabackup.test | 2 +- .../t/galera_ipv6_mariabackup_section.test | 2 +- mysql-test/suite/mariabackup/suite.pm | 19 +-- mysql-test/suite/wsrep/suite.pm | 20 +-- 19 files changed, 336 insertions(+), 140 deletions(-) rename mysql-test/{suite/mariabackup => }/include/have_file_key_management.inc (100%) rename mysql-test/{suite/galera/include/have_mariabackup.inc => include/have_garbd.inc} (100%) rename mysql-test/{suite/galera/include/have_xtrabackup.inc => include/have_mariabackup.inc} (100%) create mode 100644 mysql-test/include/have_xtrabackup.inc create mode 100644 mysql-test/lib/My/SafeProcess/wsrep_check_version.c delete mode 100644 mysql-test/suite/galera/include/have_filekeymanagement.inc diff --git a/mysql-test/suite/mariabackup/include/have_file_key_management.inc b/mysql-test/include/have_file_key_management.inc similarity index 100% rename from mysql-test/suite/mariabackup/include/have_file_key_management.inc rename to mysql-test/include/have_file_key_management.inc diff --git a/mysql-test/suite/galera/include/have_mariabackup.inc b/mysql-test/include/have_garbd.inc similarity index 100% rename from mysql-test/suite/galera/include/have_mariabackup.inc rename to mysql-test/include/have_garbd.inc diff --git a/mysql-test/suite/galera/include/have_xtrabackup.inc b/mysql-test/include/have_mariabackup.inc similarity index 100% rename from mysql-test/suite/galera/include/have_xtrabackup.inc rename to mysql-test/include/have_mariabackup.inc diff --git a/mysql-test/include/have_xtrabackup.inc b/mysql-test/include/have_xtrabackup.inc new file mode 100644 index 00000000000..0dd693f2c63 --- /dev/null +++ b/mysql-test/include/have_xtrabackup.inc @@ -0,0 +1,4 @@ +# +# suite.pm will make sure that all tests including this file +# will be skipped as needed +# diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index 19f2893ea51..87054019759 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -100,6 +100,8 @@ else $bindir = getcwd(); } +our $wsrep_check_version; + # Find the safe process binary or script sub find_bin { if (IS_WIN32PERL or IS_CYGWIN) @@ -119,6 +121,10 @@ sub find_bin { "my_safe_process"); push(@safe_process_cmd, $exe); } + # Wsrep version check utility: + $wsrep_check_version= + my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"], + "wsrep_check_version", NOT_REQUIRED); } diff --git a/mysql-test/lib/My/SafeProcess/CMakeLists.txt b/mysql-test/lib/My/SafeProcess/CMakeLists.txt index a71f5d8ca36..4c3b62fa67e 100644 --- a/mysql-test/lib/My/SafeProcess/CMakeLists.txt +++ b/mysql-test/lib/My/SafeProcess/CMakeLists.txt @@ -14,7 +14,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA - IF (WIN32) +IF (WIN32) ADD_EXECUTABLE(my_safe_process safe_process_win.cc) ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc) TARGET_LINK_LIBRARIES(my_safe_kill dbghelp psapi) @@ -22,6 +22,11 @@ ELSE() ADD_EXECUTABLE(my_safe_process safe_process.cc) ENDIF() +IF(WITH_WSREP) + ADD_EXECUTABLE(wsrep_check_version wsrep_check_version.c) + TARGET_LINK_LIBRARIES(wsrep_check_version ${LIBDL}) +ENDIF() + IF(NOT INSTALL_MYSQLTESTDIR) RETURN() ENDIF() @@ -32,6 +37,9 @@ SET(INSTALL_ARGS ) INSTALL(TARGETS my_safe_process ${INSTALL_ARGS}) +IF(WITH_WSREP) + INSTALL(TARGETS wsrep_check_version ${INSTALL_ARGS}) +ENDIF() IF (WIN32) INSTALL(TARGETS my_safe_kill ${INSTALL_ARGS}) ENDIF() diff --git a/mysql-test/lib/My/SafeProcess/wsrep_check_version.c b/mysql-test/lib/My/SafeProcess/wsrep_check_version.c new file mode 100644 index 00000000000..cec760738be --- /dev/null +++ b/mysql-test/lib/My/SafeProcess/wsrep_check_version.c @@ -0,0 +1,123 @@ +/* Copyright (c) 2009, 2019, MariaDB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ + +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef _WIN32 +#include +#define dlsym(lib, name) GetProcAddress((HMODULE)lib, name) +#define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0) +#define dlclose(lib) FreeLibrary((HMODULE)lib) +#elif defined(HAVE_DLFCN_H) +#include +#else +#define NO_DLL +#endif + +#ifndef NO_DLL + +#include "../../../../wsrep/wsrep_api.h" + +/************************************************************************** + * Library loader + **************************************************************************/ + +static int wsrep_check_iface_version(const char *found, const char *iface_ver) +{ + if (strcmp(found, iface_ver)) { + return ERANGE; + } + return 0; +} + +typedef int (*wsrep_loader_fun)(wsrep_t*); + +static wsrep_loader_fun wsrep_dlf(void *dlh, const char *sym) +{ + union { + wsrep_loader_fun dlfun; + void *obj; + } alias; + alias.obj = dlsym(dlh, sym); + return alias.dlfun; +} + +static int wsrep_check_version_symbol(void *dlh) +{ + char** dlversion = NULL; + dlversion = (char**) dlsym(dlh, "wsrep_interface_version"); + if (dlversion == NULL) + return EINVAL; + return wsrep_check_iface_version(*dlversion, WSREP_INTERFACE_VERSION); +} + +static int wsrep_print_version(void *dlh) +{ + char** dlversion = NULL; + dlversion = (char**) dlsym(dlh, "wsrep_interface_version"); + if (dlversion == NULL) + return EINVAL; + printf("found: %s, need: %s\n", *dlversion, WSREP_INTERFACE_VERSION); + return 0; +} + +int main(int argc, char **argv) +{ + int rc = EINVAL; + void *dlh; + wsrep_loader_fun dlfun; + + if (!(dlh = dlopen(getenv("WSREP_PROVIDER"), RTLD_NOW | RTLD_LOCAL))) { + goto err; + } + + if (!(dlfun = wsrep_dlf(dlh, "wsrep_loader"))) { + goto err; + } + + if (argc < 2 || strcmp(argv[1], "-p")) { + rc = wsrep_check_version_symbol(dlh); + } + else { + rc = wsrep_print_version(dlh); + } + +err: + if (dlh) dlclose(dlh); + + if (rc == 0) + return 0; + else if (rc == ERANGE) + return 2; + else + return 1; +} + +#else + +int main(void) +{ + return 1; +} + +#endif diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3095de2f819..87713fc8208 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -137,6 +137,10 @@ my $opt_start_dirty; my $opt_start_exit; my $start_only; my $file_wsrep_provider; +my $extra_path; +my $mariabackup_path; +my $mariabackup_exe; +my $garbd_exe; our @global_suppressions; @@ -364,6 +368,157 @@ $| = 1; # Automatically flush STDOUT main(); +sub have_wsrep() { + my $wsrep_on= $mysqld_variables{'wsrep-on'}; + return defined $wsrep_on +} + +sub have_wsrep_provider() { + return $file_wsrep_provider ne ""; +} + +sub have_mariabackup() { + return $mariabackup_path ne ""; +} + +sub have_garbd() { + return $garbd_exe ne ""; +} + +sub check_wsrep_version() { + if ($My::SafeProcess::wsrep_check_version ne "") { + system($My::SafeProcess::wsrep_check_version); + return ($? >> 8) == 0; + } + else { + return 0; + } +} + +sub wsrep_version_message() { + if ($My::SafeProcess::wsrep_check_version ne "") { + my $output= `$My::SafeProcess::wsrep_check_version -p`; + if (($? >> 8) == 0) { + $output =~ s/\s+\z//; + return "Wsrep provider version mismatch (".$output.")"; + } + else { + return "Galera library does not contain a version symbol"; + } + } + else { + return "Unable to find a wsrep version check utility"; + } +} + +sub which($) { return `sh -c "command -v $_[0]"` } + +sub check_garbd_support() { + if (defined $ENV{'MTR_GARBD_EXE'}) { + if (mtr_file_exists($ENV{'MTR_GARBD_EXE'}) ne "") { + $garbd_exe= $ENV{'MTR_GARBD_EXE'}; + } else { + mtr_error("MTR_GARBD_EXE env set to an invalid path"); + } + } + else { + my $wsrep_path= dirname($file_wsrep_provider); + $garbd_exe= + mtr_file_exists($wsrep_path."/garb/garbd", + $wsrep_path."/../../bin/garb/garbd"); + if ($garbd_exe ne "") { + $ENV{MTR_GARBD_EXE}= $garbd_exe; + } + } +} + +sub check_wsrep_support() { + if (have_wsrep()) { + mtr_report(" - binaries built with wsrep patch"); + + # ADD scripts to $PATH to that wsrep_sst_* can be found + my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$bindir/scripts", $path_client_bindir; + mtr_error("No SST scripts") unless $spath; + $ENV{PATH}="$spath:$ENV{PATH}"; + + # ADD mysql client library path to path so that wsrep_notify_cmd can find mysql + # client for loading the tables. (Don't assume each machine has mysql install) + my ($cpath) = grep { -f "$_/mysql"; } "$bindir/scripts", $path_client_bindir; + mtr_error("No scritps") unless $cpath; + $ENV{PATH}="$cpath:$ENV{PATH}" unless $cpath eq $spath; + + # ADD my_print_defaults script path to path so that SST scripts can find it + my ($epath) = grep { -f "$_/my_print_defaults"; } "$bindir/extra", $path_client_bindir; + mtr_error("No my_print_defaults") unless $epath; + $ENV{PATH}="$epath:$ENV{PATH}" unless ($epath eq $spath) or + ($epath eq $cpath); + + $extra_path= $epath; + + if (which("socat")) { + $ENV{MTR_GALERA_TFMT}="socat"; + } elsif (which("nc")) { + $ENV{MTR_GALERA_TFMT}="nc"; + } + + # Check whether WSREP_PROVIDER environment variable is set. + if (defined $ENV{'WSREP_PROVIDER'}) { + $file_wsrep_provider= ""; + if ($ENV{'WSREP_PROVIDER'} ne "none") { + if (mtr_file_exists($ENV{'WSREP_PROVIDER'}) ne "") { + $file_wsrep_provider= $ENV{'WSREP_PROVIDER'}; + } else { + mtr_error("WSREP_PROVIDER env set to an invalid path"); + } + check_garbd_support(); + } + # WSREP_PROVIDER is valid; set to a valid path or "none"). + mtr_verbose("WSREP_PROVIDER env set to $ENV{'WSREP_PROVIDER'}"); + } else { + # WSREP_PROVIDER env not defined. Lets try to locate the wsrep provider + # library. + $file_wsrep_provider= + mtr_file_exists("/usr/lib64/galera-3/libgalera_smm.so", + "/usr/lib64/galera/libgalera_smm.so", + "/usr/lib/galera-3/libgalera_smm.so", + "/usr/lib/galera/libgalera_smm.so"); + if ($file_wsrep_provider ne "") { + # wsrep provider library found ! + mtr_verbose("wsrep provider library found : $file_wsrep_provider"); + $ENV{'WSREP_PROVIDER'}= $file_wsrep_provider; + check_garbd_support(); + } else { + mtr_verbose("Could not find wsrep provider library, setting it to 'none'"); + $ENV{'WSREP_PROVIDER'}= "none"; + } + } + } else { + $file_wsrep_provider= ""; + $extra_path= ""; + } +} + +sub check_mariabackup_support() { + $mariabackup_path= ""; + $mariabackup_exe= + mtr_exe_maybe_exists( + "$bindir/extra/mariabackup$opt_vs_config/mariabackup", + "$path_client_bindir/mariabackup"); + if ($mariabackup_exe ne "") { + my ($bpath) = grep { -f "$_/mariabackup"; } "$bindir/extra/mariabackup$opt_vs_config", $path_client_bindir; + $ENV{PATH}="$bpath:$ENV{PATH}" unless $bpath eq $extra_path; + + $mariabackup_path= $bpath; + + $ENV{XTRABACKUP}= $mariabackup_exe; + + $ENV{XBSTREAM}= mtr_exe_maybe_exists( + "$bindir/extra/mariabackup/$opt_vs_config/mbstream", + "$path_client_bindir/mbstream"); + + $ENV{INNOBACKUPEX}= "$mariabackup_exe --innobackupex"; + } +} sub main { $ENV{MTR_PERL}=$^X; @@ -409,6 +564,8 @@ sub main { } check_ssl_support(); check_debug_support(); + check_wsrep_support(); + check_mariabackup_support(); if (!$opt_suites) { $opt_suites= join ',', collect_default_suites(@DEFAULT_SUITES); diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index fe68295340c..ee1eac2794d 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -59,6 +59,27 @@ sub skip_combinations { $skip{'t/plugin_loaderr.test'} = 'needs compiled-in innodb' unless $::mysqld_variables{'innodb'} eq "ON"; + $skip{'include/have_mariabackup.inc'} = 'Need mariabackup' + unless ::have_mariabackup(); + + $skip{'include/have_mariabackup.inc'} = 'Need ss' + unless ::which("ss"); + + $skip{'include/have_mariabackup.inc'} = 'Need socat or nc' + unless $ENV{MTR_GALERA_TFMT}; + + $skip{'include/have_xtrabackup.inc'} = 'Need innobackupex' + unless ::which(innobackupex); + + $skip{'include/have_xtrabackup.inc'} = 'Need socat or nc' + unless $ENV{MTR_GALERA_TFMT}; + + $skip{'include/have_garbd.inc'} = 'Need garbd' + unless ::have_garbd(); + + $skip{'include/have_file_key_management.inc'} = 'Needs file_key_management plugin' + unless $ENV{FILE_KEY_MANAGEMENT_SO}; + # disable tests that use ipv6, if unsupported sub ipv6_ok() { use Socket; diff --git a/mysql-test/suite/galera/include/have_filekeymanagement.inc b/mysql-test/suite/galera/include/have_filekeymanagement.inc deleted file mode 100644 index f5507ca4548..00000000000 --- a/mysql-test/suite/galera/include/have_filekeymanagement.inc +++ /dev/null @@ -1,3 +0,0 @@ -# -# Used in galera/suite.pm to check file key management plugin -# diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index 6e53e6e2e31..f3c04979705 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -6,28 +6,11 @@ use My::Find; return "Not run for embedded server" if $::opt_embedded_server; -return "WSREP is not compiled in" unless defined $::mysqld_variables{'wsrep-on'}; +return "WSREP is not compiled in" if not ::have_wsrep(); -my ($provider) = grep { -f $_ } $ENV{WSREP_PROVIDER}, - "/usr/lib/galera/libgalera_smm.so", - "/usr/lib64/galera/libgalera_smm.so"; +return "No wsrep provider library" unless ::have_wsrep_provider(); -return "No wsrep provider library" unless -f $provider; - -$ENV{WSREP_PROVIDER} = $provider; - -my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$::bindir/scripts", $::path_client_bindir; -return "No SST scripts" unless $spath; - -my ($cpath) = grep { -f "$_/mysql"; } "$::bindir/scripts", $::path_client_bindir; -return "No scritps" unless $cpath; - -my ($epath) = grep { -f "$_/my_print_defaults"; } "$::bindir/extra", $::path_client_bindir; -return "No my_print_defaults" unless $epath; - -my ($bpath) = grep { -f "$_/mariabackup"; } "$::bindir/extra/mariabackup", $::path_client_bindir; - -sub which($) { return `sh -c "command -v $_[0]"` } +return ::wsrep_version_message() unless ::check_wsrep_version(); push @::global_suppressions, ( @@ -84,32 +67,4 @@ push @::global_suppressions, qr(WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to .*), ); -$ENV{PATH}="$epath:$ENV{PATH}"; -$ENV{PATH}="$spath:$ENV{PATH}" unless $epath eq $spath; -$ENV{PATH}="$cpath:$ENV{PATH}" unless $cpath eq $spath; -$ENV{PATH}="$bpath:$ENV{PATH}" unless $bpath eq $spath; - -if (which(socat)) { - $ENV{MTR_GALERA_TFMT}='socat'; -} elsif (which(nc)) { - $ENV{MTR_GALERA_TFMT}='nc'; -} - -sub skip_combinations { - my %skip = (); - $skip{'include/have_filekeymanagement.inc'} = 'needs file_key_management plugin' - unless $ENV{FILE_KEY_MANAGEMENT_SO}; - $skip{'include/have_xtrabackup.inc'} = 'Need innobackupex' - unless which(innobackupex); - $skip{'include/have_xtrabackup.inc'} = 'Need socat or nc' - unless $ENV{MTR_GALERA_TFMT}; - $skip{'include/have_mariabackup.inc'} = 'Need mariabackup' - unless which(mariabackup); - $skip{'include/have_mariabackup.inc'} = 'Need ss' - unless which(ss); - $skip{'include/have_mariabackup.inc'} = 'Need socat or nc' - unless $ENV{MTR_GALERA_TFMT}; - %skip; -} - bless { }; diff --git a/mysql-test/suite/galera/t/galera_sst_mariabackup_table_options.test b/mysql-test/suite/galera/t/galera_sst_mariabackup_table_options.test index 9d4f50f66ee..953a1635559 100644 --- a/mysql-test/suite/galera/t/galera_sst_mariabackup_table_options.test +++ b/mysql-test/suite/galera/t/galera_sst_mariabackup_table_options.test @@ -1,6 +1,6 @@ --source include/big_test.inc --source include/galera_cluster.inc ---source include/have_filekeymanagement.inc +--source include/have_file_key_management.inc --source include/innodb_encrypt_tables.inc --source include/innodb_page_size_small.inc --source include/have_mariabackup.inc diff --git a/mysql-test/suite/galera_3nodes/suite.pm b/mysql-test/suite/galera_3nodes/suite.pm index a7c1bf79c06..4a861f3b9fa 100644 --- a/mysql-test/suite/galera_3nodes/suite.pm +++ b/mysql-test/suite/galera_3nodes/suite.pm @@ -6,30 +6,11 @@ use My::Find; return "Not run for embedded server" if $::opt_embedded_server; -return "WSREP is not compiled in" unless defined $::mysqld_variables{'wsrep-on'}; +return "WSREP is not compiled in" if not ::have_wsrep(); -my ($provider) = grep { -f $_ } $ENV{WSREP_PROVIDER}, - "/usr/lib64/galera-3/libgalera_smm.so", - "/usr/lib64/galera/libgalera_smm.so", - "/usr/lib/galera-3/libgalera_smm.so", - "/usr/lib/galera/libgalera_smm.so"; +return "No wsrep provider library" unless ::have_wsrep_provider(); -return "No wsrep provider library" unless -f $provider; - -$ENV{WSREP_PROVIDER} = $provider; - -my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$::bindir/scripts", $::path_client_bindir; -return "No SST scripts" unless $spath; - -my ($cpath) = grep { -f "$_/mysql"; } "$::bindir/scripts", $::path_client_bindir; -return "No scritps" unless $cpath; - -my ($epath) = grep { -f "$_/my_print_defaults"; } "$::bindir/extra", $::path_client_bindir; -return "No my_print_defaults" unless $epath; - -my ($bpath) = grep { -f "$_/mariabackup"; } "$::bindir/extra/mariabackup", $::path_client_bindir; - -sub which($) { return `sh -c "command -v $_[0]"` } +return ::wsrep_version_message() unless ::check_wsrep_version(); push @::global_suppressions, ( @@ -65,30 +46,4 @@ push @::global_suppressions, qr(WSREP: JOIN message from member .* in non-primary configuration. Ignored.), ); - -$ENV{PATH}="$epath:$ENV{PATH}"; -$ENV{PATH}="$spath:$ENV{PATH}" unless $epath eq $spath; -$ENV{PATH}="$cpath:$ENV{PATH}" unless $cpath eq $spath; -$ENV{PATH}="$bpath:$ENV{PATH}" unless $bpath eq $spath; - -if (which(socat)) { - $ENV{MTR_GALERA_TFMT}='socat'; -} elsif (which(nc)) { - $ENV{MTR_GALERA_TFMT}='nc'; -} - -sub skip_combinations { - my %skip = (); - $skip{'include/have_filekeymanagement.inc'} = 'needs file_key_management plugin' - unless $ENV{FILE_KEY_MANAGEMENT_SO}; - $skip{'suite/galera/include/have_mariabackup.inc'} = 'Need mariabackup' - unless which(mariabackup); - $skip{'suite/galera/include/have_mariabackup.inc'} = 'Need ss' - unless which(ss); - $skip{'suite/galera/include/have_mariabackup.inc'} = 'Need socat or nc' - unless $ENV{MTR_GALERA_TFMT}; - %skip; -} - bless { }; - diff --git a/mysql-test/suite/galera_3nodes/t/galera_garbd.test b/mysql-test/suite/galera_3nodes/t/galera_garbd.test index 2d03e8897b9..3992259c732 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_garbd.test +++ b/mysql-test/suite/galera_3nodes/t/galera_garbd.test @@ -5,6 +5,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/have_garbd.inc --source include/big_test.inc --let $galera_connection_name = node_3 @@ -30,7 +31,7 @@ --echo Starting garbd ... --let $gp1 = `SELECT SUBSTR(@@wsrep_provider_options, LOCATE('base_port =', @@wsrep_provider_options) + LENGTH('base_port = '))` --let $galera_port_1 = `SELECT SUBSTR('$gp1', 1, LOCATE(';', '$gp1') - 1)` ---exec `dirname $WSREP_PROVIDER`/../../bin/garb/garbd --address "gcomm://127.0.0.1:$galera_port_1" --group my_wsrep_cluster --options 'base_port=$galera_port_3' > $MYSQL_TMP_DIR/garbd.log 2>&1 & +--exec $MTR_GARBD_EXE --address "gcomm://127.0.0.1:$galera_port_1" --group my_wsrep_cluster --options 'base_port=$galera_port_3' > $MYSQL_TMP_DIR/garbd.log 2>&1 & --sleep 5 diff --git a/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test b/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test index cd5c020ae38..8dfb4660f3e 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test +++ b/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test @@ -4,7 +4,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc ---source suite/galera/include/have_mariabackup.inc +--source include/have_mariabackup.inc --let $galera_connection_name = node_3 --let $galera_server_number = 3 diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup.test b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup.test index 84c33251c98..8cbd8cf2454 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup.test +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup.test @@ -1,6 +1,6 @@ --source include/galera_cluster.inc --source include/check_ipv6.inc ---source suite/galera/include/have_mariabackup.inc +--source include/have_mariabackup.inc # Confirm that initial handshake happened over ipv6 diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup_section.test b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup_section.test index 95cd1a5bea5..88c399ddb99 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup_section.test +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup_section.test @@ -1,6 +1,6 @@ --source include/galera_cluster.inc --source include/check_ipv6.inc ---source suite/galera/include/have_mariabackup.inc +--source include/have_mariabackup.inc # Confirm that initial handshake happened over ipv6 diff --git a/mysql-test/suite/mariabackup/suite.pm b/mysql-test/suite/mariabackup/suite.pm index 9242bbc051f..14e38d16158 100644 --- a/mysql-test/suite/mariabackup/suite.pm +++ b/mysql-test/suite/mariabackup/suite.pm @@ -7,31 +7,14 @@ use strict; return "Not run for embedded server" if $::opt_embedded_server; -my $mariabackup_exe= -::mtr_exe_maybe_exists( - "$::bindir/extra/mariabackup$::opt_vs_config/mariabackup", - "$::path_client_bindir/mariabackup"); - -return "No mariabackup" if !$mariabackup_exe; - - -$ENV{XTRABACKUP}= $mariabackup_exe; - -$ENV{XBSTREAM}= ::mtr_exe_maybe_exists( - "$::bindir/extra/mariabackup/$::opt_vs_config/mbstream", - "$::path_client_bindir/mbstream"); - -$ENV{INNOBACKUPEX}= "$mariabackup_exe --innobackupex"; +return "No mariabackup" unless ::have_mariabackup(); my $have_qpress = index(`qpress 2>&1`,"Compression") > 0; - sub skip_combinations { my %skip; - $skip{'include/have_file_key_management.inc'} = 'needs file_key_management plugin' unless $ENV{FILE_KEY_MANAGEMENT_SO}; $skip{'compress_qpress.test'}= 'needs qpress executable in PATH' unless $have_qpress; %skip; } bless { }; - diff --git a/mysql-test/suite/wsrep/suite.pm b/mysql-test/suite/wsrep/suite.pm index b6c5bf15ca1..7b3dae7c8c3 100644 --- a/mysql-test/suite/wsrep/suite.pm +++ b/mysql-test/suite/wsrep/suite.pm @@ -6,21 +6,11 @@ use My::Find; return "Not run for embedded server" if $::opt_embedded_server; -return "WSREP is not compiled in" unless defined $::mysqld_variables{'wsrep-on'}; +return "WSREP is not compiled in" unless ::have_wsrep(); -my ($provider) = grep { -f $_ } $ENV{WSREP_PROVIDER}, - "/usr/lib/galera/libgalera_smm.so", - "/usr/lib64/galera/libgalera_smm.so"; +return "No wsrep provider library" unless ::have_wsrep_provider(); -return "No wsrep provider library" unless -f $provider; - -$ENV{WSREP_PROVIDER} = $provider; - -my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$::bindir/scripts", $::path_client_bindir; -return "No SST scripts" unless $spath; - -my ($epath) = grep { -f "$_/my_print_defaults"; } "$::bindir/extra", $::path_client_bindir; -return "No my_print_defaults" unless $epath; +return ::wsrep_version_message() unless ::check_wsrep_version(); push @::global_suppressions, ( @@ -29,8 +19,4 @@ push @::global_suppressions, qr|WSREP: access file\(.*gvwstate.dat\) failed\(No such file or directory\)|, ); -$ENV{PATH}="$epath:$ENV{PATH}"; -$ENV{PATH}="$spath:$ENV{PATH}" unless $epath eq $spath; - bless { }; - From 26b594e4110b4f7e6f2bcfbdb4c87aef65652bc0 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Thu, 18 Jul 2019 11:37:01 +0200 Subject: [PATCH 15/26] Set the garbd_exe variable to empty string to avoid warning about an uninitialized variable when wsrep_provider is not initialized correctly, set to 'none' or when wsrep is switched off --- mysql-test/mysql-test-run.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 87713fc8208..a29ae0b67ae 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -433,6 +433,7 @@ sub check_garbd_support() { } sub check_wsrep_support() { + $garbd_exe= ""; if (have_wsrep()) { mtr_report(" - binaries built with wsrep patch"); From c0eb3a4d9230b0242c48107b8aea8580fce219b5 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Thu, 18 Jul 2019 14:56:39 +0200 Subject: [PATCH 16/26] Fixed dependency checking in some Galera tests --- .gitignore | 1 + mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.test | 1 + .../galera/t/galera_ist_mariabackup_innodb_flush_logs.test | 3 ++- mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup.test | 1 + .../suite/galera_3nodes/t/galera_ipv6_mariabackup_section.test | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2567c41278f..7974a539ee0 100644 --- a/.gitignore +++ b/.gitignore @@ -81,6 +81,7 @@ make_dist.cmake mariadb-*.*.*.tar.gz mariadb-*.*.*/ mysql-test/lib/My/SafeProcess/my_safe_process +mysql-test/lib/My/SafeProcess/wsrep_check_version mysql-test/mtr mysql-test/mysql-test-run mysql-test/var diff --git a/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.test b/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.test index 20f2fb9dea0..c8e053dc2b6 100644 --- a/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.test +++ b/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.test @@ -5,6 +5,7 @@ --source include/big_test.inc --source include/galera_cluster.inc +--source include/have_innodb.inc --source include/have_mariabackup.inc --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_ist_mariabackup_innodb_flush_logs.test b/mysql-test/suite/galera/t/galera_ist_mariabackup_innodb_flush_logs.test index 328b6b7d4de..fd362a26840 100644 --- a/mysql-test/suite/galera/t/galera_ist_mariabackup_innodb_flush_logs.test +++ b/mysql-test/suite/galera/t/galera_ist_mariabackup_innodb_flush_logs.test @@ -6,7 +6,8 @@ --source include/big_test.inc --source include/galera_cluster.inc ---source include/have_xtrabackup.inc +--source include/have_innodb.inc +--source include/have_mariabackup.inc --source suite/galera/include/galera_st_kill_slave.inc --source suite/galera/include/galera_st_kill_slave_ddl.inc diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup.test b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup.test index 8cbd8cf2454..808dad0dbb2 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup.test +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup.test @@ -1,5 +1,6 @@ --source include/galera_cluster.inc --source include/check_ipv6.inc +--source include/have_innodb.inc --source include/have_mariabackup.inc # Confirm that initial handshake happened over ipv6 diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup_section.test b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup_section.test index 88c399ddb99..72f4fde299b 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup_section.test +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mariabackup_section.test @@ -1,5 +1,6 @@ --source include/galera_cluster.inc --source include/check_ipv6.inc +--source include/have_innodb.inc --source include/have_mariabackup.inc # Confirm that initial handshake happened over ipv6 From adbab0d4cd80b10a1176f1ce8561aff3d5875a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 26 Jun 2019 12:07:17 +0300 Subject: [PATCH 17/26] MDEV-13625: Add the test innodb.innodb-wl5980-debug --- .../suite/innodb/r/innodb-wl5980-debug.result | 27 ++++++++++ .../suite/innodb/t/innodb-wl5980-debug.test | 51 +++++++++++++++++++ storage/innobase/fil/fil0fil.cc | 5 ++ storage/xtradb/fil/fil0fil.cc | 5 ++ 4 files changed, 88 insertions(+) create mode 100644 mysql-test/suite/innodb/r/innodb-wl5980-debug.result create mode 100644 mysql-test/suite/innodb/t/innodb-wl5980-debug.test diff --git a/mysql-test/suite/innodb/r/innodb-wl5980-debug.result b/mysql-test/suite/innodb/r/innodb-wl5980-debug.result new file mode 100644 index 00000000000..51cff4393aa --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-wl5980-debug.result @@ -0,0 +1,27 @@ +call mtr.add_suppression("Cannot find space id [0-9]+ in the tablespace memory cache"); +call mtr.add_suppression("Cannot rename table 'test/t1' to 'test/t2' since the dictionary cache already contains 'test/t2'."); +# +# WL5980 Remote tablespace debug error injection tests. +# +CREATE TABLE t1 (a int KEY, b text) ENGINE=Innodb DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir' ; +INSERT INTO t1 VALUES (1, 'tablespace'); +SELECT * FROM t1; +a b +1 tablespace +# +# Test the second injection point in fil_rename_tablespace(). +# Make sure the table is useable after this failure. +# +SET @save_dbug=@@debug_dbug; +SET debug_dbug="+d,fil_rename_tablespace_failure_2"; +RENAME TABLE t1 TO t2; +SET debug_dbug=@save_dbug; +INSERT INTO t1 VALUES (2, 'tablespace'); +SELECT * FROM t1; +a b +1 tablespace +2 tablespace +# +# Cleanup +# +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-wl5980-debug.test b/mysql-test/suite/innodb/t/innodb-wl5980-debug.test new file mode 100644 index 00000000000..2c5e2b48870 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-wl5980-debug.test @@ -0,0 +1,51 @@ +# +# This testcase is to check the various debug injection points +# to make sure error conditions react corectly and acheive +# better code coverage. +# + +# Not supported in embedded +--source include/not_embedded.inc +--source include/have_debug.inc +--source include/have_innodb.inc + +# These messages are expected in the log +call mtr.add_suppression("Cannot find space id [0-9]+ in the tablespace memory cache"); +call mtr.add_suppression("Cannot rename table 'test/t1' to 'test/t2' since the dictionary cache already contains 'test/t2'."); + +# Set up some variables +LET $MYSQL_DATA_DIR = `select @@datadir`; +LET $data_directory_clause = DATA DIRECTORY='$MYSQL_TMP_DIR/alt_dir'; +--enable_query_log + +--echo # +--echo # WL5980 Remote tablespace debug error injection tests. +--echo # + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE t1 (a int KEY, b text) ENGINE=Innodb $data_directory_clause ; +INSERT INTO t1 VALUES (1, 'tablespace'); +SELECT * FROM t1; + +--echo # +--echo # Test the second injection point in fil_rename_tablespace(). +--echo # Make sure the table is useable after this failure. +--echo # +SET @save_dbug=@@debug_dbug; +SET debug_dbug="+d,fil_rename_tablespace_failure_2"; +--disable_result_log +--error ER_ERROR_ON_RENAME +RENAME TABLE t1 TO t2; +--enable_result_log +SET debug_dbug=@save_dbug; +INSERT INTO t1 VALUES (2, 'tablespace'); +SELECT * FROM t1; + +--echo # +--echo # Cleanup +--echo # + +DROP TABLE t1; + +--rmdir $MYSQL_TMP_DIR/alt_dir/test +--rmdir $MYSQL_TMP_DIR/alt_dir diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 8c4e1db6f51..7234a6c4102 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -3216,8 +3216,13 @@ fil_rename_tablespace( space, node, new_name, new_path); if (success) { + DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2", + goto skip_second_rename; ); success = os_file_rename( innodb_file_data_key, old_path, new_path); + DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2", +skip_second_rename: + success = FALSE; ); if (!success) { /* We have to revert the changes we made diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index d3641efc062..254d0954397 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -3262,8 +3262,13 @@ fil_rename_tablespace( space, node, new_name, new_path); if (success) { + DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2", + goto skip_second_rename; ); success = os_file_rename( innodb_file_data_key, old_path, new_path); + DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2", +skip_second_rename: + success = FALSE; ); if (!success) { /* We have to revert the changes we made From 5a22c456049456ee1dfbafd3211953ca6295c572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 18 Jul 2019 14:30:34 +0300 Subject: [PATCH 18/26] MDEV-13626: Add the test innodb.trx_id_future --- .../suite/innodb/r/trx_id_future.result | 11 ++++ mysql-test/suite/innodb/t/trx_id_future.test | 58 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 mysql-test/suite/innodb/r/trx_id_future.result create mode 100644 mysql-test/suite/innodb/t/trx_id_future.test diff --git a/mysql-test/suite/innodb/r/trx_id_future.result b/mysql-test/suite/innodb/r/trx_id_future.result new file mode 100644 index 00000000000..f7dee933319 --- /dev/null +++ b/mysql-test/suite/innodb/r/trx_id_future.result @@ -0,0 +1,11 @@ +# +# Bug #20445525 ADD A CONSISTENCY CHECK AGAINST DB_TRX_ID BEING +# IN THE FUTURE +# +CREATE TABLE t1(a INT) row_format=redundant engine=innoDB; +INSERT INTO t1 VALUES(1); +NOT FOUND /\[Warning\] InnoDB: A transaction id in a record of table `test`\.`t1` is newer than the system-wide maximum/ in mysqld.1.err +call mtr.add_suppression("\\[Warning\\] InnoDB: A transaction id in a record of table `test`\\.`t1` is newer than the system-wide maximum"); +SELECT * FROM t1; +a +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/trx_id_future.test b/mysql-test/suite/innodb/t/trx_id_future.test new file mode 100644 index 00000000000..deba753caca --- /dev/null +++ b/mysql-test/suite/innodb/t/trx_id_future.test @@ -0,0 +1,58 @@ +--echo # +--echo # Bug #20445525 ADD A CONSISTENCY CHECK AGAINST DB_TRX_ID BEING +--echo # IN THE FUTURE +--echo # + +--source include/not_debug.inc +--source include/have_innodb.inc +--source include/not_embedded.inc + +let PAGE_SIZE=`select @@innodb_page_size`; + +CREATE TABLE t1(a INT) row_format=redundant engine=innoDB; +INSERT INTO t1 VALUES(1); + +let MYSQLD_DATADIR=`select @@datadir`; + +--source include/shutdown_mysqld.inc + +perl; +do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; +my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd"; +open(FILE, "+<", $file) || die "Unable to open $file"; +binmode FILE; + +#Seek the the infimum record and get the offset to next record +#Infimum record exist at offset 101 for redundant format +#And offset to the next record is present 2 bytes prior to +#infimum record + +my $ps= $ENV{PAGE_SIZE}; +my $page; +sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n"; +die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; +#In this case the first record should be at offset 135 +die unless unpack("n", substr($page, 99, 2)) == 135; + +substr($page,135+6,6) = "\xff" x 6; + +my $polynomial = 0x82f63b78; # CRC-32C +my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ + mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); +substr($page,0,4)=$ck; +substr($page,$ps-8,4)=$ck; +sysseek(FILE, 3*$ps, 0) || die "Unable to rewind $file\n"; +syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; +close(FILE) || die "Unable to close $file"; +EOF + +--source include/start_mysqld.inc + +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; +let SEARCH_PATTERN= \[Warning\] InnoDB: A transaction id in a record of table `test`\.`t1` is newer than the system-wide maximum; +--source include/search_pattern_in_file.inc + +call mtr.add_suppression("\\[Warning\\] InnoDB: A transaction id in a record of table `test`\\.`t1` is newer than the system-wide maximum"); + +SELECT * FROM t1; +DROP TABLE t1; From eb14806e6c36c126b0e73f5d4d473f6010b05af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 18 Jul 2019 15:01:13 +0300 Subject: [PATCH 19/26] MDEV-13625: Adapt the test innodb-system-table-view --- .../suite/innodb/include/show_i_s_tables.inc | 19 +++ .../innodb/include/show_i_s_tablespaces.inc | 19 +++ .../innodb/r/innodb-system-table-view.result | 153 ++++++++++++++++++ .../innodb/t/innodb-system-table-view.opt | 11 ++ .../innodb/t/innodb-system-table-view.test | 139 ++++++++++++++++ 5 files changed, 341 insertions(+) create mode 100644 mysql-test/suite/innodb/include/show_i_s_tables.inc create mode 100644 mysql-test/suite/innodb/include/show_i_s_tablespaces.inc create mode 100644 mysql-test/suite/innodb/r/innodb-system-table-view.result create mode 100644 mysql-test/suite/innodb/t/innodb-system-table-view.opt create mode 100644 mysql-test/suite/innodb/t/innodb-system-table-view.test diff --git a/mysql-test/suite/innodb/include/show_i_s_tables.inc b/mysql-test/suite/innodb/include/show_i_s_tables.inc new file mode 100644 index 00000000000..5fe34c370c8 --- /dev/null +++ b/mysql-test/suite/innodb/include/show_i_s_tables.inc @@ -0,0 +1,19 @@ +--echo === information_schema.innodb_sys_tables and innodb_sys_tablespaces === +--disable_query_log +--replace_result #P# #p# #SP# #sp# +--replace_regex /FTS_([0-9a-f_]+)([A-Z0-9_]+)/FTS_AUX_\2/ + +SELECT t.name 'Table Name', + s.name 'Tablespace', + t.flag 'Table Flags', + t.n_cols 'Columns', + t.row_format 'Row Format', + t.zip_page_size 'Zip Size' + FROM information_schema.innodb_sys_tables t LEFT JOIN + information_schema.innodb_sys_tablespaces s + ON t.space = s.space + WHERE t.name not like 'SYS_%' + AND t.name NOT LIKE 'mysql/%' + AND t.name NOT LIKE 'sys/%' + ORDER BY t.name; +--enable_query_log diff --git a/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc b/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc new file mode 100644 index 00000000000..c6a4dfc4366 --- /dev/null +++ b/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc @@ -0,0 +1,19 @@ +# This script assumes that the caller did the following; +# LET $MYSQLD_DATADIR = `select @@datadir`; +# LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`; +--echo === information_schema.innodb_sys_tablespaces and innodb_sys_datafiles === +--disable_query_log +--replace_regex /#P#/#p#/ /#SP#/#sp#/ +--replace_result ./ MYSQLD_DATADIR/ $MYSQLD_DATADIR/ MYSQLD_DATADIR/ $MYSQLD_DATADIR MYSQLD_DATADIR/ $MYSQL_TMP_DIR MYSQL_TMP_DIR $INNODB_PAGE_SIZE DEFAULT +SELECT s.name 'Space_Name', + s.page_size 'Page_Size', + s.zip_page_size 'Zip_Size', + s.row_format 'Formats_Permitted', + d.path 'Path' + FROM information_schema.innodb_sys_tablespaces s, + information_schema.innodb_sys_datafiles d + WHERE s.space = d.space + AND s.name NOT LIKE 'mysql/%' + AND s.name NOT LIKE 'sys/%' + ORDER BY s.space; +--enable_query_log diff --git a/mysql-test/suite/innodb/r/innodb-system-table-view.result b/mysql-test/suite/innodb/r/innodb-system-table-view.result new file mode 100644 index 00000000000..ea29e47e27b --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-system-table-view.result @@ -0,0 +1,153 @@ +SELECT table_id INTO @table_stats_id FROM information_schema.innodb_sys_tables +WHERE name = 'mysql/innodb_table_stats'; +SELECT table_id INTO @index_stats_id FROM information_schema.innodb_sys_tables +WHERE name = 'mysql/innodb_index_stats'; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE table_id NOT IN (@table_stats_id, @index_stats_id) ORDER BY table_id; +TABLE_ID NAME FLAG N_COLS SPACE FILE_FORMAT ROW_FORMAT ZIP_PAGE_SIZE +11 SYS_FOREIGN 0 7 0 Antelope Redundant 0 +12 SYS_FOREIGN_COLS 0 7 0 Antelope Redundant 0 +13 SYS_TABLESPACES 0 6 0 Antelope Redundant 0 +14 SYS_DATAFILES 0 5 0 Antelope Redundant 0 +SELECT table_id,pos,mtype,prtype,len,name +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS +WHERE table_id NOT IN (@table_stats_id, @index_stats_id) +ORDER BY table_id, pos; +table_id pos mtype prtype len name +11 0 1 524292 0 ID +11 1 1 524292 0 FOR_NAME +11 2 1 524292 0 REF_NAME +11 3 6 0 4 N_COLS +12 0 1 524292 0 ID +12 1 6 0 4 POS +12 2 1 524292 0 FOR_COL_NAME +12 3 1 524292 0 REF_COL_NAME +13 0 6 0 4 SPACE +13 1 1 524292 0 NAME +13 2 6 0 4 FLAGS +14 0 6 0 4 SPACE +14 1 1 524292 0 PATH +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES +WHERE table_id NOT IN (@table_stats_id, @index_stats_id) ORDER BY index_id; +INDEX_ID NAME TABLE_ID TYPE N_FIELDS PAGE_NO SPACE +# ID_IND # 3 1 # # +# FOR_IND # 0 1 # # +# REF_IND # 0 1 # # +# ID_IND # 3 2 # # +# SYS_TABLESPACES_SPACE # 3 1 # # +# SYS_DATAFILES_SPACE # 3 1 # # +SELECT index_id,pos,name FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS +WHERE name NOT IN ('database_name', 'table_name', 'index_name', 'stat_name') +ORDER BY index_id, pos; +index_id pos name +11 0 ID +12 0 FOR_NAME +13 0 REF_NAME +14 0 ID +14 1 POS +15 0 SPACE +16 0 SPACE +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +CREATE TABLE t_redundant (a INT KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=innodb; +CREATE TABLE t_compact (a INT KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=innodb; +CREATE TABLE t_compressed (a INT KEY, b TEXT) ROW_FORMAT=COMPRESSED ENGINE=innodb KEY_BLOCK_SIZE=2; +CREATE TABLE t_dynamic (a INT KEY, b TEXT) ROW_FORMAT=DYNAMIC ENGINE=innodb; +=== information_schema.innodb_sys_tables and innodb_sys_tablespaces === +Table Name Tablespace Table Flags Columns Row Format Zip Size +test/t_compact test/t_compact 1 5 Compact 0 +test/t_compressed test/t_compressed 37 5 Compressed 2048 +test/t_dynamic test/t_dynamic 33 5 Dynamic 0 +test/t_redundant test/t_redundant 0 5 Redundant 0 +=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles === +Space_Name Page_Size Zip_Size Formats_Permitted Path +test/t_redundant DEFAULT 0 Compact or Redundant MYSQLD_DATADIR/test/t_redundant.ibd +test/t_compact DEFAULT 0 Compact or Redundant MYSQLD_DATADIR/test/t_compact.ibd +test/t_compressed DEFAULT 2048 Compressed MYSQLD_DATADIR/test/t_compressed.ibd +test/t_dynamic DEFAULT 0 Dynamic MYSQLD_DATADIR/test/t_dynamic.ibd +DROP TABLE t_redundant, t_compact, t_compressed, t_dynamic; +SELECT count(*) FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS; +count(*) +6 +CREATE TABLE parent (id INT NOT NULL, +PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE child (id INT, parent_id INT, +INDEX par_ind (parent_id), +CONSTRAINT constraint_test +FOREIGN KEY (parent_id) REFERENCES parent(id) +ON DELETE CASCADE) ENGINE=INNODB; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/constraint_test test/child test/parent 1 1 +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/constraint_test parent_id id 0 +INSERT INTO parent VALUES(1); +SELECT name, num_rows, ref_count +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS +WHERE name LIKE "%parent"; +name num_rows ref_count +test/parent 1 1 +SELECT NAME, FLAG, N_COLS FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name NOT LIKE 'sys/%'; +NAME FLAG N_COLS +SYS_DATAFILES 0 5 +SYS_FOREIGN 0 7 +SYS_FOREIGN_COLS 0 7 +SYS_TABLESPACES 0 6 +mysql/innodb_index_stats 1 11 +mysql/innodb_table_stats 1 9 +test/child 1 5 +test/parent 1 4 +SELECT name, n_fields +from INFORMATION_SCHEMA.INNODB_SYS_INDEXES +WHERE table_id In (SELECT table_id from +INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE "%parent%"); +name n_fields +PRIMARY 1 +SELECT name, n_fields +from INFORMATION_SCHEMA.INNODB_SYS_INDEXES +WHERE table_id In (SELECT table_id from +INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE "%child%"); +name n_fields +GEN_CLUST_INDEX 0 +par_ind 1 +SELECT name, pos, mtype, len +from INFORMATION_SCHEMA.INNODB_SYS_COLUMNS +WHERE table_id In (SELECT table_id from +INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE "%child%"); +name pos mtype len +id 0 6 4 +parent_id 1 6 4 +DROP TABLE child; +DROP TABLE parent; +CREATE TABLE parent (id INT NOT NULL, newid INT NOT NULL, +PRIMARY KEY (id, newid)) ENGINE=INNODB; +CREATE TABLE child (id INT, parent_id INT, +INDEX par_ind (parent_id), +CONSTRAINT constraint_test +FOREIGN KEY (id, parent_id) REFERENCES parent(id, newid) +ON DELETE CASCADE) ENGINE=INNODB; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/constraint_test test/child test/parent 2 1 +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/constraint_test id id 0 +test/constraint_test parent_id newid 1 +INSERT INTO parent VALUES(1, 9); +SELECT * FROM parent WHERE id IN (SELECT id FROM parent); +id newid +1 9 +SELECT name, num_rows, ref_count +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS +WHERE name LIKE "%parent"; +name num_rows ref_count +test/parent 1 2 +DROP TABLE child; +DROP TABLE parent; diff --git a/mysql-test/suite/innodb/t/innodb-system-table-view.opt b/mysql-test/suite/innodb/t/innodb-system-table-view.opt new file mode 100644 index 00000000000..f23741f479e --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-system-table-view.opt @@ -0,0 +1,11 @@ +--innodb +--innodb-sys-tablespaces +--innodb-sys-datafiles +--innodb-sys-tablestats +--innodb-sys-tables +--innodb-sys-columns +--innodb-sys-indexes +--innodb-sys-fields +--innodb-sys-foreign +--innodb-sys-foreign-cols +--innodb-file-format=barracuda diff --git a/mysql-test/suite/innodb/t/innodb-system-table-view.test b/mysql-test/suite/innodb/t/innodb-system-table-view.test new file mode 100644 index 00000000000..e72781d2218 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-system-table-view.test @@ -0,0 +1,139 @@ +# This is the test for Information Schema System Table View +# that displays the InnoDB system table content through +# information schema tables. + +--source include/innodb_page_size_small.inc + +--disable_query_log +SET default_storage_engine=InnoDB; +LET $MYSQLD_DATADIR = `select @@datadir`; +LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`; +--enable_query_log + +# The IDs of mysql.innodb_table_stats and mysql.innodb_index_stats may +# vary depending on whether the tables have been rebuilt +# by previously run tests. +SELECT table_id INTO @table_stats_id FROM information_schema.innodb_sys_tables +WHERE name = 'mysql/innodb_table_stats'; +SELECT table_id INTO @index_stats_id FROM information_schema.innodb_sys_tables +WHERE name = 'mysql/innodb_index_stats'; + +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE table_id NOT IN (@table_stats_id, @index_stats_id) ORDER BY table_id; + +SELECT table_id,pos,mtype,prtype,len,name +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS +WHERE table_id NOT IN (@table_stats_id, @index_stats_id) +ORDER BY table_id, pos; + +--replace_column 1 # 3 # 6 # 7 # +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES +WHERE table_id NOT IN (@table_stats_id, @index_stats_id) ORDER BY index_id; + +SELECT index_id,pos,name FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS +WHERE name NOT IN ('database_name', 'table_name', 'index_name', 'stat_name') +ORDER BY index_id, pos; + +--sorted_result +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +--sorted_result +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; + +CREATE TABLE t_redundant (a INT KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=innodb; +CREATE TABLE t_compact (a INT KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=innodb; +CREATE TABLE t_compressed (a INT KEY, b TEXT) ROW_FORMAT=COMPRESSED ENGINE=innodb KEY_BLOCK_SIZE=2; +CREATE TABLE t_dynamic (a INT KEY, b TEXT) ROW_FORMAT=DYNAMIC ENGINE=innodb; + +--source suite/innodb/include/show_i_s_tables.inc +--source suite/innodb/include/show_i_s_tablespaces.inc + +DROP TABLE t_redundant, t_compact, t_compressed, t_dynamic; + +SELECT count(*) FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS; + +# Create a foreign key constraint, and verify the information +# in INFORMATION_SCHEMA.INNODB_SYS_FOREIGN and +# INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS +CREATE TABLE parent (id INT NOT NULL, + PRIMARY KEY (id)) ENGINE=INNODB; + +CREATE TABLE child (id INT, parent_id INT, + INDEX par_ind (parent_id), + CONSTRAINT constraint_test + FOREIGN KEY (parent_id) REFERENCES parent(id) + ON DELETE CASCADE) ENGINE=INNODB; + +--sorted_result +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; + +--sorted_result +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; + +# Insert a row in the table "parent", and see whether that reflected in +# INNODB_SYS_TABLESTATS +INSERT INTO parent VALUES(1); + +--sorted_result +SELECT name, num_rows, ref_count +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS +WHERE name LIKE "%parent"; + +--sorted_result +SELECT NAME, FLAG, N_COLS FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES + WHERE name NOT LIKE 'sys/%'; + +--sorted_result +SELECT name, n_fields +from INFORMATION_SCHEMA.INNODB_SYS_INDEXES +WHERE table_id In (SELECT table_id from + INFORMATION_SCHEMA.INNODB_SYS_TABLES + WHERE name LIKE "%parent%"); + +--sorted_result +SELECT name, n_fields +from INFORMATION_SCHEMA.INNODB_SYS_INDEXES +WHERE table_id In (SELECT table_id from + INFORMATION_SCHEMA.INNODB_SYS_TABLES + WHERE name LIKE "%child%"); + +--sorted_result +SELECT name, pos, mtype, len +from INFORMATION_SCHEMA.INNODB_SYS_COLUMNS +WHERE table_id In (SELECT table_id from + INFORMATION_SCHEMA.INNODB_SYS_TABLES + WHERE name LIKE "%child%"); + +DROP TABLE child; + +DROP TABLE parent; + +# Create table with 2 columns in the foreign key constraint +CREATE TABLE parent (id INT NOT NULL, newid INT NOT NULL, + PRIMARY KEY (id, newid)) ENGINE=INNODB; + +CREATE TABLE child (id INT, parent_id INT, + INDEX par_ind (parent_id), + CONSTRAINT constraint_test + FOREIGN KEY (id, parent_id) REFERENCES parent(id, newid) + ON DELETE CASCADE) ENGINE=INNODB; + +--sorted_result +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; + +--sorted_result +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; + +INSERT INTO parent VALUES(1, 9); + +# Nested query will open the table handle twice +--sorted_result +SELECT * FROM parent WHERE id IN (SELECT id FROM parent); + +--sorted_result +SELECT name, num_rows, ref_count +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS +WHERE name LIKE "%parent"; + +DROP TABLE child; + +DROP TABLE parent; From f616e2b97fec3a8105c70cd72e80d6ef57f460c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 18 Jul 2019 16:51:16 +0300 Subject: [PATCH 20/26] MDEV-13625: Add innodb.check_ibd_filesize --- .../innodb/r/check_ibd_filesize,32k.rdiff | 25 +++++++++ .../innodb/r/check_ibd_filesize,4k.rdiff | 25 +++++++++ .../innodb/r/check_ibd_filesize,64k.rdiff | 25 +++++++++ .../innodb/r/check_ibd_filesize,8k.rdiff | 25 +++++++++ .../suite/innodb/r/check_ibd_filesize.result | 20 +++++++ .../suite/innodb/t/check_ibd_filesize.test | 53 +++++++++++++++++++ 6 files changed, 173 insertions(+) create mode 100644 mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff create mode 100644 mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff create mode 100644 mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff create mode 100644 mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff create mode 100644 mysql-test/suite/innodb/r/check_ibd_filesize.result create mode 100644 mysql-test/suite/innodb/t/check_ibd_filesize.test diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff new file mode 100644 index 00000000000..d6828e88256 --- /dev/null +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff @@ -0,0 +1,25 @@ +--- check_ibd_filesize.result ++++ check_ibd_filesize.result,32k +@@ -3,18 +3,12 @@ + # SPACE IN 5.7 THAN IN 5.6 + # + CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +-# bytes: 98304 ++# bytes: 196608 + INSERT INTO t1 SELECT * FROM seq_1_to_25000; +-# bytes: 9437184 ++# bytes: 786432 + DROP TABLE t1; + CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; +-# bytes: 98304 ++# bytes: 196608 + INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; +-# bytes: 2097152 +-DROP TABLE t1; +-CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) +-ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +-# bytes: 65536 +-INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; +-# bytes: 65536 ++# bytes: 786432 + DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff new file mode 100644 index 00000000000..0aeb3ebcaee --- /dev/null +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff @@ -0,0 +1,25 @@ +--- check_ibd_filesize.result ++++ check_ibd_filesize.result,4k +@@ -3,18 +3,18 @@ + # SPACE IN 5.7 THAN IN 5.6 + # + CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +-# bytes: 98304 ++# bytes: 24576 + INSERT INTO t1 SELECT * FROM seq_1_to_25000; + # bytes: 9437184 + DROP TABLE t1; + CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; +-# bytes: 98304 ++# bytes: 24576 + INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; + # bytes: 2097152 + DROP TABLE t1; + CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) + ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +-# bytes: 65536 ++# bytes: 16384 + INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; +-# bytes: 65536 ++# bytes: 25600 + DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff new file mode 100644 index 00000000000..410707991d1 --- /dev/null +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff @@ -0,0 +1,25 @@ +--- check_ibd_filesize.result ++++ check_ibd_filesize.result,64k +@@ -3,18 +3,12 @@ + # SPACE IN 5.7 THAN IN 5.6 + # + CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +-# bytes: 98304 ++# bytes: 393216 + INSERT INTO t1 SELECT * FROM seq_1_to_25000; +-# bytes: 9437184 ++# bytes: 983040 + DROP TABLE t1; + CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; +-# bytes: 98304 ++# bytes: 393216 + INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; +-# bytes: 2097152 +-DROP TABLE t1; +-CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) +-ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +-# bytes: 65536 +-INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; +-# bytes: 65536 ++# bytes: 1572864 + DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff new file mode 100644 index 00000000000..f1d79846c2a --- /dev/null +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff @@ -0,0 +1,25 @@ +--- check_ibd_filesize.result ++++ check_ibd_filesize.result,8k +@@ -3,18 +3,18 @@ + # SPACE IN 5.7 THAN IN 5.6 + # + CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +-# bytes: 98304 ++# bytes: 49152 + INSERT INTO t1 SELECT * FROM seq_1_to_25000; + # bytes: 9437184 + DROP TABLE t1; + CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; +-# bytes: 98304 ++# bytes: 49152 + INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; + # bytes: 2097152 + DROP TABLE t1; + CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) + ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +-# bytes: 65536 ++# bytes: 32768 + INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; +-# bytes: 65536 ++# bytes: 32768 + DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize.result b/mysql-test/suite/innodb/r/check_ibd_filesize.result new file mode 100644 index 00000000000..9465c3a3115 --- /dev/null +++ b/mysql-test/suite/innodb/r/check_ibd_filesize.result @@ -0,0 +1,20 @@ +# +# Bug #21950389 SMALL TABLESPACES WITH BLOBS TAKE UP TO 80 TIMES MORE +# SPACE IN 5.7 THAN IN 5.6 +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +# bytes: 98304 +INSERT INTO t1 SELECT * FROM seq_1_to_25000; +# bytes: 9437184 +DROP TABLE t1; +CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; +# bytes: 98304 +INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; +# bytes: 2097152 +DROP TABLE t1; +CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +# bytes: 65536 +INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; +# bytes: 65536 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/check_ibd_filesize.test b/mysql-test/suite/innodb/t/check_ibd_filesize.test new file mode 100644 index 00000000000..92f9061a3f6 --- /dev/null +++ b/mysql-test/suite/innodb/t/check_ibd_filesize.test @@ -0,0 +1,53 @@ +--source include/innodb_page_size.inc +--source include/have_sequence.inc + +--echo # +--echo # Bug #21950389 SMALL TABLESPACES WITH BLOBS TAKE UP TO 80 TIMES MORE +--echo # SPACE IN 5.7 THAN IN 5.6 +--echo # + +# +# Table 1: small rows +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +let MYSQLD_DATADIR=`select @@datadir`; +perl; +print "# bytes: ", (-s "$ENV{MYSQLD_DATADIR}/test/t1.ibd"), "\n"; +EOF + +INSERT INTO t1 SELECT * FROM seq_1_to_25000; +perl; +print "# bytes: ", (-s "$ENV{MYSQLD_DATADIR}/test/t1.ibd"), "\n"; +EOF +DROP TABLE t1; + +# +# Table 2: BLOB +# +CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; +perl; +print "# bytes: ", (-s "$ENV{MYSQLD_DATADIR}/test/t1.ibd"), "\n"; +EOF +INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; +perl; +print "# bytes: ", (-s "$ENV{MYSQLD_DATADIR}/test/t1.ibd"), "\n"; +EOF +DROP TABLE t1; + +let $page_size=`SELECT @@innodb_page_size`; +if ($page_size < 32768) +{ +# +# Table 3: compressed BLOB +# +CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) +ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +perl; +print "# bytes: ", (-s "$ENV{MYSQLD_DATADIR}/test/t1.ibd"), "\n"; +EOF +INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; +perl; +print "# bytes: ", (-s "$ENV{MYSQLD_DATADIR}/test/t1.ibd"), "\n"; +EOF +DROP TABLE t1; +} From 5b205458d9bc9b838ab7725d9f8e2f45b743e385 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 18 Jul 2019 22:28:11 +0300 Subject: [PATCH 21/26] MDEV-20097 potential use-after-free row_merge_read_clustered_index(): make buf always equals to merge_buf[i] --- storage/innobase/row/row0merge.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 463be8d229d..ac7eddfedbb 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -1916,6 +1916,7 @@ write_buffers: UNIV_MEM_INVALID(&block[0], srv_sort_buf_size); merge_buf[i] = row_merge_buf_empty(buf); + buf = merge_buf[i]; if (UNIV_LIKELY(row != NULL)) { /* Try writing the record again, now From a24e824cc420e4b666f5fb97a51d94d6deeea829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 18 Jul 2019 23:24:13 +0300 Subject: [PATCH 22/26] MDEV-20097: Also fix XtraDB --- storage/xtradb/row/row0merge.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index f71a623da20..a79a766bcaf 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -1929,6 +1929,7 @@ write_buffers: UNIV_MEM_INVALID(&block[0], srv_sort_buf_size); merge_buf[i] = row_merge_buf_empty(buf); + buf = merge_buf[i]; if (UNIV_LIKELY(row != NULL)) { /* Try writing the record again, now From 864f0005f9370aadc361e767df335a8c9d814c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 18 Jul 2019 23:26:52 +0300 Subject: [PATCH 23/26] MDEV-20094: Disable innodb.check_ibd_filesize The results are nondeterministic on MariaDB Server 10.1. --- mysql-test/suite/innodb/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/innodb/disabled.def b/mysql-test/suite/innodb/disabled.def index 8cae44a3607..78bc167c561 100644 --- a/mysql-test/suite/innodb/disabled.def +++ b/mysql-test/suite/innodb/disabled.def @@ -10,3 +10,4 @@ # ############################################################################## +check_ibd_filesize : MDEV-20094 result differences From 4aa97ba5944f4afe751525e68b77100b1aa51524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 19 Jul 2019 09:48:17 +0300 Subject: [PATCH 24/26] Fix innodb-system-table-view for --embedded --- mysql-test/suite/innodb/include/show_i_s_tablespaces.inc | 2 +- mysql-test/suite/innodb/t/innodb-system-table-view.test | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc b/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc index c6a4dfc4366..a3755f8657a 100644 --- a/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc +++ b/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc @@ -4,7 +4,7 @@ --echo === information_schema.innodb_sys_tablespaces and innodb_sys_datafiles === --disable_query_log --replace_regex /#P#/#p#/ /#SP#/#sp#/ ---replace_result ./ MYSQLD_DATADIR/ $MYSQLD_DATADIR/ MYSQLD_DATADIR/ $MYSQLD_DATADIR MYSQLD_DATADIR/ $MYSQL_TMP_DIR MYSQL_TMP_DIR $INNODB_PAGE_SIZE DEFAULT +--replace_result ./ MYSQLD_DATADIR/ $MYSQLD_DATADIR MYSQLD_DATADIR $MYSQL_TMP_DIR MYSQL_TMP_DIR $INNODB_PAGE_SIZE DEFAULT SELECT s.name 'Space_Name', s.page_size 'Page_Size', s.zip_page_size 'Zip_Size', diff --git a/mysql-test/suite/innodb/t/innodb-system-table-view.test b/mysql-test/suite/innodb/t/innodb-system-table-view.test index e72781d2218..087c0a22eca 100644 --- a/mysql-test/suite/innodb/t/innodb-system-table-view.test +++ b/mysql-test/suite/innodb/t/innodb-system-table-view.test @@ -4,11 +4,8 @@ --source include/innodb_page_size_small.inc ---disable_query_log -SET default_storage_engine=InnoDB; LET $MYSQLD_DATADIR = `select @@datadir`; LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`; ---enable_query_log # The IDs of mysql.innodb_table_stats and mysql.innodb_index_stats may # vary depending on whether the tables have been rebuilt From 9c29d068627313d29621adc53be4620e8257e805 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Fri, 19 Jul 2019 11:42:08 +0300 Subject: [PATCH 25/26] MDEV-20097 potential use-after-free row_merge_read_clustered_index(): fix one more place with buf and merge_buf[i] --- storage/innobase/row/row0merge.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 0fd981a5e66..3783b926efa 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -2431,6 +2431,7 @@ write_buffers: BTR_SEARCH_LEAF, &pcur, &mtr); buf = row_merge_buf_empty(buf); + merge_buf[i] = buf; /* Restart the outer loop on the record. We did not insert it into any index yet. */ From 059968dc5dbe834a9c7119b282d7c63a1261b44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 19 Jul 2019 11:42:34 +0300 Subject: [PATCH 26/26] Remove a conditionally unused declaration The embedded server does not HAVE_PSI_STAGE_INTERFACE. --- storage/maria/ha_maria.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 23de1508b05..51839aa5ff4 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -355,10 +355,12 @@ static PSI_file_info all_aria_files[]= { &key_file_control, "control", PSI_FLAG_GLOBAL} }; +# ifdef HAVE_PSI_STAGE_INTERFACE static PSI_stage_info *all_aria_stages[]= { & stage_waiting_for_a_resource }; +# endif /* HAVE_PSI_STAGE_INTERFACE */ static void init_aria_psi_keys(void) { @@ -379,9 +381,10 @@ static void init_aria_psi_keys(void) count= array_elements(all_aria_files); mysql_file_register(category, all_aria_files, count); - +# ifdef HAVE_PSI_STAGE_INTERFACE count= array_elements(all_aria_stages); mysql_stage_register(category, all_aria_stages, count); +# endif /* HAVE_PSI_STAGE_INTERFACE */ } #else #define init_aria_psi_keys() /* no-op */