diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 9caf9d58db795..730306138be32 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1484,7 +1484,12 @@ int main(int argc, char **argv) open_mysql_upgrade_file(); if (opt_check_upgrade) - exit(upgrade_already_done(0) == 0); + { + int upgrade_needed = upgrade_already_done(0); + free_used_memory(); + my_end(my_end_arg); + exit(upgrade_needed == 0); + } /* Find mysqlcheck */ find_tool(mysqlcheck_path, IF_WIN("mariadb-check.exe", "mariadb-check"), self_name); diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 9d5738b132a1b..89eab6b7a356a 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -91,6 +91,8 @@ static my_bool non_blocking_api_enabled= 0; #define CLOSED_CONNECTION "-closed_connection-" +#define dynstr_append DO_NO_USE + #ifndef HAVE_SETENV static int setenv(const char *name, const char *value, int overwrite); #endif @@ -1878,7 +1880,7 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...) if (strncmp(arg, "--", 2) == 0) dynstr_append_os_quoted(&ds_cmdline, arg, NullS); else - dynstr_append(&ds_cmdline, arg); + dynstr_append_mem(&ds_cmdline, arg, strlen(arg)); dynstr_append_mem(&ds_cmdline, STRING_WITH_LEN(" ")); } @@ -2035,11 +2037,11 @@ void show_diff(DYNAMIC_STRING* ds, dynstr_append_mem(&ds_tmp, message, sizeof(message)); dynstr_append_mem(&ds_tmp, STRING_WITH_LEN(" --- ")); - dynstr_append(&ds_tmp, filename1); + dynstr_append_mem(&ds_tmp, filename1, strlen(filename1)); dynstr_append_mem(&ds_tmp, STRING_WITH_LEN(" >>>\n")); cat_file(&ds_tmp, filename1); dynstr_append_mem(&ds_tmp, STRING_WITH_LEN("<<<\n --- ")); - dynstr_append(&ds_tmp, filename1); + dynstr_append_mem(&ds_tmp, filename1, strlen(filename1)); dynstr_append_mem(&ds_tmp, STRING_WITH_LEN(" >>>\n")); cat_file(&ds_tmp, filename2); dynstr_append_mem(&ds_tmp, STRING_WITH_LEN("<<<<\n")); @@ -3295,13 +3297,15 @@ static int replace(DYNAMIC_STRING *ds_str, { DYNAMIC_STRING ds_tmp; const char *start= strstr(ds_str->str, search_str); + size_t prefixlen= start - ds_str->str; if (!start) return 1; init_dynamic_string(&ds_tmp, "", ds_str->length + replace_len, 256); - dynstr_append_mem(&ds_tmp, ds_str->str, start - ds_str->str); + dynstr_append_mem(&ds_tmp, ds_str->str, prefixlen); dynstr_append_mem(&ds_tmp, replace_str, replace_len); - dynstr_append(&ds_tmp, start + search_len); + dynstr_append_mem(&ds_tmp, start + search_len, + ds_str->length - prefixlen - search_len); dynstr_set(ds_str, ds_tmp.str); dynstr_free(&ds_tmp); return 0; @@ -3806,7 +3810,7 @@ void do_remove_files_wildcard(struct st_command *command) wild_compare(file->name, ds_wild.str, 0)) continue; ds_file_to_remove.length= directory_length; - dynstr_append(&ds_file_to_remove, file->name); + dynstr_append_mem(&ds_file_to_remove, file->name, strlen(file->name)); DBUG_PRINT("info", ("removing file: %s", ds_file_to_remove.str)); if ((error= (my_delete(ds_file_to_remove.str, MYF(MY_WME)) != 0))) sys_errno= my_errno; @@ -7679,7 +7683,7 @@ void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field, } else { - dynstr_append(ds, field->name); + dynstr_append_mem(ds, field->name, strlen(field->name)); dynstr_append_mem(ds, "\t", 1); replace_dynstr_append_mem(ds, val, len); dynstr_append_mem(ds, "\n", 1); @@ -7852,12 +7856,12 @@ void append_info(DYNAMIC_STRING *ds, ulonglong affected_rows, const char *info) { char buf[40], buff2[21]; - sprintf(buf,"affected rows: %s\n", llstr(affected_rows, buff2)); - dynstr_append(ds, buf); + size_t len= sprintf(buf,"affected rows: %s\n", llstr(affected_rows, buff2)); + dynstr_append_mem(ds, buf, len); if (info) { dynstr_append_mem(ds, STRING_WITH_LEN("info: ")); - dynstr_append(ds, info); + dynstr_append_mem(ds, info, strlen(info)); dynstr_append_mem(ds, STRING_WITH_LEN("\n")); } } @@ -7907,7 +7911,8 @@ static void append_session_track_info(DYNAMIC_STRING *ds, MYSQL *mysql) dynstr_append_mem(ds, STRING_WITH_LEN("-- ")); if (type <= SESSION_TRACK_END) { - dynstr_append(ds, trking_info_desc[type]); + dynstr_append_mem(ds, trking_info_desc[type], + strlen(trking_info_desc[type])); } else { @@ -9800,7 +9805,7 @@ void mark_progress(struct st_command* command __attribute__((unused)), dynstr_append_mem(&ds_progress, "\t", 1); /* Filename */ - dynstr_append(&ds_progress, cur_file->file_name); + dynstr_append_mem(&ds_progress, cur_file->file_name, strlen(cur_file->file_name)); dynstr_append_mem(&ds_progress, ":", 1); /* Line in file */ @@ -12100,7 +12105,7 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input, for (i= 0; i < lines.elements ; i++) { const char **line= dynamic_element(&lines, i, const char**); - dynstr_append(ds, *line); + dynstr_append_mem(ds, *line, strlen(*line)); dynstr_append_mem(ds, STRING_WITH_LEN("\n")); } diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 66e26def00506..f770efe946827 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -1709,8 +1709,11 @@ struct my_option xb_server_options[] = "Path to InnoDB log files.", &srv_log_group_home_dir, &srv_log_group_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT, - "Percentage of dirty pages allowed in bufferpool.", (G_PTR*) &srv_max_buf_pool_modified_pct, - (G_PTR*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0, 0, 0}, + "Percentage of dirty pages allowed in bufferpool.", + (G_PTR*) &srv_max_buf_pool_modified_pct, + (G_PTR*) &srv_max_buf_pool_modified_pct, 0, GET_DOUBLE, REQUIRED_ARG, + (longlong)getopt_double2ulonglong(90), (longlong)getopt_double2ulonglong(0), + getopt_double2ulonglong(100), 0, 0, 0}, {"innodb_use_native_aio", OPT_INNODB_USE_NATIVE_AIO, "Use native AIO if supported on this platform.", (G_PTR*) &srv_use_native_aio, diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index 6fc9f3f4d9b22..c15752aa23e6b 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -170,6 +170,7 @@ int main(int argc, char **argv) if ((error= load_defaults(config_file, (const char **) load_default_groups, &count, &arguments))) { + my_free(load_default_groups); my_end(0); if (error == 4) return 0; diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index 81a0165ab039e..2fbb6da2d03e5 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -891,5 +891,20 @@ SELECT * FROM t1 JOIN t2 WHERE (t1.a, t2.b) IN (SELECT * FROM v); a b DROP VIEW v; DROP TABLE t1, t2, t3; +# +# MDEV-31279 Crash when lateral derived is guaranteed to return no rows +# +CREATE TABLE t1 (a CHAR(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('1'),('2'); +CREATE TABLE t2 (b INT, KEY(b)) ENGINE=MyISAM; +ALTER TABLE t2 DISABLE KEYS; +INSERT INTO t2 VALUES (1),(2),(3); +ALTER TABLE t2 ENABLE KEYS; +CREATE TABLE t3 (c INT) ENGINE=MyISAM; +INSERT INTO t3 (c) SELECT seq FROM seq_1_to_101; +SELECT * FROM t1 WHERE t1.a IN (SELECT b FROM +(SELECT t2.b FROM t2 WHERE NOT EXISTS (SELECT 1 FROM t3) GROUP BY b) sq); +a +DROP TABLE t1, t2, t3; # End of 10.4 tests SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent; diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index af38a8d71abf1..acd7674786a1d 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -499,6 +499,24 @@ SELECT * FROM t1 JOIN t2 WHERE (t1.a, t2.b) IN (SELECT * FROM v); DROP VIEW v; DROP TABLE t1, t2, t3; +--echo # +--echo # MDEV-31279 Crash when lateral derived is guaranteed to return no rows +--echo # + +CREATE TABLE t1 (a CHAR(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('1'),('2'); +CREATE TABLE t2 (b INT, KEY(b)) ENGINE=MyISAM; +ALTER TABLE t2 DISABLE KEYS; +INSERT INTO t2 VALUES (1),(2),(3); +ALTER TABLE t2 ENABLE KEYS; +CREATE TABLE t3 (c INT) ENGINE=MyISAM; +INSERT INTO t3 (c) SELECT seq FROM seq_1_to_101; + +SELECT * FROM t1 WHERE t1.a IN (SELECT b FROM + (SELECT t2.b FROM t2 WHERE NOT EXISTS (SELECT 1 FROM t3) GROUP BY b) sq); + +DROP TABLE t1, t2, t3; + --echo # End of 10.4 tests SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent; diff --git a/mysql-test/main/mysql_upgrade.result b/mysql-test/main/mysql_upgrade.result index 5913c5b3abab3..717b3cd6354fa 100644 --- a/mysql-test/main/mysql_upgrade.result +++ b/mysql-test/main/mysql_upgrade.result @@ -2505,6 +2505,14 @@ Phase 7/8: uninstalling plugins Phase 8/8: Running 'FLUSH PRIVILEGES' OK set global sql_safe_updates=@orig_sql_safe_updates; +# +# MDEV-32043 Remove plugins previously external that are now built in (unix_socket) +# +INSERT INTO mysql.plugin SELECT 'unix_socket', 'auth_socket.so' + FROM dual WHERE convert(@@version_compile_os using latin1) not in ('Win32', 'Win64', 'Windows'); +# mariadb-upgrade --force --silent 2>&1 +SELECT * FROM mysql.plugin WHERE name='unix_socket'; +name dl # End of 10.4 tests # # Check that mysql_upgrade can be run on mysqldump diff --git a/mysql-test/main/mysql_upgrade.test b/mysql-test/main/mysql_upgrade.test index 3145d58b18c20..42efb4174d805 100644 --- a/mysql-test/main/mysql_upgrade.test +++ b/mysql-test/main/mysql_upgrade.test @@ -517,6 +517,17 @@ set global sql_safe_updates=ON; --remove_file $MYSQLD_DATADIR/mariadb_upgrade_info set global sql_safe_updates=@orig_sql_safe_updates; +--echo # +--echo # MDEV-32043 Remove plugins previously external that are now built in (unix_socket) +--echo # + +INSERT INTO mysql.plugin SELECT 'unix_socket', 'auth_socket.so' + FROM dual WHERE convert(@@version_compile_os using latin1) not in ('Win32', 'Win64', 'Windows'); +--echo # mariadb-upgrade --force --silent 2>&1 +--exec $MYSQL_UPGRADE --force --silent 2>&1 +SELECT * FROM mysql.plugin WHERE name='unix_socket'; +--remove_file $MYSQLD_DATADIR/mariadb_upgrade_info + --echo # End of 10.4 tests # diff --git a/mysql-test/main/mysql_upgrade_file_leak.result b/mysql-test/main/mysql_upgrade_file_leak.result new file mode 100644 index 0000000000000..648a0c97802a0 --- /dev/null +++ b/mysql-test/main/mysql_upgrade_file_leak.result @@ -0,0 +1,4 @@ +Running mysql_upgrade with --check-if-upgrade-is-needed +Checking for absence of temporary files by mysql_upgrade +No temporary files found +End of 10.4 tests diff --git a/mysql-test/main/mysql_upgrade_file_leak.test b/mysql-test/main/mysql_upgrade_file_leak.test new file mode 100644 index 0000000000000..7f1a049516156 --- /dev/null +++ b/mysql-test/main/mysql_upgrade_file_leak.test @@ -0,0 +1,24 @@ +-- source include/mysql_upgrade_preparation.inc + +# +# MDEV-31925 mysqld_upgrade --check-if-upgrade-is-needed leaks files +# + +# Run mysql_upgrade with --check-if-upgrade-is-needed +--echo Running mysql_upgrade with --check-if-upgrade-is-needed +--exec $MYSQL_UPGRADE --check-if-upgrade-is-needed 2>&1 + +# Check if temporary files related to mysql_upgrade are cleared +--echo Checking for absence of temporary files by mysql_upgrade +--perl + +# Use the temporary directory path from the MySQL configuration +my $tmpdir = "$ENV{MYSQL_TMP_DIR}"; + +die "Test failed: Found temporary file left by mysql_upgrade\n" if (glob("$tmpdir/mysql_upgrade-*")); +print "No temporary files found\n"; +EOF + +let $MYSQLD_DATADIR= `select @@datadir`; +--remove_file $MYSQLD_DATADIR/mariadb_upgrade_info +--echo End of 10.4 tests diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index 6065be96070b3..501a8b8c3d45e 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -5798,5 +5798,15 @@ END; $ ERROR 42000: EXECUTE..USING does not support subqueries or stored functions # +# MDEV-32965: Assertion `thd->active_stmt_arena_to_use()-> is_stmt_prepare_or_first_sp_execute() || thd->active_stmt_arena_to_use()-> is_conventional() || thd->active_stmt_arena_to_use()->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed +# +CREATE TABLE t (f VARCHAR(8)) CHARACTER SET utf8; +INSERT INTO t VALUES ('foo'),('bar'); +EXECUTE IMMEDIATE 'SELECT GROUP_CONCAT(@x) FROM t GROUP BY @x := f'; +GROUP_CONCAT(@x) +0 +0 +DROP TABLE t; +# # End of 10.4 tests # diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test index 0043d3aa1410c..675c510286d42 100644 --- a/mysql-test/main/ps.test +++ b/mysql-test/main/ps.test @@ -5236,6 +5236,18 @@ $ delimiter ;$ +--echo # +--echo # MDEV-32965: Assertion `thd->active_stmt_arena_to_use()-> is_stmt_prepare_or_first_sp_execute() || thd->active_stmt_arena_to_use()-> is_conventional() || thd->active_stmt_arena_to_use()->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed +--echo # +CREATE TABLE t (f VARCHAR(8)) CHARACTER SET utf8; + +INSERT INTO t VALUES ('foo'),('bar'); +EXECUTE IMMEDIATE 'SELECT GROUP_CONCAT(@x) FROM t GROUP BY @x := f'; + +# Cleanup + +DROP TABLE t; + --echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/std_data/mysql80/t2.cfg b/mysql-test/std_data/mysql80/t2.cfg new file mode 100644 index 0000000000000..81f92978393cb Binary files /dev/null and b/mysql-test/std_data/mysql80/t2.cfg differ diff --git a/mysql-test/std_data/mysql80/t2.ibd b/mysql-test/std_data/mysql80/t2.ibd new file mode 100644 index 0000000000000..be2b46a7af1d5 Binary files /dev/null and b/mysql-test/std_data/mysql80/t2.ibd differ diff --git a/mysql-test/suite/binlog_encryption/rpl_gtid_basic.result b/mysql-test/suite/binlog_encryption/rpl_gtid_basic.result index 2bdfe0b1c528f..fde3703645a56 100644 --- a/mysql-test/suite/binlog_encryption/rpl_gtid_basic.result +++ b/mysql-test/suite/binlog_encryption/rpl_gtid_basic.result @@ -188,6 +188,13 @@ BINLOG_GTID_POS('master-bin.000001',18446744073709551616) NULL Warnings: Warning 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated +SET sql_log_bin= 0; +CREATE TABLE t1 AS SELECT MASTER_POS_WAIT(@binlog_file, 4, 0); +SELECT BINLOG_GTID_POS(@binlog_file, 4); +BINLOG_GTID_POS(@binlog_file, 4) +NULL +DROP TABLE t1; +SET sql_log_bin= 1; *** Some tests of @@GLOBAL.gtid_binlog_state *** connection server_2; include/sync_with_master_gtid.inc diff --git a/mysql-test/suite/encryption/r/innodb_encrypt_temporary_tables.result b/mysql-test/suite/encryption/r/innodb_encrypt_temporary_tables.result index 541680ae862a3..d86ca6f9c0032 100644 --- a/mysql-test/suite/encryption/r/innodb_encrypt_temporary_tables.result +++ b/mysql-test/suite/encryption/r/innodb_encrypt_temporary_tables.result @@ -1,6 +1,8 @@ -SELECT variable_value into @old_encrypted FROM information_schema.global_status +SELECT CAST(variable_value AS INT) INTO @old_encrypted +FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_temp_blocks_encrypted'; -SELECT variable_value into @old_decrypted FROM information_schema.global_status +SELECT CAST(variable_value AS INT) INTO @old_decrypted +FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_temp_blocks_decrypted'; CREATE TEMPORARY TABLE t1(f1 CHAR(200), f2 CHAR(200)) ENGINE=InnoDB; INSERT INTO t1 (f1,f2) SELECT '', '' FROM seq_1_to_8192; @@ -12,11 +14,13 @@ COUNT(*) SELECT COUNT(*) FROM t2; COUNT(*) 8192 -SELECT variable_value > @old_encrypted FROM information_schema.global_status +SELECT CAST(variable_value AS INT) > @old_encrypted +FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_temp_blocks_encrypted'; -variable_value > @old_encrypted +CAST(variable_value AS INT) > @old_encrypted 1 -SELECT variable_value > @old_decrypted FROM information_schema.global_status +SELECT CAST(variable_value AS INT) > @old_decrypted +FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_temp_blocks_decrypted'; -variable_value > @old_decrypted +CAST(variable_value AS INT) > @old_decrypted 1 diff --git a/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result b/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result index 7ee30423fe7a7..18082027660ec 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result +++ b/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result @@ -13,11 +13,13 @@ set current_num = current_num + 1; end while; end// commit; -set autocommit=0; -call innodb_insert_proc(10000); +begin; +set statement unique_checks=0, foreign_key_checks=0 for +call innodb_insert_proc(100); commit; -set autocommit=1; +DROP PROCEDURE innodb_insert_proc; # Wait max 10 min for key encryption threads to encrypt all spaces +FLUSH TABLES t1, t2, t3 FOR EXPORT; # tablespaces should be now encrypted # t1 yes on expecting NOT FOUND NOT FOUND /foobar/ in t1.ibd @@ -25,15 +27,16 @@ NOT FOUND /foobar/ in t1.ibd NOT FOUND /temp/ in t2.ibd # t3 ... on expecting NOT FOUND NOT FOUND /barfoo/ in t3.ibd -# restart db.opt +t1.cfg t1.frm t1.ibd +t2.cfg t2.frm t2.ibd +t3.cfg t3.frm t3.ibd -FLUSH TABLES t1, t2, t3 FOR EXPORT; backup: t1 backup: t2 backup: t3 @@ -55,17 +58,18 @@ restore: t1 .ibd and .cfg files restore: t2 .ibd and .cfg files restore: t3 .ibd and .cfg files ALTER TABLE t1 IMPORT TABLESPACE; -SELECT COUNT(1) FROM t1; -COUNT(1) -10000 +SELECT COUNT(*) FROM t1; +COUNT(*) +100 ALTER TABLE t2 IMPORT TABLESPACE; -SELECT COUNT(1) FROM t2; -COUNT(1) -10000 +SELECT COUNT(*) FROM t2; +COUNT(*) +100 ALTER TABLE t3 IMPORT TABLESPACE; -SELECT COUNT(1) FROM t3; -COUNT(1) -10000 +SELECT COUNT(*) FROM t3; +COUNT(*) +100 +FLUSH TABLES t1, t2, t3 FOR EXPORT; # tablespaces should remain encrypted after import # t1 yes on expecting NOT FOUND NOT FOUND /foobar/ in t1.ibd @@ -73,8 +77,8 @@ NOT FOUND /foobar/ in t1.ibd NOT FOUND /temp/ in t2.ibd # t3 ... on expecting NOT FOUND NOT FOUND /barfoo/ in t3.ibd -# restart -ALTER TABLE t1 ENGINE InnoDB; +UNLOCK TABLES; +ALTER TABLE t1 FORCE; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -82,7 +86,7 @@ t1 CREATE TABLE `t1` ( `a` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `encrypted`=yes -ALTER TABLE t2 ENGINE InnoDB; +ALTER TABLE t2 FORCE; SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -90,7 +94,7 @@ t2 CREATE TABLE `t2` ( `a` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -ALTER TABLE t3 ENGINE InnoDB; +ALTER TABLE t3 FORCE; SHOW CREATE TABLE t3; Table Create Table t3 CREATE TABLE `t3` ( @@ -98,30 +102,17 @@ t3 CREATE TABLE `t3` ( `a` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPRESSED `encrypted`=yes -# Restarting server -# restart -# Done restarting server # Verify that tables are still usable -SELECT COUNT(1) FROM t1; -COUNT(1) -10000 -SELECT COUNT(1) FROM t2; -COUNT(1) -10000 -SELECT COUNT(1) FROM t3; -COUNT(1) -10000 -# Tablespaces should be encrypted after restart +CHECK TABLE t1, t2, t3 EXTENDED; +Table Op Msg_type Msg_text +test.t1 check status OK +test.t2 check status OK +test.t3 check status OK +FLUSH TABLES t1, t2, t3 FOR EXPORT; # t1 yes on expecting NOT FOUND NOT FOUND /foobar/ in t1.ibd # t2 ... on expecting NOT FOUND NOT FOUND /temp/ in t2.ibd # t3 ... on expecting NOT FOUND -NOT FOUND /barfoo/ in t3.ibd -# restart -# Wait max 10 min for key encryption threads to encrypt all spaces -# Success! -# Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 -# restart: --innodb_encrypt_tables=0 --innodb_encryption_threads=0 -DROP PROCEDURE innodb_insert_proc; +UNLOCK TABLES; DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/encryption/t/innodb_encrypt_temporary_tables.test b/mysql-test/suite/encryption/t/innodb_encrypt_temporary_tables.test index d99a55b9b44ef..83abb783c9e33 100644 --- a/mysql-test/suite/encryption/t/innodb_encrypt_temporary_tables.test +++ b/mysql-test/suite/encryption/t/innodb_encrypt_temporary_tables.test @@ -2,10 +2,12 @@ --source include/have_innodb.inc --source include/have_file_key_management_plugin.inc -SELECT variable_value into @old_encrypted FROM information_schema.global_status +SELECT CAST(variable_value AS INT) INTO @old_encrypted +FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_temp_blocks_encrypted'; -SELECT variable_value into @old_decrypted FROM information_schema.global_status +SELECT CAST(variable_value AS INT) INTO @old_decrypted +FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_temp_blocks_decrypted'; CREATE TEMPORARY TABLE t1(f1 CHAR(200), f2 CHAR(200)) ENGINE=InnoDB; @@ -17,8 +19,10 @@ INSERT INTO t2 (f1,f2,f3) SELECT '', '', '' FROM seq_1_to_8192; SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t2; -SELECT variable_value > @old_encrypted FROM information_schema.global_status +SELECT CAST(variable_value AS INT) > @old_encrypted +FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_temp_blocks_encrypted'; -SELECT variable_value > @old_decrypted FROM information_schema.global_status +SELECT CAST(variable_value AS INT) > @old_decrypted +FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_temp_blocks_decrypted'; diff --git a/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test b/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test index 227555716180a..5f02d966e7e75 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test +++ b/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test @@ -6,7 +6,6 @@ let MYSQLD_DATADIR = `SELECT @@datadir`; --let SEARCH_RANGE = 10000000 ---let $id = `SELECT RAND()` --let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd --let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd --let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd @@ -30,19 +29,18 @@ end// delimiter ;// commit; -set autocommit=0; -call innodb_insert_proc(10000); +begin; +set statement unique_checks=0, foreign_key_checks=0 for +call innodb_insert_proc(100); commit; -set autocommit=1; +DROP PROCEDURE innodb_insert_proc; --echo # Wait max 10 min for key encryption threads to encrypt all spaces --let $wait_timeout= 600 --let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING <> 0 --source include/wait_condition.inc -# shutdown so that grep is safe ---source include/shutdown_mysqld.inc - +FLUSH TABLES t1, t2, t3 FOR EXPORT; --echo # tablespaces should be now encrypted --let SEARCH_PATTERN=foobar --echo # t1 yes on expecting NOT FOUND @@ -57,11 +55,8 @@ set autocommit=1; -- let SEARCH_FILE=$t3_IBD -- source include/search_pattern_in_file.inc ---source include/start_mysqld.inc let MYSQLD_DATADIR =`SELECT @@datadir`; - --list_files $MYSQLD_DATADIR/test -FLUSH TABLES t1, t2, t3 FOR EXPORT; perl; do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; ib_backup_tablespaces("test", "t1","t2","t3"); @@ -80,14 +75,13 @@ ib_restore_tablespaces("test", "t1","t2","t3"); EOF ALTER TABLE t1 IMPORT TABLESPACE; -SELECT COUNT(1) FROM t1; +SELECT COUNT(*) FROM t1; ALTER TABLE t2 IMPORT TABLESPACE; -SELECT COUNT(1) FROM t2; +SELECT COUNT(*) FROM t2; ALTER TABLE t3 IMPORT TABLESPACE; -SELECT COUNT(1) FROM t3; +SELECT COUNT(*) FROM t3; -# shutdown so that grep is safe ---source include/shutdown_mysqld.inc +FLUSH TABLES t1, t2, t3 FOR EXPORT; --echo # tablespaces should remain encrypted after import --let SEARCH_PATTERN=foobar @@ -103,28 +97,18 @@ SELECT COUNT(1) FROM t3; -- let SEARCH_FILE=$t3_IBD -- source include/search_pattern_in_file.inc ---source include/start_mysqld.inc - -ALTER TABLE t1 ENGINE InnoDB; +UNLOCK TABLES; +ALTER TABLE t1 FORCE; SHOW CREATE TABLE t1; -ALTER TABLE t2 ENGINE InnoDB; +ALTER TABLE t2 FORCE; SHOW CREATE TABLE t2; -ALTER TABLE t3 ENGINE InnoDB; +ALTER TABLE t3 FORCE; SHOW CREATE TABLE t3; ---echo # Restarting server --- source include/restart_mysqld.inc ---echo # Done restarting server - --echo # Verify that tables are still usable -SELECT COUNT(1) FROM t1; -SELECT COUNT(1) FROM t2; -SELECT COUNT(1) FROM t3; - -# shutdown so that grep is safe ---source include/shutdown_mysqld.inc +CHECK TABLE t1, t2, t3 EXTENDED; +FLUSH TABLES t1, t2, t3 FOR EXPORT; ---echo # Tablespaces should be encrypted after restart --let SEARCH_PATTERN=foobar --echo # t1 yes on expecting NOT FOUND -- let SEARCH_FILE=$t1_IBD @@ -136,19 +120,7 @@ SELECT COUNT(1) FROM t3; --echo # t3 ... on expecting NOT FOUND --let SEARCH_PATTERN=barfoo -- let SEARCH_FILE=$t3_IBD --- source include/search_pattern_in_file.inc - ---source include/start_mysqld.inc - ---echo # Wait max 10 min for key encryption threads to encrypt all spaces ---let $wait_timeout= 600 ---let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING <> 0 ---source include/wait_condition.inc ---echo # Success! ---echo # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 --- let $restart_parameters=--innodb_encrypt_tables=0 --innodb_encryption_threads=0 --- source include/restart_mysqld.inc +UNLOCK TABLES; -DROP PROCEDURE innodb_insert_proc; DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/galera/r/MDEV-27806.result b/mysql-test/suite/galera/r/MDEV-27806.result new file mode 100644 index 0000000000000..0f7ac79e4cdcf --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-27806.result @@ -0,0 +1,52 @@ +connection node_2; +connection node_1; +connection node_1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE ts1 AS SELECT * FROM t1; +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-bin.000002 # Gtid # # BEGIN GTID #-#-# +mysqld-bin.000002 # Query # # use `test`; CREATE TABLE `ts1` ( + `f1` int(11) NOT NULL +) +mysqld-bin.000002 # Annotate_rows # # CREATE TABLE ts1 AS SELECT * FROM t1 +mysqld-bin.000002 # Table_map # # table_id: # (test.ts1) +mysqld-bin.000002 # Write_rows_v1 # # table_id: # flags: STMT_END_F +mysqld-bin.000002 # Xid # # COMMIT /* XID */ +connection node_2; +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-bin.000003 # Gtid # # BEGIN GTID #-#-# +mysqld-bin.000003 # Query # # use `test`; CREATE TABLE `ts1` ( + `f1` int(11) NOT NULL +) +mysqld-bin.000003 # Annotate_rows # # CREATE TABLE ts1 AS SELECT * FROM t1 +mysqld-bin.000003 # Table_map # # table_id: # (test.ts1) +mysqld-bin.000003 # Write_rows_v1 # # table_id: # flags: STMT_END_F +mysqld-bin.000003 # Xid # # COMMIT /* XID */ +BINLOG_POSITIONS_MATCH +1 +DROP TABLE t1,ts1; +connection node_1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +CREATE TABLE ts1 AS SELECT * FROM t1; +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-bin.000002 # Gtid # # BEGIN GTID #-#-# +mysqld-bin.000002 # Query # # use `test`; CREATE TABLE `ts1` ( + `f1` int(11) NOT NULL +) +mysqld-bin.000002 # Xid # # COMMIT /* XID */ +connection node_2; +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-bin.000003 # Gtid # # BEGIN GTID #-#-# +mysqld-bin.000003 # Query # # use `test`; CREATE TABLE `ts1` ( + `f1` int(11) NOT NULL +) +mysqld-bin.000003 # Query # # COMMIT +BINLOG_POSITIONS_MATCH +1 +DROP TABLE t1,ts1; +CALL mtr.add_suppression("Ignoring server id for non bootstrap node"); diff --git a/mysql-test/suite/galera/r/galera_as_master.result b/mysql-test/suite/galera/r/galera_as_master.result index 4aca328be56d7..dd3e017379c54 100644 --- a/mysql-test/suite/galera/r/galera_as_master.result +++ b/mysql-test/suite/galera/r/galera_as_master.result @@ -52,6 +52,8 @@ DROP TABLE t1, t4; SET SQL_LOG_BIN=OFF; DROP TABLE t2, t3; connection node_3; +BINLOG_POSITIONS_MATCH +1 STOP SLAVE; RESET SLAVE ALL; CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); diff --git a/mysql-test/suite/galera/t/MDEV-27806.opt b/mysql-test/suite/galera/t/MDEV-27806.opt new file mode 100644 index 0000000000000..009e761eb2c86 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-27806.opt @@ -0,0 +1 @@ +--log-bin --log-slave-updates --gtid-strict-mode --wsrep_gtid_mode=on diff --git a/mysql-test/suite/galera/t/MDEV-27806.test b/mysql-test/suite/galera/t/MDEV-27806.test new file mode 100644 index 0000000000000..62a0ca483e02c --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-27806.test @@ -0,0 +1,51 @@ +# +# MDEV-27806 GTIDs diverge after CTAS +# +--source include/galera_cluster.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE ts1 AS SELECT * FROM t1; +--let binlog_pos= `SELECT @@gtid_binlog_pos` + +--let $MASTER_MYPORT=$NODE_MYPORT_1 +--let $binlog_file=LAST +--let $binlog_limit=8,20 +--source include/show_binlog_events.inc + +--connection node_2 +--let $binlog_limit=7,20 +--source include/show_binlog_events.inc + +--disable_query_log +--eval SELECT STRCMP(@@gtid_binlog_pos, "$binlog_pos") = 0 AS BINLOG_POSITIONS_MATCH; +--enable_query_log + +DROP TABLE t1,ts1; + + +# +# Same as above, with empty CREATE TABLE AS SELECT +# +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +CREATE TABLE ts1 AS SELECT * FROM t1; +--let binlog_pos= `SELECT @@gtid_binlog_pos` + +--let $MASTER_MYPORT=$NODE_MYPORT_1 +--let $binlog_file=LAST +--let $binlog_limit=18,20 +--source include/show_binlog_events.inc + +--connection node_2 +--let $binlog_limit=17,20 +--source include/show_binlog_events.inc + +--disable_query_log +--eval SELECT STRCMP(@@gtid_binlog_pos, "$binlog_pos") = 0 AS BINLOG_POSITIONS_MATCH; +--enable_query_log + +DROP TABLE t1,ts1; + +CALL mtr.add_suppression("Ignoring server id for non bootstrap node"); diff --git a/mysql-test/suite/galera/t/galera_as_master.test b/mysql-test/suite/galera/t/galera_as_master.test index 1c439ffff6341..a5554a735fef8 100644 --- a/mysql-test/suite/galera/t/galera_as_master.test +++ b/mysql-test/suite/galera/t/galera_as_master.test @@ -52,12 +52,18 @@ DROP TABLE t1, t4; SET SQL_LOG_BIN=OFF; DROP TABLE t2, t3; +--let binlog_pos=`SELECT @@gtid_binlog_pos;` + --connection node_3 --let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't4'; --source include/wait_condition.inc +--disable_query_log +--eval SELECT STRCMP(@@gtid_binlog_pos, "$binlog_pos") = 0 AS BINLOG_POSITIONS_MATCH; +--enable_query_log + STOP SLAVE; RESET SLAVE ALL; diff --git a/mysql-test/suite/galera_sr/r/MDEV-28971.result b/mysql-test/suite/galera_sr/r/MDEV-28971.result new file mode 100644 index 0000000000000..0826f5e6b66b6 --- /dev/null +++ b/mysql-test/suite/galera_sr/r/MDEV-28971.result @@ -0,0 +1,17 @@ +connection node_2; +connection node_1; +CREATE SEQUENCE SEQ NOCACHE ENGINE=InnoDB; +SET SESSION wsrep_trx_fragment_size=1; +SET collation_connection=utf16_thai_520_w2; +SET autocommit=0; +CREATE TABLE t1 (a BLOB UNIQUE); +INSERT INTO t1 VALUES ('AAF'); +SELECT SETVAL (SEQ, 100); +ERROR 42000: This version of MariaDB doesn't yet support 'SEQUENCEs with streaming replication in Galera cluster' +ALTER TABLE t1 ADD CONSTRAINT constraint_1 UNIQUE (a); +Warnings: +Note 1831 Duplicate index `constraint_1`. This is deprecated and will be disallowed in a future release +INSERT INTO t1 VALUES(); +ALTER TABLE t1 ADD KEY(b (50)); +ERROR 42000: Key column 'b' doesn't exist in table +DROP TABLE t1,SEQ; diff --git a/mysql-test/suite/galera_sr/t/MDEV-28971.test b/mysql-test/suite/galera_sr/t/MDEV-28971.test new file mode 100644 index 0000000000000..81238f94b4ab1 --- /dev/null +++ b/mysql-test/suite/galera_sr/t/MDEV-28971.test @@ -0,0 +1,20 @@ +# +# MDEV-28971 - Assertion `total_length + thd->wsrep_sr().log_position() == saved_pos' +# failed in int wsrep_write_cache_inc(THD*, IO_CACHE*, size_t*) +# + +--source include/galera_cluster.inc + +CREATE SEQUENCE SEQ NOCACHE ENGINE=InnoDB; +SET SESSION wsrep_trx_fragment_size=1; +SET collation_connection=utf16_thai_520_w2; +SET autocommit=0; +CREATE TABLE t1 (a BLOB UNIQUE); +INSERT INTO t1 VALUES ('AAF'); +--error ER_NOT_SUPPORTED_YET +SELECT SETVAL (SEQ, 100); +ALTER TABLE t1 ADD CONSTRAINT constraint_1 UNIQUE (a); +INSERT INTO t1 VALUES(); +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE t1 ADD KEY(b (50)); +DROP TABLE t1,SEQ; diff --git a/mysql-test/suite/innodb/disabled.def b/mysql-test/suite/innodb/disabled.def new file mode 100644 index 0000000000000..e78d33745b226 --- /dev/null +++ b/mysql-test/suite/innodb/disabled.def @@ -0,0 +1 @@ +doublewrite_debug : MDEV-33098 occasionally fails to start up InnoDB diff --git a/mysql-test/suite/innodb/r/alter_table.result b/mysql-test/suite/innodb/r/alter_table.result index d39edd3c826d0..a07780148ffa8 100644 --- a/mysql-test/suite/innodb/r/alter_table.result +++ b/mysql-test/suite/innodb/r/alter_table.result @@ -117,8 +117,25 @@ ERROR 42000: Incorrect column specifier for column 'c' CREATE TABLE t1 (c DATETIME AUTO_INCREMENT UNIQUE) ENGINE=InnoDB; ERROR 42000: Incorrect column specifier for column 'c' # -# End of 10.4 tests +# MDEV-31000 Assertion failed on ALTER TABLE...page_compressed=1 # +SET @save_file_per_table=@@GLOBAL.innodb_file_per_table; +SET GLOBAL innodb_file_per_table=0; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release +CREATE TABLE t (c INT PRIMARY KEY) ENGINE=INNODB; +SET GLOBAL innodb_file_per_table=1; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release +ALTER TABLE t page_compressed=1; +SET GLOBAL innodb_file_per_table=@save_file_per_table; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release +SELECT space>0 FROM information_schema.innodb_sys_tables WHERE name='test/t'; +space>0 +1 +DROP TABLE t; +# End of 10.4 tests # # MDEV-21748 ASAN use-after-poison in PageBulk::insertPage() # @@ -136,3 +153,4 @@ CREATE TABLE t1 (id INT PRIMARY KEY, a YEAR, INDEX(id,a)) ENGINE=InnoDB; INSERT INTO t1 VALUES (1,NULL),(2,NULL); UPDATE t1 SET a=0; DROP TABLE t1; +# End of 10.5 tests diff --git a/mysql-test/suite/innodb/r/innodb-wl5522-1.result b/mysql-test/suite/innodb/r/innodb-wl5522-1.result index 204d6bc8b78d3..42c0631dd296f 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5522-1.result +++ b/mysql-test/suite/innodb/r/innodb-wl5522-1.result @@ -808,6 +808,18 @@ call mtr.add_suppression("InnoDB: unsupported MySQL tablespace"); ALTER TABLE t1 IMPORT TABLESPACE; ERROR 42000: Table 't1' uses an extension that doesn't exist in this MariaDB version DROP TABLE t1; -# # End of 10.3 tests # +# MDEV-29972 crash after "Unsupported meta-data version number" +# +call mtr.add_suppression("Index for table 't2' is corrupt"); +CREATE TABLE t2 (i INT PRIMARY KEY) ENGINE=InnoDB; +ALTER TABLE t2 DISCARD TABLESPACE; +ALTER TABLE t2 IMPORT TABLESPACE; +ERROR 42000: This version of MariaDB doesn't yet support 'meta-data version' +ALTER TABLE t2 IMPORT TABLESPACE; +ERROR HY000: Index for table 't2' is corrupt; try to repair it +SELECT * FROM t2; +ERROR HY000: Tablespace has been discarded for table `t2` +DROP TABLE t2; +# End of 10.4 tests diff --git a/mysql-test/suite/innodb/r/innodb_buffer_pool_dump_pct.result b/mysql-test/suite/innodb/r/innodb_buffer_pool_dump_pct.result index fa17487df9767..33adf9baebbda 100644 --- a/mysql-test/suite/innodb/r/innodb_buffer_pool_dump_pct.result +++ b/mysql-test/suite/innodb/r/innodb_buffer_pool_dump_pct.result @@ -3,17 +3,8 @@ col2 VARCHAR(25), col3 varchar(25)) ENGINE=InnoDB; CREATE INDEX idx1 ON tab5(col2(10)); CREATE INDEX idx2 ON tab5(col3(10)); SET GLOBAL innodb_buffer_pool_dump_pct=100; -SELECT variable_value INTO @IBPDS -FROM information_schema.global_status -WHERE variable_name = 'INNODB_BUFFER_POOL_DUMP_STATUS'; SET GLOBAL innodb_buffer_pool_dump_now=ON; SET GLOBAL innodb_buffer_pool_dump_pct=1; -SELECT @@global.innodb_buffer_pool_dump_pct; -@@global.innodb_buffer_pool_dump_pct -1 -SELECT variable_value INTO @IBPDS -FROM information_schema.global_status -WHERE variable_name = 'INNODB_BUFFER_POOL_DUMP_STATUS'; SET GLOBAL innodb_buffer_pool_dump_now=ON; SET GLOBAL innodb_buffer_pool_dump_pct=DEFAULT; DROP TABLE tab5; diff --git a/mysql-test/suite/innodb/r/innodb_prefix_index_restart_server.result b/mysql-test/suite/innodb/r/innodb_prefix_index_restart_server.result index 1e97c21c2536c..1ccf79e451710 100644 --- a/mysql-test/suite/innodb/r/innodb_prefix_index_restart_server.result +++ b/mysql-test/suite/innodb/r/innodb_prefix_index_restart_server.result @@ -90,3 +90,19 @@ worklog5743; col_1_text = REPEAT("a", 3500) col_2_text = REPEAT("o", 3500) 1 1 DROP TABLE worklog5743; +# +# MDEV-21245 InnoDB: Using a partial-field key prefix in search +# +CREATE TABLE t1 (a VARCHAR(255), KEY k(a)) DEFAULT CHARSET=utf8mb3 +ENGINE=InnoDB; +INSERT INTO t1 set a=''; +alter table t1 change a a varchar(3000); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Note 1071 Specified key was too long; max key length is 3072 bytes +SELECT * FROM t1 WHERE a IN (''); +a + +DROP TABLE t1; +# End of 10.4 tests diff --git a/mysql-test/suite/innodb/t/alter_table.test b/mysql-test/suite/innodb/t/alter_table.test index 67ada081d467d..d293d3a40f45e 100644 --- a/mysql-test/suite/innodb/t/alter_table.test +++ b/mysql-test/suite/innodb/t/alter_table.test @@ -121,9 +121,20 @@ CREATE TABLE t1 (c TIMESTAMP AUTO_INCREMENT UNIQUE) ENGINE=InnoDB; CREATE TABLE t1 (c DATETIME AUTO_INCREMENT UNIQUE) ENGINE=InnoDB; --echo # ---echo # End of 10.4 tests +--echo # MDEV-31000 Assertion failed on ALTER TABLE...page_compressed=1 --echo # +SET @save_file_per_table=@@GLOBAL.innodb_file_per_table; +SET GLOBAL innodb_file_per_table=0; +CREATE TABLE t (c INT PRIMARY KEY) ENGINE=INNODB; +SET GLOBAL innodb_file_per_table=1; +ALTER TABLE t page_compressed=1; +SET GLOBAL innodb_file_per_table=@save_file_per_table; +SELECT space>0 FROM information_schema.innodb_sys_tables WHERE name='test/t'; +DROP TABLE t; + +--echo # End of 10.4 tests + --echo # --echo # MDEV-21748 ASAN use-after-poison in PageBulk::insertPage() --echo # @@ -141,3 +152,5 @@ CREATE TABLE t1 (id INT PRIMARY KEY, a YEAR, INDEX(id,a)) ENGINE=InnoDB; INSERT INTO t1 VALUES (1,NULL),(2,NULL); UPDATE t1 SET a=0; DROP TABLE t1; + +--echo # End of 10.5 tests diff --git a/mysql-test/suite/innodb/t/import_update_stats.test b/mysql-test/suite/innodb/t/import_update_stats.test index 7e7913ce5c489..30420f4d07989 100644 --- a/mysql-test/suite/innodb/t/import_update_stats.test +++ b/mysql-test/suite/innodb/t/import_update_stats.test @@ -4,7 +4,6 @@ --source include/not_embedded.inc --source include/have_innodb.inc ---source include/not_valgrind.inc # MDEV-32725 FIXME let MYSQLD_DATADIR =`SELECT @@datadir`; diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-1.test b/mysql-test/suite/innodb/t/innodb-wl5522-1.test index dbd58835ec60e..9e5d606b894c8 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5522-1.test +++ b/mysql-test/suite/innodb/t/innodb-wl5522-1.test @@ -960,6 +960,25 @@ ALTER TABLE t1 IMPORT TABLESPACE; DROP TABLE t1; --remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd ---echo # --echo # End of 10.3 tests + --echo # +--echo # MDEV-29972 crash after "Unsupported meta-data version number" +--echo # + +call mtr.add_suppression("Index for table 't2' is corrupt"); + +CREATE TABLE t2 (i INT PRIMARY KEY) ENGINE=InnoDB; +ALTER TABLE t2 DISCARD TABLESPACE; +--copy_file std_data/mysql80/t2.cfg $MYSQLD_DATADIR/test/t2.cfg +--copy_file std_data/mysql80/t2.ibd $MYSQLD_DATADIR/test/t2.ibd +--error ER_NOT_SUPPORTED_YET +ALTER TABLE t2 IMPORT TABLESPACE; +--remove_file $MYSQLD_DATADIR/test/t2.cfg +--error ER_NOT_KEYFILE +ALTER TABLE t2 IMPORT TABLESPACE; +--error ER_TABLESPACE_DISCARDED +SELECT * FROM t2; +DROP TABLE t2; + +--echo # End of 10.4 tests diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_dump_pct.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_dump_pct.test index 381091165ef08..b393ca707785a 100644 --- a/mysql-test/suite/innodb/t/innodb_buffer_pool_dump_pct.test +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_dump_pct.test @@ -35,49 +35,44 @@ SET GLOBAL innodb_buffer_pool_dump_pct=100; # - The granularity of the timestamp is one second. # - There could have been some dump caused by some previous test # just a few milliseconds before. -# In order to avoid conflict with previous tests, read the current value -# of INNODB_BUFFER_POOL_DUMP_STATUS -# and confirm that the timestamp is different after the dump #*********************************************************** -# Read the current value to compare with the new value. -SELECT variable_value INTO @IBPDS -FROM information_schema.global_status -WHERE variable_name = 'INNODB_BUFFER_POOL_DUMP_STATUS'; -SET GLOBAL innodb_buffer_pool_dump_now=ON; - -# Sleep one second in order to ensure that the time stamp is -# different at next dump ---sleep 1 +--error 0,1 +--remove_file $MYSQLD_DATADIR/ib_buffer_pool +SET GLOBAL innodb_buffer_pool_dump_now=ON; +perl; +my $f="$ENV{MYSQLD_DATADIR}/ib_buffer_pool"; +my $count=300; +until (-e $f) +{ + select(undef, undef, undef, .1); + die "File $f was not created\n" if (0 > --$count); +} +EOF let $wait_condition = SELECT count(*) = 1 FROM information_schema.global_status WHERE variable_name = 'INNODB_BUFFER_POOL_DUMP_STATUS' -AND variable_value != @IBPDS AND variable_value like 'Buffer pool(s) dump completed at%'; --source include/wait_condition.inc --move_file $MYSQLD_DATADIR/ib_buffer_pool $MYSQLD_DATADIR/ib_buffer_pool100 SET GLOBAL innodb_buffer_pool_dump_pct=1; -SELECT @@global.innodb_buffer_pool_dump_pct; - -# Read the current value to compare with the new value. ---disable_warnings -SELECT variable_value INTO @IBPDS -FROM information_schema.global_status -WHERE variable_name = 'INNODB_BUFFER_POOL_DUMP_STATUS'; ---enable_warnings - SET GLOBAL innodb_buffer_pool_dump_now=ON; -# Sleep one second in order to ensure that the time stamp is -# different at next dump ---sleep 1 +perl; +my $f="$ENV{MYSQLD_DATADIR}/ib_buffer_pool"; +my $count=300; +until (-e $f) +{ + select(undef, undef, undef, .1); + die "File $f was not created\n" if (0 > --$count); +} +EOF let $wait_condition = SELECT count(*) = 1 FROM information_schema.global_status WHERE variable_name = 'INNODB_BUFFER_POOL_DUMP_STATUS' -AND variable_value != @IBPDS AND variable_value like 'Buffer pool(s) dump completed at%'; --source include/wait_condition.inc diff --git a/mysql-test/suite/innodb/t/innodb_prefix_index_restart_server.test b/mysql-test/suite/innodb/t/innodb_prefix_index_restart_server.test index 1fb7c6d0f7740..fa93e95c64225 100644 --- a/mysql-test/suite/innodb/t/innodb_prefix_index_restart_server.test +++ b/mysql-test/suite/innodb/t/innodb_prefix_index_restart_server.test @@ -93,3 +93,17 @@ SELECT col_1_text = REPEAT("a", 3500) , col_2_text = REPEAT("o", 3500) FROM worklog5743; DROP TABLE worklog5743; + +--echo # +--echo # MDEV-21245 InnoDB: Using a partial-field key prefix in search +--echo # +CREATE TABLE t1 (a VARCHAR(255), KEY k(a)) DEFAULT CHARSET=utf8mb3 +ENGINE=InnoDB; +INSERT INTO t1 set a=''; +--enable_info +alter table t1 change a a varchar(3000); +--disable_info +SELECT * FROM t1 WHERE a IN (''); +DROP TABLE t1; + +--echo # End of 10.4 tests diff --git a/mysql-test/suite/rpl/r/rpl_deadlock_show_slave_status.result b/mysql-test/suite/rpl/r/rpl_deadlock_show_slave_status.result new file mode 100644 index 0000000000000..12ad5870d4a13 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_deadlock_show_slave_status.result @@ -0,0 +1,66 @@ +include/master-slave.inc +[connection master] +# +# Initialize test data +connection master; +create table t1 (a int) engine=innodb; +insert into t1 values (1); +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +include/stop_slave.inc +call mtr.add_suppression("Connection was killed"); +call mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); +set @save_parallel_threads= @@global.slave_parallel_threads; +set @save_parallel_mode= @@global.slave_parallel_mode; +set @save_transaction_retries= @@global.slave_transaction_retries; +set @save_innodb_lock_wait_timeout= @@global.innodb_lock_wait_timeout; +set @@global.slave_parallel_threads= 2; +set @@global.slave_parallel_mode= CONSERVATIVE; +set @@global.slave_transaction_retries= 0; +set @@global.innodb_lock_wait_timeout= 10; +# Grabbing lock on innodb row to force future replication transaction to wait (and eventually timeout) +BEGIN; +select * from t1 where a=1 for update; +a +1 +connection master; +set @old_dbug= @@session.debug_dbug; +set @@session.debug_dbug="+d,binlog_force_commit_id"; +SET @commit_id= 10000; +update t1 set a=2 where a=1; +SET @commit_id= 10001; +insert into t1 values (3); +set @@session.debug_dbug= @old_dbug; +connection slave; +start slave; +# Waiting for first transaction to start (and be held at innodb row lock).. +# Waiting for next transaction to start and hold at do_gco_wait().. +connection slave1; +set @@session.debug_dbug="+d,hold_sss_with_err_lock"; +show slave status; +connection slave; +set debug_sync="now wait_for sss_got_err_lock"; +kill ; +set debug_sync="now signal sss_continue"; +connection slave1; +# Waiting for SHOW SLAVE STATUS to complete.. +# ..done +connection slave; +ROLLBACK; +include/wait_for_slave_sql_error.inc [errno=1927] +# +# Cleanup +connection master; +drop table t1; +include/save_master_gtid.inc +connection slave; +set debug_sync= "RESET"; +set @@global.slave_parallel_threads= @save_parallel_threads; +set @@global.slave_parallel_mode= @save_parallel_mode; +set @@global.slave_transaction_retries= @save_transaction_retries; +set @@global.innodb_lock_wait_timeout= @save_innodb_lock_wait_timeout; +start slave sql_thread; +include/sync_with_master_gtid.inc +include/rpl_end.inc +# End of rpl_deadlock_show_slave_status.test diff --git a/mysql-test/suite/rpl/r/rpl_gtid_basic.result b/mysql-test/suite/rpl/r/rpl_gtid_basic.result index 584499a9e1e9b..a7da70108b021 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_basic.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_basic.result @@ -188,6 +188,13 @@ BINLOG_GTID_POS('master-bin.000001',18446744073709551616) NULL Warnings: Warning 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated +SET sql_log_bin= 0; +CREATE TABLE t1 AS SELECT MASTER_POS_WAIT(@binlog_file, 4, 0); +SELECT BINLOG_GTID_POS(@binlog_file, 4); +BINLOG_GTID_POS(@binlog_file, 4) +NULL +DROP TABLE t1; +SET sql_log_bin= 1; *** Some tests of @@GLOBAL.gtid_binlog_state *** connection server_2; include/sync_with_master_gtid.inc diff --git a/mysql-test/suite/rpl/r/rpl_gtid_slave_filtering.result b/mysql-test/suite/rpl/r/rpl_gtid_slave_filtering.result new file mode 100644 index 0000000000000..84080b94de88d --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_slave_filtering.result @@ -0,0 +1,78 @@ +include/rpl_init.inc [topology=1->2->3] +*** Test GTID master switch in a topology with filtered events. +*** With --gtid-ignore-duplicate and --gtid-strict-mode, should allow +*** GTID connect at a GTID position that is filtered on the new master. +connection server_1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO t3 VALUES (1,1); +INSERT INTO t1 VALUES (2,1); +INSERT INTO t3 VALUES (2,1); +include/save_master_gtid.inc +connection server_2; +CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,2); +include/sync_with_master_gtid.inc +include/save_master_gtid.inc +connection server_3; +include/sync_with_master_gtid.inc +*** Promote 3 as new master, demote 2 as slave of 3. +*** GTID position of 2 in domain 0 is filtered on 3. +connection server_2; +include/stop_slave.inc +connection server_3; +include/stop_slave.inc +CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_1, +MASTER_USE_GTID=SLAVE_POS; +connection server_2; +CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_3, +MASTER_USE_GTID=SLAVE_POS; +include/start_slave.inc +connection server_3; +include/start_slave.inc +connection server_1; +INSERT INTO t1 VALUES (3,1); +INSERT INTO t3 VALUES (3,1); +include/save_master_gtid.inc +connection server_3; +INSERT INTO t2 VALUES (2,2); +include/sync_with_master_gtid.inc +include/save_master_gtid.inc +connection server_2; +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a b +1 1 +2 1 +3 1 +SELECT * FROM t3 ORDER BY a; +ERROR 42S02: Table 'test.t3' doesn't exist +SELECT * FROM t2 ORDER BY a; +a b +1 2 +2 2 +*** Restore original topology. +connection server_3; +include/stop_slave.inc +connection server_2; +include/stop_slave.inc +CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_1, +MASTER_USE_GTID=SLAVE_POS; +include/start_slave.inc +connection server_3; +CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_2, +MASTER_USE_GTID=SLAVE_POS; +include/start_slave.inc +connection server_1; +DROP TABLE t1; +DROP TABLE t3; +include/save_master_gtid.inc +connection server_2; +DROP TABLE t2; +include/sync_with_master_gtid.inc +include/save_master_gtid.inc +connection server_3; +include/sync_with_master_gtid.inc +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_deadlock_show_slave_status.test b/mysql-test/suite/rpl/t/rpl_deadlock_show_slave_status.test new file mode 100644 index 0000000000000..4c41011e7b671 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_deadlock_show_slave_status.test @@ -0,0 +1,121 @@ +# +# Verify that SHOW SLAVE STATUS will not cause deadlocks on the replica. +# A deadlock has been seen in do_gco_wait if the thread is killed, as it will +# hold the LOCK_parallel_entry, and during error reporting, try to grab the +# err_lock. Prior to MDEV-10653, SHOW SLAVE STATUS would grab these locks in +# the reverse order, as calling workers_idle() used to grab LOCK_parallel_entry +# with the err_lock already grabbed (though the MDEV-10653 patch changed the +# workles_idle() implementation to remove the need for locking the +# parallel_entry). +# +# References: +# MDEV-10653: SHOW SLAVE STATUS Can Deadlock an Errored Slave +# + +--source include/master-slave.inc +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_binlog_format_row.inc + +--echo # +--echo # Initialize test data +--connection master +create table t1 (a int) engine=innodb; +insert into t1 values (1); +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc +--source include/stop_slave.inc + +call mtr.add_suppression("Connection was killed"); +call mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); + +set @save_parallel_threads= @@global.slave_parallel_threads; +set @save_parallel_mode= @@global.slave_parallel_mode; +set @save_transaction_retries= @@global.slave_transaction_retries; +set @save_innodb_lock_wait_timeout= @@global.innodb_lock_wait_timeout; + +set @@global.slave_parallel_threads= 2; +set @@global.slave_parallel_mode= CONSERVATIVE; +set @@global.slave_transaction_retries= 0; +set @@global.innodb_lock_wait_timeout= 10; + +--echo # Grabbing lock on innodb row to force future replication transaction to wait (and eventually timeout) +BEGIN; +select * from t1 where a=1 for update; + +--connection master + +set @old_dbug= @@session.debug_dbug; +set @@session.debug_dbug="+d,binlog_force_commit_id"; + + +# GCO 1 +SET @commit_id= 10000; +# T1 +update t1 set a=2 where a=1; + +# GCO 2 +SET @commit_id= 10001; +# T2 +insert into t1 values (3); + +set @@session.debug_dbug= @old_dbug; + +--connection slave +start slave; + +--echo # Waiting for first transaction to start (and be held at innodb row lock).. +--let $wait_condition= SELECT count(*)=1 FROM information_schema.processlist WHERE state LIKE 'Update_rows_log_event::find_row(%)%' and command LIKE 'Slave_worker'; +--source include/wait_condition.inc + +--echo # Waiting for next transaction to start and hold at do_gco_wait().. +--let $wait_condition= SELECT count(*)=1 FROM information_schema.processlist WHERE state LIKE 'Waiting for prior transaction to start commit%' and command LIKE 'Slave_worker'; +--source include/wait_condition.inc + +--connection slave1 +set @@session.debug_dbug="+d,hold_sss_with_err_lock"; +--send show slave status + +--connection slave +set debug_sync="now wait_for sss_got_err_lock"; + +--let $t2_tid= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Waiting for prior transaction to start commit%'` +--replace_result $t2_tid "" +--eval kill $t2_tid +--let $wait_condition= SELECT count(*)=1 FROM information_schema.processlist WHERE command LIKE 'Killed'; +--source include/wait_condition.inc + +set debug_sync="now signal sss_continue"; + +--connection slave1 +--echo # Waiting for SHOW SLAVE STATUS to complete.. +--disable_result_log +--reap +--enable_result_log +--echo # ..done + +--connection slave +ROLLBACK; +--let $slave_sql_errno= 1927 +--source include/wait_for_slave_sql_error.inc + + +--echo # +--echo # Cleanup +--connection master +drop table t1; +--source include/save_master_gtid.inc + +--connection slave +set debug_sync= "RESET"; +set @@global.slave_parallel_threads= @save_parallel_threads; +set @@global.slave_parallel_mode= @save_parallel_mode; +set @@global.slave_transaction_retries= @save_transaction_retries; +set @@global.innodb_lock_wait_timeout= @save_innodb_lock_wait_timeout; +start slave sql_thread; +--source include/sync_with_master_gtid.inc + +--source include/rpl_end.inc +--echo # End of rpl_deadlock_show_slave_status.test diff --git a/mysql-test/suite/rpl/t/rpl_gtid_basic.test b/mysql-test/suite/rpl/t/rpl_gtid_basic.test index 70bd0087f7a00..a7af234d47e87 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_basic.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_basic.test @@ -162,6 +162,13 @@ eval SELECT BINLOG_GTID_POS('$valid_binlog_name',0); eval SELECT BINLOG_GTID_POS('$valid_binlog_name',18446744073709551615); eval SELECT BINLOG_GTID_POS('$valid_binlog_name',18446744073709551616); +# MDEV-33045: Server crashes in Item_func_binlog_gtid_pos::val_str / Binary_string::c_ptr_safe +SET sql_log_bin= 0; +CREATE TABLE t1 AS SELECT MASTER_POS_WAIT(@binlog_file, 4, 0); +SELECT BINLOG_GTID_POS(@binlog_file, 4); +DROP TABLE t1; +SET sql_log_bin= 1; + --echo *** Some tests of @@GLOBAL.gtid_binlog_state *** --connection server_2 diff --git a/mysql-test/suite/rpl/t/rpl_gtid_slave_filtering.cnf b/mysql-test/suite/rpl/t/rpl_gtid_slave_filtering.cnf new file mode 100644 index 0000000000000..a57dbbf3f566c --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_slave_filtering.cnf @@ -0,0 +1,28 @@ +!include ../my.cnf + +[mysqld.1] +log-slave-updates +loose-innodb +gtid-domain-id=1 +gtid-strict-mode=0 +gtid-ignore-duplicates=1 + +[mysqld.2] +log-slave-updates +loose-innodb +gtid-domain-id=0 +replicate-ignore-table=test.t3 +gtid-strict-mode=0 +gtid-ignore-duplicates=1 + +[mysqld.3] +log-slave-updates +loose-innodb +gtid-domain-id=0 +replicate-ignore-table=test.t3 +gtid-strict-mode=0 +gtid-ignore-duplicates=1 + +[ENV] +SERVER_MYPORT_3= @mysqld.3.port +SERVER_MYSOCK_3= @mysqld.3.socket diff --git a/mysql-test/suite/rpl/t/rpl_gtid_slave_filtering.test b/mysql-test/suite/rpl/t/rpl_gtid_slave_filtering.test new file mode 100644 index 0000000000000..842bae8234c42 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_slave_filtering.test @@ -0,0 +1,109 @@ +--source include/have_innodb.inc +--source include/have_binlog_format_mixed.inc + +--let $rpl_topology=1->2->3 +--source include/rpl_init.inc + +--echo *** Test GTID master switch in a topology with filtered events. +--echo *** With --gtid-ignore-duplicate and --gtid-strict-mode, should allow +--echo *** GTID connect at a GTID position that is filtered on the new master. + +--connection server_1 + +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO t3 VALUES (1,1); +INSERT INTO t1 VALUES (2,1); +INSERT INTO t3 VALUES (2,1); +--source include/save_master_gtid.inc + +--connection server_2 +CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,2); + +--let $slave_timeout= 10 +--source include/sync_with_master_gtid.inc +--source include/save_master_gtid.inc + +--connection server_3 +--source include/sync_with_master_gtid.inc + +--echo *** Promote 3 as new master, demote 2 as slave of 3. +--echo *** GTID position of 2 in domain 0 is filtered on 3. + +--connection server_2 +--source include/stop_slave.inc + +--connection server_3 +--source include/stop_slave.inc +--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 +eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_1, + MASTER_USE_GTID=SLAVE_POS; + +--connection server_2 +--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3 +eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_3, + MASTER_USE_GTID=SLAVE_POS; +--source include/start_slave.inc + +--connection server_3 +--source include/start_slave.inc + +--connection server_1 +INSERT INTO t1 VALUES (3,1); +INSERT INTO t3 VALUES (3,1); +--source include/save_master_gtid.inc + +--connection server_3 +INSERT INTO t2 VALUES (2,2); + +--source include/sync_with_master_gtid.inc +--source include/save_master_gtid.inc + +--connection server_2 +--source include/sync_with_master_gtid.inc + +SELECT * FROM t1 ORDER BY a; +# Verify that table t3 is being filtered. +--error 1146 +SELECT * FROM t3 ORDER BY a; +SELECT * FROM t2 ORDER BY a; + + +--echo *** Restore original topology. + +--connection server_3 +--source include/stop_slave.inc + +--connection server_2 +--source include/stop_slave.inc +--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 +eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_1, + MASTER_USE_GTID=SLAVE_POS; +--source include/start_slave.inc + +--connection server_3 +--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2 +eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_2, + MASTER_USE_GTID=SLAVE_POS; +--source include/start_slave.inc + + +# Cleanup + +--connection server_1 +DROP TABLE t1; +DROP TABLE t3; +--source include/save_master_gtid.inc + +--connection server_2 +DROP TABLE t2; +--source include/sync_with_master_gtid.inc +--source include/save_master_gtid.inc + +--connection server_3 +--source include/sync_with_master_gtid.inc + +--source include/rpl_end.inc diff --git a/mysql-test/suite/sql_sequence/alter.result b/mysql-test/suite/sql_sequence/alter.result index 6d29876a8eb43..ae95bfb9cc1fb 100644 --- a/mysql-test/suite/sql_sequence/alter.result +++ b/mysql-test/suite/sql_sequence/alter.result @@ -210,8 +210,12 @@ create table t1 (a int); alter sequence t1 minvalue=100; ERROR 42S02: 'test.t1' is not a SEQUENCE drop table t1; +# +# MDEV-32795: ALTER SEQUENCE IF NOT EXISTS non_existing_seq Errors rather than note +# alter sequence if exists t1 minvalue=100; -ERROR 42S02: Unknown SEQUENCE: 't1' +Warnings: +Note 4091 Unknown SEQUENCE: 'test.t1' alter sequence t1 minvalue=100; ERROR 42S02: Unknown SEQUENCE: 't1' create sequence t1; diff --git a/mysql-test/suite/sql_sequence/alter.test b/mysql-test/suite/sql_sequence/alter.test index dab0e66595039..20ac6b2cb923a 100644 --- a/mysql-test/suite/sql_sequence/alter.test +++ b/mysql-test/suite/sql_sequence/alter.test @@ -120,8 +120,12 @@ create table t1 (a int); alter sequence t1 minvalue=100; drop table t1; ---error ER_UNKNOWN_SEQUENCES +--echo # +--echo # MDEV-32795: ALTER SEQUENCE IF NOT EXISTS non_existing_seq Errors rather than note +--echo # + alter sequence if exists t1 minvalue=100; + --error ER_UNKNOWN_SEQUENCES alter sequence t1 minvalue=100; diff --git a/mysql-test/suite/sysschema/disabled.def b/mysql-test/suite/sysschema/disabled.def index ffb897b553a57..62df96a4663e3 100644 --- a/mysql-test/suite/sysschema/disabled.def +++ b/mysql-test/suite/sysschema/disabled.def @@ -9,5 +9,4 @@ # Do not use any TAB characters for whitespace. # ############################################################################## -import_update_stats: MDEV-32725 fails in MSAN, uninit access pr_statement_performance_analyzer : MDEV-29822 perfschema specific and Windows specific problems. diff --git a/plugin/disks/mysql-test/disks/disks.result b/plugin/disks/mysql-test/disks/disks.result index 888f2df64f7c6..e46390c751688 100644 --- a/plugin/disks/mysql-test/disks/disks.result +++ b/plugin/disks/mysql-test/disks/disks.result @@ -7,6 +7,6 @@ DISKS CREATE TEMPORARY TABLE `DISKS` ( `Used` bigint(32) NOT NULL, `Available` bigint(32) NOT NULL ) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci -select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; -sum(Total) > sum(Available) sum(Total)>sum(Used) +select sum(Total) >= sum(Available), sum(Total)>=sum(Used) from information_schema.disks; +sum(Total) >= sum(Available) sum(Total)>=sum(Used) 1 1 diff --git a/plugin/disks/mysql-test/disks/disks.test b/plugin/disks/mysql-test/disks/disks.test index 7189c54834279..9adc3f01ebc6c 100644 --- a/plugin/disks/mysql-test/disks/disks.test +++ b/plugin/disks/mysql-test/disks/disks.test @@ -1,3 +1,3 @@ --replace_regex /varchar\([0-9]+\)/varchar(pathlen)/ show create table information_schema.disks; -select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; +select sum(Total) >= sum(Available), sum(Total)>=sum(Used) from information_schema.disks; diff --git a/plugin/disks/mysql-test/disks/disks_notembedded.result b/plugin/disks/mysql-test/disks/disks_notembedded.result index 974294744cc1b..ea2ccc85bfbb1 100644 --- a/plugin/disks/mysql-test/disks/disks_notembedded.result +++ b/plugin/disks/mysql-test/disks/disks_notembedded.result @@ -6,16 +6,16 @@ CREATE USER user1@localhost; GRANT SELECT ON *.* TO user1@localhost; connect con1,localhost,user1,,; connection con1; -select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; -sum(Total) > sum(Available) sum(Total)>sum(Used) +select sum(Total) >= sum(Available), sum(Total) >= sum(Used) from information_schema.disks; +sum(Total) >= sum(Available) sum(Total) >= sum(Used) NULL NULL disconnect con1; connection default; GRANT FILE ON *.* TO user1@localhost; connect con1,localhost,user1,,; connection con1; -select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; -sum(Total) > sum(Available) sum(Total)>sum(Used) +select sum(Total) >= sum(Available), sum(Total) >= sum(Used) from information_schema.disks; +sum(Total) >= sum(Available) sum(Total) >= sum(Used) 1 1 connection default; DROP USER user1@localhost; diff --git a/plugin/disks/mysql-test/disks/disks_notembedded.test b/plugin/disks/mysql-test/disks/disks_notembedded.test index a0f6c2e5887ff..4481da9f17646 100644 --- a/plugin/disks/mysql-test/disks/disks_notembedded.test +++ b/plugin/disks/mysql-test/disks/disks_notembedded.test @@ -10,7 +10,7 @@ GRANT SELECT ON *.* TO user1@localhost; connect (con1,localhost,user1,,); connection con1; -select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; +select sum(Total) >= sum(Available), sum(Total) >= sum(Used) from information_schema.disks; disconnect con1; connection default; @@ -18,7 +18,7 @@ GRANT FILE ON *.* TO user1@localhost; connect (con1,localhost,user1,,); connection con1; -select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; +select sum(Total) >= sum(Available), sum(Total) >= sum(Used) from information_schema.disks; connection default; DROP USER user1@localhost; diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index 2b4a678d6628c..64b92fb445e5a 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -230,6 +230,11 @@ UPDATE user SET plugin='unix_socket' WHERE plugin='auth_socket'; DELETE FROM plugin WHERE name='auth_socket'; +# Delete plugins that are now inbuilt but might not have been before (MDEV-32043) +DELETE plugin + FROM information_schema.PLUGINS is_p + JOIN plugin ON plugin.name = is_p.PLUGIN_NAME + WHERE is_p.PLUGIN_LIBRARY IS NULL; ALTER TABLE user MODIFY Password char(41) character set latin1 collate latin1_bin NOT NULL default '', diff --git a/sql/ha_sequence.cc b/sql/ha_sequence.cc index bab0614706d1f..92b307ff217c4 100644 --- a/sql/ha_sequence.cc +++ b/sql/ha_sequence.cc @@ -271,13 +271,26 @@ int ha_sequence::write_row(const uchar *buf) } #ifdef WITH_WSREP - /* We need to start Galera transaction for select NEXT VALUE FOR - sequence if it is not yet started. Note that ALTER is handled - as TOI. */ - if (WSREP_ON && WSREP(thd) && - !thd->wsrep_trx().active() && - wsrep_thd_is_local(thd)) - wsrep_start_transaction(thd, thd->wsrep_next_trx_id()); + if (WSREP_ON && WSREP(thd) && wsrep_thd_is_local(thd)) + { + if (sequence_locked && + (wsrep_thd_is_SR(thd) || wsrep_streaming_enabled(thd))) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), + "SEQUENCEs with streaming replication in Galera cluster"); + DBUG_RETURN(HA_ERR_UNSUPPORTED); + } + + /* + We need to start Galera transaction for select NEXT VALUE FOR + sequence if it is not yet started. Note that ALTER is handled + as TOI. + */ + if (!thd->wsrep_trx().active()) + { + wsrep_start_transaction(thd, thd->wsrep_next_trx_id()); + } + } #endif if (likely(!(error= file->update_first_row(buf)))) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 9afc645884412..4d9498818e028 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -3481,12 +3481,12 @@ String *Item_func_binlog_gtid_pos::val_str(String *str) String name_str, *name; longlong pos; - if (args[0]->null_value || args[1]->null_value) - goto err; - name= args[0]->val_str(&name_str); pos= args[1]->val_int(); + if (args[0]->null_value || args[1]->null_value) + goto err; + if (pos < 0 || pos > UINT_MAX32) goto err; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index ba87b86044653..bcaf229dd1590 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -4293,7 +4293,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref) String *new_separator; DBUG_ASSERT(thd->active_stmt_arena_to_use()-> - is_stmt_prepare_or_first_sp_execute() || + is_stmt_prepare_or_first_stmt_execute() || thd->active_stmt_arena_to_use()-> is_conventional() || thd->active_stmt_arena_to_use()->state == diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 95a1234ec9a0a..333a3960360c0 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -895,8 +895,7 @@ retry_event_group(rpl_group_info *rgi, rpl_parallel_thread *rpt, thd->wait_for_commit_ptr->unregister_wait_for_prior_commit(); DBUG_EXECUTE_IF("inject_mdev8031", { /* Simulate that we get deadlock killed at this exact point. */ - rgi->killed_for_retry= rpl_group_info::RETRY_KILL_KILLED; - thd->set_killed(KILL_CONNECTION); + slave_background_kill_request(thd); }); #ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("rpl_parallel_simulate_wait_at_retry", { @@ -2877,23 +2876,12 @@ rpl_parallel::stop_during_until() bool -rpl_parallel::workers_idle() +rpl_parallel::workers_idle(Relay_log_info *rli) { - struct rpl_parallel_entry *e; - uint32 i, max_i; - - max_i= domain_hash.records; - for (i= 0; i < max_i; ++i) - { - bool active; - e= (struct rpl_parallel_entry *)my_hash_element(&domain_hash, i); - mysql_mutex_lock(&e->LOCK_parallel_entry); - active= e->current_sub_id > e->last_committed_sub_id; - mysql_mutex_unlock(&e->LOCK_parallel_entry); - if (active) - break; - } - return (i == max_i); + mysql_mutex_assert_owner(&rli->data_lock); + return !rli->last_inuse_relaylog || + rli->last_inuse_relaylog->queued_count == + rli->last_inuse_relaylog->dequeued_count; } diff --git a/sql/rpl_parallel.h b/sql/rpl_parallel.h index a9cfefcb02e12..307d0e3badaff 100644 --- a/sql/rpl_parallel.h +++ b/sql/rpl_parallel.h @@ -460,9 +460,10 @@ struct rpl_parallel { rpl_parallel_entry *find(uint32 domain_id, Relay_log_info *rli); void wait_for_done(THD *thd, Relay_log_info *rli); void stop_during_until(); - bool workers_idle(); int wait_for_workers_idle(THD *thd); int do_event(rpl_group_info *serial_rgi, Log_event *ev, ulonglong event_size); + + static bool workers_idle(Relay_log_info *rli); }; diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 0fd9070426b8e..30e1bb45ec4b7 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -623,7 +623,7 @@ struct inuse_relaylog { rpl_gtid *relay_log_state; uint32 relay_log_state_count; /* Number of events in this relay log queued for worker threads. */ - int64 queued_count; + Atomic_counter queued_count; /* Number of events completed by worker threads. */ Atomic_counter dequeued_count; /* Set when all events have been read from a relaylog. */ diff --git a/sql/slave.cc b/sql/slave.cc index 13764dc350c0b..ef19d6a048b75 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3178,6 +3178,14 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, mysql_mutex_lock(&mi->err_lock); /* err_lock is to protect mi->rli.last_error() */ mysql_mutex_lock(&mi->rli.err_lock); + + DBUG_EXECUTE_IF("hold_sss_with_err_lock", { + DBUG_ASSERT(!debug_sync_set_action( + thd, STRING_WITH_LEN("now SIGNAL sss_got_err_lock " + "WAIT_FOR sss_continue"))); + DBUG_SET("-d,hold_sss_with_err_lock"); + }); + protocol->store_string_or_null(mi->host, &my_charset_bin); protocol->store_string_or_null(mi->user, &my_charset_bin); protocol->store((uint32) mi->port); @@ -3257,7 +3265,8 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, while the slave is processing ignored events, such as those skipped due to slave_skip_counter. */ - if (mi->using_parallel() && idle && !mi->rli.parallel.workers_idle()) + if (mi->using_parallel() && idle && + !rpl_parallel::workers_idle(&mi->rli)) idle= false; } if (idle) @@ -5494,19 +5503,25 @@ pthread_handler_t handle_slave_sql(void *arg) } else rli->gtid_skip_flag = GTID_SKIP_NOT; + mysql_mutex_lock(&rli->data_lock); if (init_relay_log_pos(rli, rli->group_relay_log_name, rli->group_relay_log_pos, - 1 /*need data lock*/, &errmsg, + 0 /*need data lock*/, &errmsg, 1 /*look for a description_event*/)) { rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, NULL, "Error initializing relay log position: %s", errmsg); + mysql_mutex_unlock(&rli->data_lock); goto err_before_start; } rli->reset_inuse_relaylog(); if (rli->alloc_inuse_relaylog(rli->group_relay_log_name)) + { + mysql_mutex_unlock(&rli->data_lock); goto err_before_start; + } + mysql_mutex_unlock(&rli->data_lock); strcpy(rli->future_event_master_log_name, rli->group_master_log_name); THD_CHECK_SENTRY(thd); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index cfb409e38e53c..2b19f4506db13 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -74,7 +74,9 @@ No_such_table_error_handler::handle_condition(THD *, *cond_hdl= NULL; if (!first_error) first_error= sql_errno; - if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE) + if (sql_errno == ER_NO_SUCH_TABLE + || sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE + || sql_errno == ER_UNKNOWN_SEQUENCES) { m_handled_errors++; return TRUE; diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index ade850590c0a9..54a1aae0816f2 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1251,6 +1251,9 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived) goto err; JOIN *join= unit->first_select()->join; join->first_record= false; + if (join->zero_result_cause) + goto err; + for (uint i= join->top_join_tab_count; i < join->top_join_tab_count + join->aggr_tables; i++) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 29ac123411b3d..49b58dec4ee3c 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1969,7 +1969,7 @@ static void plugin_load(MEM_ROOT *tmp_root) the mutex here to satisfy the assert */ mysql_mutex_lock(&LOCK_plugin); - plugin_add(tmp_root, false, &name, &dl, MYF(ME_ERROR_LOG)); + plugin_add(tmp_root, true, &name, &dl, MYF(ME_ERROR_LOG)); free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE)); mysql_mutex_unlock(&LOCK_plugin); } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 3c41ddbcfafa4..7df38937138ee 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7185,11 +7185,7 @@ alter: | ALTER SEQUENCE_SYM opt_if_exists { LEX *lex= Lex; - lex->name= null_clex_str; - lex->table_type= TABLE_TYPE_UNKNOWN; lex->sql_command= SQLCOM_ALTER_SEQUENCE; - lex->create_info.init(); - lex->no_write_to_binlog= 0; DBUG_ASSERT(!lex->m_sql_cmd); if (Lex->main_select_push()) MYSQL_YYABORT; diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 90ede81a06a35..8767f698bf2e6 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -204,6 +204,11 @@ int wsrep_apply_events(THD* thd, (thd->variables.option_bits & ~OPTION_SKIP_REPLICATION) | (ev->flags & LOG_EVENT_SKIP_REPLICATION_F ? OPTION_SKIP_REPLICATION : 0); + if (ev->get_type_code() == GTID_EVENT) + { + thd->variables.option_bits &= ~OPTION_GTID_BEGIN; + } + ev->thd= thd; exec_res= ev->apply_event(thd->wsrep_rgi); DBUG_PRINT("info", ("exec_event result: %d", exec_res)); diff --git a/sql/wsrep_high_priority_service.cc b/sql/wsrep_high_priority_service.cc index fb93273d10906..ecb0e487f2b37 100644 --- a/sql/wsrep_high_priority_service.cc +++ b/sql/wsrep_high_priority_service.cc @@ -569,6 +569,7 @@ int Wsrep_applier_service::apply_write_set(const wsrep::ws_meta& ws_meta, THD* thd= m_thd; thd->variables.option_bits |= OPTION_BEGIN; + thd->variables.option_bits |= OPTION_GTID_BEGIN; thd->variables.option_bits |= OPTION_NOT_AUTOCOMMIT; DBUG_ASSERT(thd->wsrep_trx().active()); DBUG_ASSERT(thd->wsrep_trx().state() == wsrep::transaction::s_executing); @@ -600,6 +601,8 @@ int Wsrep_applier_service::apply_write_set(const wsrep::ws_meta& ws_meta, thd->wsrep_cs().fragment_applied(ws_meta.seqno()); } thd_proc_info(thd, "wsrep applied write set"); + + thd->variables.option_bits &= ~OPTION_GTID_BEGIN; DBUG_RETURN(ret); } diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 9574e0b0adf6d..dfa995dc16e86 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -786,16 +786,7 @@ class mem_pressure if ((m_fds[m_num_fds].fd= open(memcgroup.c_str(), O_RDWR | O_NONBLOCK | O_CLOEXEC)) < 0) { - switch (errno) { - case EPERM: - /* https://lore.kernel.org/all/CAMw=ZnQ56cm4Txgy5EhGYvR+Jt4s-KVgoA9_65HKWVMOXp7a9A@mail.gmail.com/T/#m3bd2a73c5ee49965cb73a830b1ccaa37ccf4e427 */ - sql_print_information("InnoDB: Failed to initialize memory pressure EPERM, " - "file permissions."); - break; - default: - sql_print_information("InnoDB: Failed to initialize memory pressure: %s", - strerror(errno)); - } + /* User can't do anything about it, no point giving warning */ shutdown(); return false; } @@ -803,7 +794,7 @@ class mem_pressure ssize_t slen= strlen(*trig); if (write(m_fds[m_num_fds].fd, *trig, slen) < slen) { - sql_print_warning("InnoDB: Failed create trigger for memory pressure \"%s\"", *trig); + /* we may fail this one, but continue to the next */ my_close(m_fds[m_num_fds].fd, MYF(MY_WME)); continue; } @@ -815,7 +806,7 @@ class mem_pressure if ((m_event_fd= eventfd(0, EFD_CLOEXEC|EFD_NONBLOCK)) == -1) { - sql_print_warning("InnoDB: No memory pressure - can't create eventfd"); + /* User can't do anything about it, no point giving warning */ shutdown(); return false; } @@ -824,6 +815,7 @@ class mem_pressure m_fds[m_num_fds].events= POLLIN; m_num_fds++; m_thd= std::thread(pressure_routine, this); + sql_print_information("InnoDB: Initialized memory pressure event listener"); return true; } @@ -1309,7 +1301,8 @@ bool buf_pool_t::create() btr_search_sys_create(); #ifdef __linux__ - buf_mem_pressure_detect_init(); + if (srv_operation == SRV_OPERATION_NORMAL) + buf_mem_pressure_detect_init(); #endif ut_ad(is_initialised()); return false; diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index 17c640d5ea086..70e7184508317 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -586,6 +586,12 @@ ulint buf_read_ahead_linear(const page_id_t page_id, ulint zip_size) uint32_t prev= mach_read_from_4(my_assume_aligned<4>(f + FIL_PAGE_PREV)); uint32_t next= mach_read_from_4(my_assume_aligned<4>(f + FIL_PAGE_NEXT)); hash_lock.unlock_shared(); + /* The underlying file page of this buffer pool page could actually + be marked as freed, or a read of the page into the buffer pool might + be in progress. We may read uninitialized data here. + Suppress warnings of comparing uninitialized values. */ + MEM_MAKE_DEFINED(&prev, sizeof prev); + MEM_MAKE_DEFINED(&next, sizeof next); if (prev == FIL_NULL || next == FIL_NULL) goto fail; page_id_t id= page_id; diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index a5edfe42eca80..001783de73d1f 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -747,16 +747,9 @@ dict_stats_empty_index( } } -/*********************************************************************//** -Write all zeros (or 1 where it makes sense) into a table and its indexes' -statistics members. The resulting stats correspond to an empty table. */ -static -void -dict_stats_empty_table( -/*===================*/ - dict_table_t* table, /*!< in/out: table */ +void dict_stats_empty_table( + dict_table_t* table, bool empty_defrag_stats) - /*!< in: whether to empty defrag stats */ { /* Initialize table/index level stats is now protected by table level lock_mutex.*/ diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 3b28c21db5954..65ae3155e76a5 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -14676,12 +14676,7 @@ ha_innobase::info_low( DBUG_ASSERT(ib_table->get_ref_count() > 0); if (!ib_table->is_readable()) { - ib_table->stats_mutex_lock(); - ib_table->stat_initialized = true; - ib_table->stat_n_rows = 0; - ib_table->stat_clustered_index_size = 0; - ib_table->stat_sum_of_other_index_sizes = 0; - ib_table->stats_mutex_unlock(); + dict_stats_empty_table(ib_table, true); } if (flag & HA_STATUS_TIME) { @@ -20567,6 +20562,10 @@ Compare_keys ha_innobase::compare_key_parts( if (old_part.length >= new_part.length) return Compare_keys::NotEqual; + if (old_part.length == old_field.key_length() && + new_part.length != new_field.length) + return Compare_keys::NotEqual; + return Compare_keys::EqualButKeyPartLength; } diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 663d6c14fe477..981520a0f5289 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -2317,12 +2317,16 @@ ha_innobase::check_if_supported_inplace_alter( } } + bool need_rebuild = false; + switch (ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE) { case ALTER_OPTIONS: - if (alter_options_need_rebuild(ha_alter_info, table)) { + if ((srv_file_per_table && !m_prebuilt->table->space_id) + || alter_options_need_rebuild(ha_alter_info, table)) { reason_rebuild = my_get_err_msg( ER_ALTER_OPERATION_TABLE_OPTIONS_NEED_REBUILD); ha_alter_info->unsupported_reason = reason_rebuild; + need_rebuild= true; break; } /* fall through */ @@ -2434,7 +2438,7 @@ ha_innobase::check_if_supported_inplace_alter( /* We should be able to do the operation in-place. See if we can do it online (LOCK=NONE) or without rebuild. */ - bool online = true, need_rebuild = false; + bool online = true; const uint fulltext_indexes = innobase_fulltext_exist(altered_table); /* Fix the key parts. */ diff --git a/storage/innobase/include/dict0stats.h b/storage/innobase/include/dict0stats.h index 0dc1b984577ce..3b006daf53c5c 100644 --- a/storage/innobase/include/dict0stats.h +++ b/storage/innobase/include/dict0stats.h @@ -235,4 +235,13 @@ dict_stats_report_error(dict_table_t* table, bool defragment = false) void test_dict_stats_all(); #endif /* UNIV_ENABLE_UNIT_TEST_DICT_STATS */ +/** Write all zeros (or 1 where it makes sense) into a table +and its indexes'statistics members. The resulting stats +correspond to an empty table. +@param table table stats to be emptied +@param empty_defrag_stats empty the defrag stats */ +void +dict_stats_empty_table( + dict_table_t* table, + bool empty_defrag_stats); #endif /* dict0stats_h */ diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 809b9110a6a37..c786583118e44 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -117,7 +117,6 @@ struct row_import { row_import() UNIV_NOTHROW : m_table(NULL), - m_version(0), m_hostname(NULL), m_table_name(NULL), m_autoinc(0), @@ -196,8 +195,6 @@ struct row_import { dict_table_t* m_table; /*!< Table instance */ - ulint m_version; /*!< Version of config file */ - byte* m_hostname; /*!< Hostname where the tablespace was exported */ byte* m_table_name; /*!< Exporting instance table @@ -2963,17 +2960,13 @@ row_import_read_meta_data( return(DB_IO_ERROR); } - cfg.m_version = mach_read_from_4(row); - /* Check the version number. */ - switch (cfg.m_version) { + switch (mach_read_from_4(row)) { case IB_EXPORT_CFG_VERSION_V1: - return(row_import_read_v1(file, thd, &cfg)); default: - ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR, - "Unsupported meta-data version number (" ULINTPF "), " - "file ignored", cfg.m_version); + ib_senderrf(thd, IB_LOG_LEVEL_ERROR, ER_NOT_SUPPORTED_YET, + "meta-data version"); } return(DB_ERROR); diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index b261a40cf3e20..ddc4d400a18c2 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -685,8 +685,17 @@ TRANSACTIONAL_TARGET void trx_purge_truncate_history() mini-transaction commit and the server was killed, then discarding the to-be-trimmed pages without flushing would break crash recovery. */ - mysql_mutex_lock(&buf_pool.flush_list_mutex); + rescan: + if (UNIV_UNLIKELY(srv_shutdown_state != SRV_SHUTDOWN_NONE) && + srv_fast_shutdown) + { + fast_shutdown: + mtr.commit(); + return; + } + + mysql_mutex_lock(&buf_pool.flush_list_mutex); for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.flush_list); bpage; ) { ut_ad(bpage->oldest_modification()); @@ -728,7 +737,17 @@ TRANSACTIONAL_TARGET void trx_purge_truncate_history() mysql_mutex_lock(&buf_pool.flush_list_mutex); if (prev != buf_pool.flush_hp.get()) + { + /* The functions buf_pool_t::release_freed_page() or + buf_do_flush_list_batch() may be right now holding + buf_pool.mutex and waiting to acquire + buf_pool.flush_list_mutex. Ensure that they can proceed, + to avoid extreme waits. */ + mysql_mutex_unlock(&buf_pool.flush_list_mutex); + mysql_mutex_lock(&buf_pool.mutex); + mysql_mutex_unlock(&buf_pool.mutex); goto rescan; + } } bpage= prev; @@ -736,6 +755,10 @@ TRANSACTIONAL_TARGET void trx_purge_truncate_history() mysql_mutex_unlock(&buf_pool.flush_list_mutex); + if (UNIV_UNLIKELY(srv_shutdown_state != SRV_SHUTDOWN_NONE) && + srv_fast_shutdown) + goto fast_shutdown; + /* Re-initialize tablespace, in a single mini-transaction. */ const ulint size= SRV_UNDO_TABLESPACE_SIZE_IN_PAGES; diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index feb525f3bdca4..d0231d5409013 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -472,24 +472,25 @@ static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, mtr_t *mtr) /* Always prefer a position from rollback segment over a legacy position from before version 10.3.5. */ - int cmp = *trx_sys.recovered_binlog_filename && - !trx_sys.recovered_binlog_is_legacy_pos - ? strncmp((const char*)(binlog_name), - trx_sys.recovered_binlog_filename, - TRX_RSEG_BINLOG_NAME_LEN) - : 1; + int cmp= *trx_sys.recovered_binlog_filename && + !trx_sys.recovered_binlog_is_legacy_pos + ? strncmp(reinterpret_cast(binlog_name), + trx_sys.recovered_binlog_filename, + TRX_RSEG_BINLOG_NAME_LEN) + : 1; if (cmp >= 0) { uint64_t binlog_offset = - mach_read_from_8(TRX_RSEG + TRX_RSEG_BINLOG_OFFSET - + rseg_hdr->page.frame); - if (cmp) { + mach_read_from_8(TRX_RSEG + TRX_RSEG_BINLOG_OFFSET + + rseg_hdr->page.frame); + if (cmp) + { memcpy(trx_sys.recovered_binlog_filename, binlog_name, TRX_RSEG_BINLOG_NAME_LEN); - trx_sys.recovered_binlog_offset = binlog_offset; - } else if (binlog_offset > trx_sys.recovered_binlog_offset) { - trx_sys.recovered_binlog_offset = binlog_offset; + trx_sys.recovered_binlog_offset= binlog_offset; } + else if (binlog_offset > trx_sys.recovered_binlog_offset) + trx_sys.recovered_binlog_offset= binlog_offset; trx_sys.recovered_binlog_is_legacy_pos= false; } #ifdef WITH_WSREP diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_28683.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_28683.result new file mode 100644 index 0000000000000..358c794ef868d --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_28683.result @@ -0,0 +1,22 @@ +# +# MDEV-28683 Spider: SIGSEGV in spider_db_direct_delete, SIGSEGV in spider_db_connect, ASAN: heap-use-after-free in spider_db_direct_delete +# +for master_1 +for child2 +for child3 +CREATE TABLE t (c INT) ENGINE=Spider; +SELECT * FROM t; +ERROR HY000: Unable to connect to foreign data source: localhost +INSERT INTO t (SELECT 1 FROM t); +ERROR HY000: Unable to connect to foreign data source: localhost +LOCK TABLES t WRITE CONCURRENT; +DELETE FROM t; +ERROR HY000: Unable to connect to foreign data source: localhost +UNLOCK TABLES; +DROP TABLE t; +for master_1 +for child2 +for child3 +# +# end of test mdev_28683 +# diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_28739_simple.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_28739_simple.result new file mode 100644 index 0000000000000..db232f8a6d373 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_28739_simple.result @@ -0,0 +1,20 @@ +# +# MDEV-28739 Trying to lock uninitialized mutex or hang upon shutdown after using Spider with query_cache +# +for master_1 +for child2 +for child3 +set global query_cache_type= on; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +create table t2 (c int); +create table t1 (c int) ENGINE=Spider +COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; +SELECT * FROM t1; +c +# restart +drop table t1, t2; +drop server srv; +for master_1 +for child2 +for child3