From ee773753778e741c1aff1449fcd41b775701a4db Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Wed, 7 Dec 2022 14:14:24 +0100 Subject: [PATCH 1/9] MDEV-26875: Wrong user in SET DEFAULT ROLE error - Regression introduced in 957cb7b7ba35 - Patch 4abb8216a054 change `mysql.user` to `mysql.global_priv` for `add_anonymous.inc`, update `delete_anonymous.inc`. - Added test case with `--skip-name-resolve` - Add test case with anonymous user - Disable this test for windows, assignes current user to anonymous user. Reviewed by: --- mysql-test/include/delete_anonymous_users.inc | 2 +- .../suite/roles/set_default_role_for.result | 2 +- .../roles/set_default_role_invalid.result | 6 +- .../suite/roles/set_default_role_invalid.test | 1 - ..._role_invalid_skip_name_resolve-master.opt | 1 + ...ault_role_invalid_skip_name_resolve.result | 85 +++++++++++++++++++ ...efault_role_invalid_skip_name_resolve.test | 78 +++++++++++++++++ sql/sql_acl.cc | 16 +++- 8 files changed, 181 insertions(+), 10 deletions(-) create mode 100644 mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve-master.opt create mode 100644 mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve.result create mode 100644 mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve.test diff --git a/mysql-test/include/delete_anonymous_users.inc b/mysql-test/include/delete_anonymous_users.inc index 704e74ae4a3..cc44a01fe8d 100644 --- a/mysql-test/include/delete_anonymous_users.inc +++ b/mysql-test/include/delete_anonymous_users.inc @@ -1,7 +1,7 @@ # Remove anonymous users added by add_anonymous_users.inc disable_warnings; disable_query_log; -DELETE FROM mysql.user where host='localhost' and user=''; +DELETE FROM mysql.global_priv where host='localhost' and user=''; FLUSH PRIVILEGES; enable_query_log; enable_warnings; diff --git a/mysql-test/suite/roles/set_default_role_for.result b/mysql-test/suite/roles/set_default_role_for.result index 57a1471126c..1b133b1baae 100644 --- a/mysql-test/suite/roles/set_default_role_for.result +++ b/mysql-test/suite/roles/set_default_role_for.result @@ -14,7 +14,7 @@ set default role role_a for user_a@localhost; set default role invalid_role for user_a@localhost; ERROR OP000: Invalid role specification `invalid_role` set default role role_b for user_a@localhost; -ERROR OP000: User `root`@`localhost` has not been granted role `role_b` +ERROR OP000: User `user_a`@`localhost` has not been granted role `role_b` set default role role_b for user_b@localhost; show grants; Grants for user_a@localhost diff --git a/mysql-test/suite/roles/set_default_role_invalid.result b/mysql-test/suite/roles/set_default_role_invalid.result index 12e2c035a7d..2cd84cf2ff0 100644 --- a/mysql-test/suite/roles/set_default_role_invalid.result +++ b/mysql-test/suite/roles/set_default_role_invalid.result @@ -48,7 +48,7 @@ CREATE USER b; CREATE ROLE r1; CREATE ROLE r2; SET DEFAULT ROLE r1 FOR a; -ERROR OP000: User `root`@`localhost` has not been granted role `r1` +ERROR OP000: User `a`@`%` has not been granted role `r1` GRANT r1 TO b; GRANT r2 TO b; SET DEFAULT ROLE r1 FOR b; @@ -100,7 +100,7 @@ GRANT USAGE ON *.* TO `b`@`%` GRANT SELECT, UPDATE ON `mysql`.* TO `b`@`%` SET DEFAULT ROLE `r2` FOR `b`@`%` SET DEFAULT ROLE r1 FOR a; -ERROR OP000: User `b`@`%` has not been granted role `r1` +ERROR OP000: User `a`@`%` has not been granted role `r1` SET DEFAULT ROLE invalid_role; ERROR OP000: Invalid role specification `invalid_role` SET DEFAULT ROLE invalid_role FOR a; @@ -117,7 +117,7 @@ SET DEFAULT ROLE None; # Change user b (session 3: role granted to user a) SET DEFAULT ROLE r1 FOR a; SET DEFAULT ROLE r2 FOR a; -ERROR OP000: User `b`@`%` has not been granted role `r2` +ERROR OP000: User `a`@`%` has not been granted role `r2` SET DEFAULT ROLE invalid_role; ERROR OP000: Invalid role specification `invalid_role` SET DEFAULT ROLE invalid_role FOR a; diff --git a/mysql-test/suite/roles/set_default_role_invalid.test b/mysql-test/suite/roles/set_default_role_invalid.test index 02fca1107e2..d2ef01b8f88 100644 --- a/mysql-test/suite/roles/set_default_role_invalid.test +++ b/mysql-test/suite/roles/set_default_role_invalid.test @@ -70,7 +70,6 @@ CREATE USER a; CREATE USER b; CREATE ROLE r1; CREATE ROLE r2; -# Role has not been granted to user a, but the role is visible to current_user --error ER_INVALID_ROLE SET DEFAULT ROLE r1 FOR a; # Granting roles to user b diff --git a/mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve-master.opt b/mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve-master.opt new file mode 100644 index 00000000000..ec008a812ce --- /dev/null +++ b/mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve-master.opt @@ -0,0 +1 @@ +--skip-name-resolve \ No newline at end of file diff --git a/mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve.result b/mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve.result new file mode 100644 index 00000000000..a267e114012 --- /dev/null +++ b/mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve.result @@ -0,0 +1,85 @@ +# +# MDEV-26875: Wrong user in SET DEFAULT ROLE error +# +create user test_user; +create role test_role; +show grants for test_user; +Grants for test_user@% +GRANT USAGE ON *.* TO `test_user`@`%` +set default role test_role for test_user; +ERROR OP000: User `test_user`@`%` has not been granted role `test_role` +grant test_role to test_user; +set default role test_role for test_user; +show grants for test_user; +Grants for test_user@% +GRANT `test_role` TO `test_user`@`%` +GRANT USAGE ON *.* TO `test_user`@`%` +SET DEFAULT ROLE `test_role` FOR `test_user`@`%` +set default role none for test_user; +# +# Try to set default role to role(`test_role`). +-------------------------------------------------------------- +show grants for test_role; +Grants for test_role +GRANT USAGE ON *.* TO `test_role` +create role new_role; +grant new_role to test_role; +show grants for test_role; +Grants for test_role +GRANT `new_role` TO `test_role` +GRANT USAGE ON *.* TO `test_role` +GRANT USAGE ON *.* TO `new_role` +set default role new_role for test_role; +ERROR OP000: User `test_role`@`%` has not been granted role `new_role` +# +# Test of errors, where hostname cannot be resolved `test_user` +-------------------------------------------------------------- +grant test_role to test_user@'%'; +set default role test_role for test_user@'%'; +connect con_test_user,127.0.0.1,test_user,,,$MASTER_MYPORT; +show grants; +Grants for test_user@% +GRANT `test_role` TO `test_user`@`%` +GRANT USAGE ON *.* TO `test_user`@`%` +GRANT `new_role` TO `test_role` +GRANT USAGE ON *.* TO `test_role` +GRANT USAGE ON *.* TO `new_role` +SET DEFAULT ROLE `test_role` FOR `test_user`@`%` +select current_role; +current_role +test_role +set role `new_role`; +ERROR OP000: User `test_user`@`%` has not been granted role `new_role` +connection default; +set default role none for test_user; +disconnect con_test_user; +connect con_test_user,127.0.0.1,test_user,,,$MASTER_MYPORT; +select current_role; +current_role +NULL +set role `new_role`; +ERROR OP000: User `test_user`@`%` has not been granted role `new_role` +connection default; +disconnect con_test_user; +# +# Test of anonymous user connection +-------------------------------------------------------------- +grant test_role to ''@localhost; +connect con1,localhost,'',,,$MASTER_MYPORT; +SELECT CURRENT_ROLE; +CURRENT_ROLE +NULL +SET role test_role; +SELECT CURRENT_ROLE; +CURRENT_ROLE +test_role +SET role new_role; +ERROR OP000: User ``@`localhost` has not been granted role `new_role` +set default role test_role for ''@localhost; +ERROR 42000: You are using MariaDB as an anonymous user and anonymous users are not allowed to modify user settings +connection default; +disconnect con1; +REVOKE all privileges, grant option from ''@localhost; +drop role new_role; +drop role test_role; +drop user test_user; diff --git a/mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve.test b/mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve.test new file mode 100644 index 00000000000..5b4b14d3377 --- /dev/null +++ b/mysql-test/suite/roles/set_default_role_invalid_skip_name_resolve.test @@ -0,0 +1,78 @@ +source include/not_embedded.inc; + +--echo # +--echo # MDEV-26875: Wrong user in SET DEFAULT ROLE error +--echo # +create user test_user; +create role test_role; +show grants for test_user; +--error ER_INVALID_ROLE +set default role test_role for test_user; +grant test_role to test_user; +set default role test_role for test_user; +show grants for test_user; +set default role none for test_user; + +--echo # +--echo # Try to set default role to role(`test_role`). +--echo -------------------------------------------------------------- +show grants for test_role; +create role new_role; +grant new_role to test_role; +show grants for test_role; +# One can not set role to a role +--error ER_INVALID_ROLE +set default role new_role for test_role; + +--echo # +--echo # Test of errors, where hostname cannot be resolved `test_user` +--echo -------------------------------------------------------------- +# `new_role` is granted to `test_role` +grant test_role to test_user@'%'; +set default role test_role for test_user@'%'; + +connect con_test_user,127.0.0.1,test_user,,,$MASTER_MYPORT; +show grants; +select current_role; +# `test_user` indirectly granted `new_role` +--error ER_INVALID_ROLE +set role `new_role`; + +connection default; +set default role none for test_user; +disconnect con_test_user; + +connect con_test_user,127.0.0.1,test_user,,,$MASTER_MYPORT; +select current_role; +--error ER_INVALID_ROLE +set role `new_role`; + +connection default; +disconnect con_test_user; + +--echo # +--echo # Test of anonymous user connection +--echo -------------------------------------------------------------- +--source include/add_anonymous_users.inc +# Skip windows, since it uses current user `Administrator` in buildbot. +--source include/not_windows.inc +grant test_role to ''@localhost; + +connect(con1,localhost,'',,,$MASTER_MYPORT); +SELECT CURRENT_ROLE; +SET role test_role; +SELECT CURRENT_ROLE; +# user cannot set subset role, since it is not granted explicitly +--error ER_INVALID_ROLE +SET role new_role; +--error ER_PASSWORD_ANONYMOUS_USER +set default role test_role for ''@localhost; + +connection default; +disconnect con1; +REVOKE all privileges, grant option from ''@localhost; +--source include/delete_anonymous_users.inc + +drop role new_role; +drop role test_role; +drop user test_user; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 5468c19f531..3735d9e965d 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3339,10 +3339,18 @@ end: check_role_is_granted_callback, NULL) == -1)) { - /* Role is not granted but current user can see the role */ - my_printf_error(ER_INVALID_ROLE, "User %`s@%`s has not been granted role %`s", - MYF(0), thd->security_ctx->priv_user, - thd->security_ctx->priv_host, rolename); + /* This happens for SET ROLE case and when `--skip-name-resolve` option + is used. In that situation host can be NULL and current user is always + target user, so printing `priv_user@priv_host` is not incorrect. + */ + if (!host) + my_printf_error(ER_INVALID_ROLE, "User %`s@%`s has not been granted role %`s", + MYF(0), thd->security_ctx->priv_user, + thd->security_ctx->priv_host, rolename); + else + /* Role is not granted but current user can see the role */ + my_printf_error(ER_INVALID_ROLE, "User %`s@%`s has not been granted role %`s", + MYF(0), user, host, rolename); } else { From 4eb8aeee8e15f0267b19487bc0953f27136f6737 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Tue, 17 Oct 2023 15:41:52 +0200 Subject: [PATCH 2/9] MDEV-32462: mysql_upgrade -s still checks for non system tables - Prevent opening of any user tables in case `upgrade-system-table` option is used. - Still there may be uninstalled data types in `mysql` system table so allow it to perform. - Closes PR #2790 - Reviewer: , --- client/mysql_upgrade.c | 2 + ...ql_json_mysql_upgrade_system_tables.result | 93 +++++++++++++++++++ ...ysql_json_mysql_upgrade_system_tables.test | 52 +++++++++++ 3 files changed, 147 insertions(+) create mode 100644 mysql-test/main/mysql_json_mysql_upgrade_system_tables.result create mode 100644 mysql-test/main/mysql_json_mysql_upgrade_system_tables.test diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 60eb61938d4..617d5464e34 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1155,6 +1155,8 @@ static int install_used_plugin_data_types(void) DYNAMIC_STRING ds_result; const char *query = "SELECT table_comment FROM information_schema.tables" " WHERE table_comment LIKE 'Unknown data type: %'"; + if (opt_systables_only) + return 0; if (init_dynamic_string(&ds_result, "", 512, 512)) die("Out of memory"); run_query(query, &ds_result, TRUE); diff --git a/mysql-test/main/mysql_json_mysql_upgrade_system_tables.result b/mysql-test/main/mysql_json_mysql_upgrade_system_tables.result new file mode 100644 index 00000000000..95ca68f43a6 --- /dev/null +++ b/mysql-test/main/mysql_json_mysql_upgrade_system_tables.result @@ -0,0 +1,93 @@ +# +# MDEV-32462: mysql_upgrade -s still checks for non system tables +# +call mtr.add_suppression("Table rebuild required"); +SET NAMES utf8; +# mariadb_upgrade on system and user table +show tables from mysql like '%json%'; +Tables_in_mysql (%json%) +mysql_json_test +use mysql; +show create table mysql.mysql_json_test; +ERROR HY000: Unknown data type: 'MYSQL_JSON' +show create table test.mysql_json_test; +ERROR HY000: Unknown data type: 'MYSQL_JSON' +SET @old_general_log= @@global.general_log; +SET @old_log_output= @@global.log_output; +SET @@global.general_log = ON; +SET @@global.log_output = "TABLE"; +The --upgrade-system-tables option was used, user tables won't be touched. +Phase 1/7: Checking and upgrading mysql database +Processing databases +mysql +mysql.column_stats OK +mysql.columns_priv OK +mysql.db OK +mysql.event OK +mysql.func OK +mysql.global_priv OK +mysql.gtid_slave_pos OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.index_stats OK +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.mysql_json_test +Error : Unknown data type: 'MYSQL_JSON' +error : Corrupt +mysql.plugin OK +mysql.proc OK +mysql.procs_priv OK +mysql.proxies_priv OK +mysql.roles_mapping OK +mysql.servers OK +mysql.table_stats OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt + +Repairing tables +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.mysql_json_test +Error : Unknown data type: 'MYSQL_JSON' +error : Corrupt +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt +Phase 2/7: Installing used storage engines... Skipped +Phase 3/7: Fixing views... Skipped +Phase 4/7: Running 'mysql_fix_privilege_tables' +Phase 5/7: Fixing table and database names ... Skipped +Phase 6/7: Checking and upgrading tables... Skipped +Phase 7/7: Running 'FLUSH PRIVILEGES' +OK +SET @@global.general_log = @old_general_log; +SET @@global.log_output = @old_log_output; +select command_type, argument from mysql.general_log where argument like "%SELECT table_comment FROM information_schema.tables%"; +command_type argument +show create table mysql.mysql_json_test; +ERROR HY000: Unknown data type: 'MYSQL_JSON' +show create table test.mysql_json_test; +ERROR HY000: Unknown data type: 'MYSQL_JSON' +drop table mysql.mysql_json_test; +drop table test.mysql_json_test; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/mysql_json_mysql_upgrade_system_tables.test b/mysql-test/main/mysql_json_mysql_upgrade_system_tables.test new file mode 100644 index 00000000000..6ae3e8ddea1 --- /dev/null +++ b/mysql-test/main/mysql_json_mysql_upgrade_system_tables.test @@ -0,0 +1,52 @@ +--echo # +--echo # MDEV-32462: mysql_upgrade -s still checks for non system tables +--echo # + +# Let's now load plugin first +--source include/have_utf8.inc +--source include/not_embedded.inc + +--source include/mysql_upgrade_preparation.inc +call mtr.add_suppression("Table rebuild required"); + +SET NAMES utf8; + +let $MYSQLD_DATADIR= `select @@datadir`; + +--echo # mariadb_upgrade on system and user table +--copy_file std_data/mysql_json/mysql_json_test.frm $MYSQLD_DATADIR/mysql/mysql_json_test.frm +--copy_file std_data/mysql_json/mysql_json_test.MYI $MYSQLD_DATADIR/mysql/mysql_json_test.MYI +--copy_file std_data/mysql_json/mysql_json_test.MYD $MYSQLD_DATADIR/mysql/mysql_json_test.MYD +--copy_file std_data/mysql_json/mysql_json_test.frm $MYSQLD_DATADIR/test/mysql_json_test.frm +--copy_file std_data/mysql_json/mysql_json_test.MYI $MYSQLD_DATADIR/test/mysql_json_test.MYI +--copy_file std_data/mysql_json/mysql_json_test.MYD $MYSQLD_DATADIR/test/mysql_json_test.MYD + +show tables from mysql like '%json%'; +use mysql; +--error ER_UNKNOWN_DATA_TYPE +show create table mysql.mysql_json_test; +--error ER_UNKNOWN_DATA_TYPE +show create table test.mysql_json_test; + +SET @old_general_log= @@global.general_log; +SET @old_log_output= @@global.log_output; +SET @@global.general_log = ON; +SET @@global.log_output = "TABLE"; +--exec $MYSQL_UPGRADE -s --force 2>&1 +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info +SET @@global.general_log = @old_general_log; +SET @@global.log_output = @old_log_output; + +select command_type, argument from mysql.general_log where argument like "%SELECT table_comment FROM information_schema.tables%"; + +# User table is not upgraded in `mysql\test` DB, so we cannot see it. +--error ER_UNKNOWN_DATA_TYPE +show create table mysql.mysql_json_test; +--error ER_UNKNOWN_DATA_TYPE +show create table test.mysql_json_test; +drop table mysql.mysql_json_test; +drop table test.mysql_json_test; + +--echo # +--echo # End of 10.5 tests +--echo # From b06ac9a8cd2146e89270cc2150d306d8ed1b33fb Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Thu, 19 Oct 2023 09:21:18 +0200 Subject: [PATCH 3/9] MDEV-32462: mysql_upgrade -s still checks for non system tables - Rename files as requested by Vicentiu: ``` mysql_json_mysql_upgrade.test -> mysql_upgrade_mysql_json.test mysql_json_mysql_upgrade_with_plugin_loaded.test -> mysql_upgrade_mysql_json_with_plugin_loaded.test mysql_json_mysql_upgrade_system_tables.test -> mysql_upgrade_mysql_json_system_tables.test ``` - Related to PR #2790 - Reviewer: , --- ..._json_mysql_upgrade.result => mysql_upgrade_mysql_json.result} | 0 ...ysql_json_mysql_upgrade.test => mysql_upgrade_mysql_json.test} | 0 ...ables.result => mysql_upgrade_mysql_json_system_tables.result} | 0 ...em_tables.test => mysql_upgrade_mysql_json_system_tables.test} | 0 ....result => mysql_upgrade_mysql_json_with_plugin_loaded.result} | 0 ...aded.test => mysql_upgrade_mysql_json_with_plugin_loaded.test} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename mysql-test/main/{mysql_json_mysql_upgrade.result => mysql_upgrade_mysql_json.result} (100%) rename mysql-test/main/{mysql_json_mysql_upgrade.test => mysql_upgrade_mysql_json.test} (100%) rename mysql-test/main/{mysql_json_mysql_upgrade_system_tables.result => mysql_upgrade_mysql_json_system_tables.result} (100%) rename mysql-test/main/{mysql_json_mysql_upgrade_system_tables.test => mysql_upgrade_mysql_json_system_tables.test} (100%) rename mysql-test/main/{mysql_json_mysql_upgrade_with_plugin_loaded.result => mysql_upgrade_mysql_json_with_plugin_loaded.result} (100%) rename mysql-test/main/{mysql_json_mysql_upgrade_with_plugin_loaded.test => mysql_upgrade_mysql_json_with_plugin_loaded.test} (100%) diff --git a/mysql-test/main/mysql_json_mysql_upgrade.result b/mysql-test/main/mysql_upgrade_mysql_json.result similarity index 100% rename from mysql-test/main/mysql_json_mysql_upgrade.result rename to mysql-test/main/mysql_upgrade_mysql_json.result diff --git a/mysql-test/main/mysql_json_mysql_upgrade.test b/mysql-test/main/mysql_upgrade_mysql_json.test similarity index 100% rename from mysql-test/main/mysql_json_mysql_upgrade.test rename to mysql-test/main/mysql_upgrade_mysql_json.test diff --git a/mysql-test/main/mysql_json_mysql_upgrade_system_tables.result b/mysql-test/main/mysql_upgrade_mysql_json_system_tables.result similarity index 100% rename from mysql-test/main/mysql_json_mysql_upgrade_system_tables.result rename to mysql-test/main/mysql_upgrade_mysql_json_system_tables.result diff --git a/mysql-test/main/mysql_json_mysql_upgrade_system_tables.test b/mysql-test/main/mysql_upgrade_mysql_json_system_tables.test similarity index 100% rename from mysql-test/main/mysql_json_mysql_upgrade_system_tables.test rename to mysql-test/main/mysql_upgrade_mysql_json_system_tables.test diff --git a/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.result b/mysql-test/main/mysql_upgrade_mysql_json_with_plugin_loaded.result similarity index 100% rename from mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.result rename to mysql-test/main/mysql_upgrade_mysql_json_with_plugin_loaded.result diff --git a/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.test b/mysql-test/main/mysql_upgrade_mysql_json_with_plugin_loaded.test similarity index 100% rename from mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.test rename to mysql-test/main/mysql_upgrade_mysql_json_with_plugin_loaded.test From 3c1f324a5560d106f4918eda2d42eb626ab9ed57 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Fri, 3 Nov 2023 14:43:45 +0100 Subject: [PATCH 4/9] MDEV-32672: Don't hold LOCK_thd_data over commit_ordered Partial revert of this commit: commit 6b685ea7b0776430d45b095cb4be3ef0739a3c04 Author: Sergei Golubchik Date: Wed Sep 28 18:55:15 2022 +0200 Don't hold LOCK_thd_data over run_commit_ordered(). Holding the mutex is unnecessary and will deadlock if any code in a commit_ordered handlerton call tries to take the mutex to change THD local data. Instead, set the current_thd for the duration of the call to keep asserts happy around LOCK_thd_data. Signed-off-by: Kristian Nielsen --- sql/log.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 12e2aee94cc..277d8de6701 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -8556,13 +8556,10 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader) DEBUG_SYNC(leader->thd, "commit_loop_entry_commit_ordered"); ++num_commits; + set_current_thd(current->thd); if (current->cache_mngr->using_xa && likely(!current->error) && DBUG_EVALUATE_IF("skip_commit_ordered", 0, 1)) - { - mysql_mutex_lock(¤t->thd->LOCK_thd_data); run_commit_ordered(current->thd, current->all); - mysql_mutex_unlock(¤t->thd->LOCK_thd_data); - } current->thd->wakeup_subsequent_commits(current->error); /* @@ -8579,6 +8576,7 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader) } current= next; } + set_current_thd(leader->thd); DEBUG_SYNC(leader->thd, "commit_after_group_run_commit_ordered"); mysql_mutex_unlock(&LOCK_commit_ordered); DEBUG_SYNC(leader->thd, "commit_after_group_release_commit_ordered"); From c68620df48cd1b0e7f5f1cb5ff8b905a5d9c80a5 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Sat, 4 Nov 2023 20:40:31 +0100 Subject: [PATCH 5/9] Fix random test failures in testcase perfschema.mdl_func The test case can get extra rows in its output from table performance_schema.table_handles, left there by an earlier test case (for example main.long_unique_delayed). So force a server restart at the beginning of the test. Signed-off-by: Kristian Nielsen --- mysql-test/suite/perfschema/r/mdl_func.result | 1 + mysql-test/suite/perfschema/t/mdl_func.test | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/mysql-test/suite/perfschema/r/mdl_func.result b/mysql-test/suite/perfschema/r/mdl_func.result index 4887b15efa5..f3fc0d10a96 100644 --- a/mysql-test/suite/perfschema/r/mdl_func.result +++ b/mysql-test/suite/perfschema/r/mdl_func.result @@ -1,3 +1,4 @@ +# restart UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES'; UPDATE performance_schema.setup_instruments SET enabled = 'YES' WHERE name in ('wait/io/table/sql/handler', diff --git a/mysql-test/suite/perfschema/t/mdl_func.test b/mysql-test/suite/perfschema/t/mdl_func.test index c7f5585a5c2..209c2f112af 100644 --- a/mysql-test/suite/perfschema/t/mdl_func.test +++ b/mysql-test/suite/perfschema/t/mdl_func.test @@ -1,5 +1,11 @@ --source include/not_embedded.inc --source include/have_perfschema.inc +# This test needs a fresh restart. The table performance_schema.table_handles +# can otherwise contain extra rows left from previous testcases. +# For example the test case main.long_unique_delayed, which uses +# INSERT DELAYED, will leave extra rows in this table if run just before this +# test, causing .result diff failure. +--source include/restart_mysqld.inc UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES'; From e0c65784aa78ea91f7e0ef400bbda9562d07c0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 9 Nov 2023 11:06:17 +0200 Subject: [PATCH 6/9] MDEV-32737 innodb.log_file_name fails on Assertion `after_apply || !(blocks).end in recv_sys_t::clear recv_group_scan_log_recs(): Set the debug flag recv_sys.after_apply after actually completing the log scan. In the test, suppress some errors that may be reported when the crash recovery of RENAME TABLE t1 TO t2 is preceded by copying t2.ibd to t1.ibd. --- mysql-test/suite/innodb/t/log_file_name.test | 2 ++ storage/innobase/log/log0recv.cc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/t/log_file_name.test b/mysql-test/suite/innodb/t/log_file_name.test index c153c38e54b..11eca0a7a12 100644 --- a/mysql-test/suite/innodb/t/log_file_name.test +++ b/mysql-test/suite/innodb/t/log_file_name.test @@ -170,6 +170,8 @@ call mtr.add_suppression("InnoDB: Plugin initialization aborted"); call mtr.add_suppression("Plugin 'InnoDB' \(init function returned error\|registration as a STORAGE ENGINE failed\)"); call mtr.add_suppression("InnoDB: Table test/u[123] in the InnoDB data dictionary has tablespace id [1-9][0-9]*, but tablespace with that id or name does not exist\\. Have you deleted or moved \\.ibd files\\?"); call mtr.add_suppression("InnoDB: Cannot replay rename of tablespace.*"); +call mtr.add_suppression("InnoDB: Attempted to open a previously opened tablespace"); +call mtr.add_suppression("InnoDB: Recovery cannot access file"); FLUSH TABLES; --enable_query_log diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index a213b4842ce..59c4682552f 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -3203,7 +3203,6 @@ recv_group_scan_log_recs( log_sys.log.scanned_lsn = end_lsn = *contiguous_lsn = ut_uint64_align_down(*contiguous_lsn, OS_FILE_LOG_BLOCK_SIZE); - ut_d(recv_sys.after_apply = last_phase); do { if (last_phase && store == STORE_NO) { @@ -3226,6 +3225,7 @@ recv_group_scan_log_recs( DBUG_RETURN(false); } + ut_d(recv_sys.after_apply = last_phase); DBUG_PRINT("ib_log", ("%s " LSN_PF " completed", last_phase ? "rescan" : "scan", log_sys.log.scanned_lsn)); From c3fdfbdbd82c43f867ed82232e3b3077c485c5e1 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Fri, 10 Nov 2023 13:54:25 +0100 Subject: [PATCH 7/9] MDEV-31413: post-fix for 10.5+ (galera_restart_replica test failures) --- mysql-test/suite/galera/t/galera_restart_replica.test | 2 +- sql/rpl_gtid.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/t/galera_restart_replica.test b/mysql-test/suite/galera/t/galera_restart_replica.test index 2cc3a1dcff2..37cfd9bc0f9 100644 --- a/mysql-test/suite/galera/t/galera_restart_replica.test +++ b/mysql-test/suite/galera/t/galera_restart_replica.test @@ -3,9 +3,9 @@ # # The galera/galera_2node_slave.cnf describes the setup of the nodes # ---source include/big_test.inc --source include/force_restart.inc --source include/galera_cluster.inc +--source include/have_innodb.inc --source include/have_sequence.inc # As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index 26a86c60608..3f519f67eb6 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -703,6 +703,7 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id, if (WSREP_ON_ && wsrep_thd_is_local(thd)) { thd->wsrep_ignore_table= false; + table->file->row_logging= 1; // replication requires binary logging wsrep_start_trx_if_not_started(thd); } else From 9da247b2e727ce87c1c10d81ec54601d473ca896 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Sat, 11 Nov 2023 15:37:29 +0100 Subject: [PATCH 8/9] galera: cleanup of the lists of disabled tests --- mysql-test/suite/galera/disabled.def | 14 ++++++++------ mysql-test/suite/galera_3nodes/disabled.def | 7 +++---- mysql-test/suite/galera_3nodes_sr/disabled.def | 2 +- mysql-test/suite/galera_sr/disabled.def | 3 +-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 104a631f8b7..c5412874929 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -14,9 +14,11 @@ galera_as_slave_ctas : MDEV-28378 timeout galera_pc_recovery : MDEV-25199 cluster fails to start up galera_sst_encrypted : MDEV-29876 Galera test failure on galera_sst_encrypted galera_var_node_address : MDEV-20485 Galera test failure -MDEV-26575 : MDEV-29878 Galera test failure on MDEV-26575 -galera_bf_abort_shutdown : MDEV-29918 Assertion failure on galera_bf_abort_shutdown -galera_var_ignore_apply_errors : 28: "Server did not transition to READY state" -versioning_trx_id : MDEV-18590: galera.versioning_trx_id: Test failure: mysqltest: Result content mismatch -MDEV-27713 : test is using get_lock(), which is now rejected in cluster -galera_bf_abort_group_commit : MDEV-30855 PR to remove the test exists +galera_sequences : MDEV-32561 WSREP FSM failure: no such a transition REPLICATING -> COMMITTED +galera_shutdown_nonprim : MDEV-32635 galera_shutdown_nonprim: mysql_shutdown failed +versioning_trx_id : MDEV-18590 : galera.versioning_trx_id: Test failure: mysqltest: Result content mismatch +galera_concurrent_ctas : MDEV-32779 galera_concurrent_ctas: assertion in the galera::ReplicatorSMM::finish_cert() +galera_as_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() +galera_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() +galera_bf_lock_wait : MDEV-32781 galera_bf_lock_wait test failed +galera_sst_mysqldump_with_key : MDEV-32782 galera_sst_mysqldump_with_key test failed diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def index dc08e0981bd..3986bc69dcf 100644 --- a/mysql-test/suite/galera_3nodes/disabled.def +++ b/mysql-test/suite/galera_3nodes/disabled.def @@ -10,8 +10,7 @@ # ############################################################################## - -galera_2_cluster : MDEV-29877 Galera test failure on galera_2_cluster -galera_gtid_2_cluster : MDEV-29877 Galera test failure on galera_2_cluster +galera_2_cluster : MDEV-32631 galera_2_cluster: before_rollback(): Assertion `0' failed +galera_gtid_2_cluster : MDEV-32633 galera_gtid_2_cluster: Assertion `thd->wsrep_next_trx_id() != (0x7fffffffffffffffLL * 2ULL + 1)' galera_vote_rejoin_mysqldump : MDEV-24481: galera_3nodes.galera_vote_rejoin_mysqldump MTR failed: mysql_shutdown failed -galera_ssl_reload : MDEV-30172 At line 50: mysql_shutdown failed +galera_ssl_reload : MDEV-32778 galera_ssl_reload failed with warning message diff --git a/mysql-test/suite/galera_3nodes_sr/disabled.def b/mysql-test/suite/galera_3nodes_sr/disabled.def index df2277fb8ad..4472d960d9f 100644 --- a/mysql-test/suite/galera_3nodes_sr/disabled.def +++ b/mysql-test/suite/galera_3nodes_sr/disabled.def @@ -10,4 +10,4 @@ # ############################################################################## -galera_sr_kill_slave_after_apply_rollback2 : MDEV-29892 Galera test failure on galera_sr_kill_slave_after_apply_rollback2 \ No newline at end of file +galera_sr_kill_slave_after_apply_rollback2 : MDEV-29892 Galera test failure on galera_sr_kill_slave_after_apply_rollback2 diff --git a/mysql-test/suite/galera_sr/disabled.def b/mysql-test/suite/galera_sr/disabled.def index 1132a0097c4..fa62168d474 100644 --- a/mysql-test/suite/galera_sr/disabled.def +++ b/mysql-test/suite/galera_sr/disabled.def @@ -10,6 +10,5 @@ # ############################################################################## -GCF-1060 : MDEV-26528 wrong usage of mutex LOCK_thd_kill and LOCK_thd_kill +GCF-1060 : MDEV-32160 GCF-1060 test failure due to wsrep MDL conflict galera_sr_cc_master : MDEV-29882 Galera test failure on galera_sr_cc_master -mysql-wsrep-features#138 : At line 25: query 'DROP TABLE t1' failed: 2013: Lost connection to MySQL server during query From 8b84fb13837d0964211d52916e2eea82bb3d2e16 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Mon, 13 Nov 2023 13:21:35 -0500 Subject: [PATCH 9/9] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0f8a4608896..e7b29db2217 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=23 +MYSQL_VERSION_PATCH=24 SERVER_MATURITY=stable