From 868bc463c04948b649d907c731ca126b7f68fe4c Mon Sep 17 00:00:00 2001 From: Akshat Nehra Date: Fri, 24 Jan 2025 20:18:46 +0000 Subject: [PATCH 01/10] MDEV-4151 Mixed MySQL/MariaDB references in RPM upgrade error message Update pre-install script to fix package detection and standardize MariaDB/MySQL terminology in messages for improved upgrade reliability and reduced user confusion. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- support-files/rpm/server-prein.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/support-files/rpm/server-prein.sh b/support-files/rpm/server-prein.sh index 17cce6b5ba8..af04b343910 100644 --- a/support-files/rpm/server-prein.sh +++ b/support-files/rpm/server-prein.sh @@ -28,10 +28,11 @@ startup script in %{_sysconfdir}/init.d/. if [ "$old_family" != "$new_family" ]; then error_text="$error_text -Upgrading directly from MySQL $old_family to MariaDB $new_family may not -be safe in all cases. A manual dump and restore using mysqldump is -recommended. It is important to review the MariaDB manual's Upgrading -section for version-specific incompatibilities. +Upgrading directly from MariaDB or MySQL $old_family +to MariaDB $new_family may not be safe in all cases. +A manual dump and restore using mariadb-dump (or mysqldump) is recommended. +It is important to review the MariaDB manual's Upgrading section for +version-specific incompatibilities. " fi @@ -39,23 +40,23 @@ section for version-specific incompatibilities. cat <&2 ****************************************************************** -A MySQL or MariaDB server package ($installed) is installed. +A MariaDB or MySQL server package ($installed) is installed. $error_text A manual upgrade is required. - Ensure that you have a complete, working backup of your data and my.cnf files -- Shut down the MySQL server cleanly -- Remove the existing MySQL packages. Usually this command will +- Shut down the MariaDB or MySQL server cleanly +- Remove the existing MariaDB or MySQL packages. Usually this command will list the packages you should remove: - rpm -qa | grep -i '^mysql-' + rpm -qa | grep -iE '^(mariadb|mysql)-' You may choose to use 'rpm --nodeps -ev ' to remove the package which contains the mysqlclient shared library. The library will be reinstalled by the MariaDB-shared package. - Install the new MariaDB packages supplied by $myvendor - Ensure that the MariaDB server is started -- Run the 'mysql_upgrade' program +- Run the 'mariadb-upgrade' program This is a brief description of the upgrade process. Important details can be found in the MariaDB manual, in the Upgrading section. @@ -65,8 +66,8 @@ HERE fi fi -# Create a MySQL user and group. Do not report any problems if it already exists. +# Create a MariaDB user and group. Do not report any problems if it already exists. groupadd -r %{mysqld_group} 2> /dev/null || true -useradd -M -r --home %{mysqldatadir} --shell /sbin/nologin --comment "MySQL server" --gid %{mysqld_group} %{mysqld_user} 2> /dev/null || true +useradd -M -r --home %{mysqldatadir} --shell /sbin/nologin --comment "MariaDB server" --gid %{mysqld_group} %{mysqld_user} 2> /dev/null || true # The user may already exist, make sure it has the proper group nevertheless (BUG#12823) usermod --gid %{mysqld_group} %{mysqld_user} 2> /dev/null || true From b6b6bb8d36b8dd72150647570833ec60a037a237 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Sat, 8 Mar 2025 07:27:04 +0100 Subject: [PATCH 02/10] Fix sporadic failures of rpl.rpl_gtid_crash - Suppress a couple errors the slave can get as the master crashes. - The mysql-test-run occasionally takes 120 seconds between crashing the master and starting it back up for some (unknown) reason. For now, work-around that by letting the slave try for 500 seconds to connect to master before giving up instead of only 100 seconds. Reviewed-by: Brandon Nesterenko Signed-off-by: Kristian Nielsen --- mysql-test/suite/rpl/r/rpl_gtid_crash.result | 2 ++ mysql-test/suite/rpl/t/rpl_gtid_crash-slave.opt | 2 +- mysql-test/suite/rpl/t/rpl_gtid_crash.test | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/r/rpl_gtid_crash.result b/mysql-test/suite/rpl/r/rpl_gtid_crash.result index 4e74a3b25ac..181db3e28cb 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_crash.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_crash.result @@ -11,6 +11,8 @@ INSERT INTO t1 VALUES (1, 0); connection server_2; SET sql_log_bin=0; call mtr.add_suppression('Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again'); +call mtr.add_suppression('Slave I/O: .*Lost connection to server during query'); +call mtr.add_suppression("Slave I/O thread couldn't register on master"); SET sql_log_bin=1; include/stop_slave.inc CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT, diff --git a/mysql-test/suite/rpl/t/rpl_gtid_crash-slave.opt b/mysql-test/suite/rpl/t/rpl_gtid_crash-slave.opt index 5b3fb44c910..13232d12992 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_crash-slave.opt +++ b/mysql-test/suite/rpl/t/rpl_gtid_crash-slave.opt @@ -1 +1 @@ ---master-retry-count=100 --slave-net-timeout=10 +--master-retry-count=500 --slave-net-timeout=10 diff --git a/mysql-test/suite/rpl/t/rpl_gtid_crash.test b/mysql-test/suite/rpl/t/rpl_gtid_crash.test index f2167911101..032150d2003 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_crash.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_crash.test @@ -23,6 +23,8 @@ INSERT INTO t1 VALUES (1, 0); --sync_with_master SET sql_log_bin=0; call mtr.add_suppression('Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again'); +call mtr.add_suppression('Slave I/O: .*Lost connection to server during query'); +call mtr.add_suppression("Slave I/O thread couldn't register on master"); SET sql_log_bin=1; --source include/stop_slave.inc --replace_result $MASTER_MYPORT MASTER_PORT From acaf07daed13e723db29adb35a73a218f15d24b2 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Thu, 13 Mar 2025 10:43:21 +0100 Subject: [PATCH 03/10] Add --source include/long_test.inc to some tests This will make mysql-test-run.pl try to schedule these long-running (> 60 seconds) tests early in --parallel runs, which helps avoid that the testsuite gets stuck with a few long-running tests at the end while most other test workers are idle. This speed up mtr --parallel=96 with 25 seconds for me. Reviewed-by: Brandon Nesterenko Signed-off-by: Kristian Nielsen --- mysql-test/include/long_test.inc | 2 +- mysql-test/main/backup_locks.test | 1 + mysql-test/suite/binlog_encryption/encrypted_master.test | 1 + mysql-test/suite/funcs_2/t/innodb_charset.test | 2 +- mysql-test/suite/innodb/t/innodb_bug52663.test | 1 + mysql-test/suite/mariabackup/log_page_corruption.test | 2 +- mysql-test/suite/parts/t/partition_exchange_innodb.test | 1 + mysql-test/suite/parts/t/partition_exchange_memory.test | 1 + mysql-test/suite/parts/t/partition_exchange_myisam.test | 1 + mysql-test/suite/rpl/t/rpl_heartbeat_basic.test | 1 + mysql-test/suite/rpl/t/rpl_semi_sync.test | 1 + mysql-test/suite/rpl/t/rpl_semi_sync_after_sync.test | 1 + mysql-test/suite/rpl/t/rpl_semi_sync_after_sync_row.test | 1 + mysql-test/suite/rpl/t/rpl_typeconv.test | 1 + 14 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mysql-test/include/long_test.inc b/mysql-test/include/long_test.inc index 765f88b8037..7f3a3a61778 100644 --- a/mysql-test/include/long_test.inc +++ b/mysql-test/include/long_test.inc @@ -1,6 +1,6 @@ # We use this --source include to mark a test as taking long to run. # We can use this to schedule such test early (to not be left with -# only one or two long tests running, and rests of works idle), or to +# only one or two long tests running, and rests of workers idle), or to # run a quick test skipping long-running test cases. --source include/no_valgrind_without_big.inc diff --git a/mysql-test/main/backup_locks.test b/mysql-test/main/backup_locks.test index 40f12bb7ef8..6a1fe9f6094 100644 --- a/mysql-test/main/backup_locks.test +++ b/mysql-test/main/backup_locks.test @@ -2,6 +2,7 @@ # Tests BACKUP STAGE locking ######################################################################## +--source include/long_test.inc --source include/have_innodb.inc --source include/have_metadata_lock_info.inc --source include/not_embedded.inc diff --git a/mysql-test/suite/binlog_encryption/encrypted_master.test b/mysql-test/suite/binlog_encryption/encrypted_master.test index f6fc172c79e..1539ad29f00 100644 --- a/mysql-test/suite/binlog_encryption/encrypted_master.test +++ b/mysql-test/suite/binlog_encryption/encrypted_master.test @@ -18,6 +18,7 @@ # - with annotated events, default checksums and minimal binlog row image # +--source include/long_test.inc # The test can take very long time with valgrind --source include/not_valgrind.inc diff --git a/mysql-test/suite/funcs_2/t/innodb_charset.test b/mysql-test/suite/funcs_2/t/innodb_charset.test index 631c20352d4..c91a9c4d5d6 100644 --- a/mysql-test/suite/funcs_2/t/innodb_charset.test +++ b/mysql-test/suite/funcs_2/t/innodb_charset.test @@ -6,7 +6,7 @@ # Checking of other prerequisites is in charset_master.test # ################################################################################ ---source include/no_valgrind_without_big.inc +--source include/long_test.inc --source include/have_innodb.inc # Starting with MariaDB 10.6, ensure that DDL recovery will have completed diff --git a/mysql-test/suite/innodb/t/innodb_bug52663.test b/mysql-test/suite/innodb/t/innodb_bug52663.test index fcf97531e00..dd246297d94 100644 --- a/mysql-test/suite/innodb/t/innodb_bug52663.test +++ b/mysql-test/suite/innodb/t/innodb_bug52663.test @@ -1,3 +1,4 @@ +--source include/long_test.inc --source include/have_innodb.inc set session transaction isolation level read committed; diff --git a/mysql-test/suite/mariabackup/log_page_corruption.test b/mysql-test/suite/mariabackup/log_page_corruption.test index 27f2d383b47..e556cba4661 100644 --- a/mysql-test/suite/mariabackup/log_page_corruption.test +++ b/mysql-test/suite/mariabackup/log_page_corruption.test @@ -1,5 +1,5 @@ +--source include/long_test.inc --source include/have_debug.inc ---source include/no_valgrind_without_big.inc --source include/innodb_undo_tablespaces.inc --echo ######## diff --git a/mysql-test/suite/parts/t/partition_exchange_innodb.test b/mysql-test/suite/parts/t/partition_exchange_innodb.test index 31ea61bbb7b..73dd5500a43 100644 --- a/mysql-test/suite/parts/t/partition_exchange_innodb.test +++ b/mysql-test/suite/parts/t/partition_exchange_innodb.test @@ -1,3 +1,4 @@ +--source include/long_test.inc --source include/have_innodb.inc --source include/have_partition.inc --source include/have_debug_sync.inc diff --git a/mysql-test/suite/parts/t/partition_exchange_memory.test b/mysql-test/suite/parts/t/partition_exchange_memory.test index 7384a49f829..431a662f056 100644 --- a/mysql-test/suite/parts/t/partition_exchange_memory.test +++ b/mysql-test/suite/parts/t/partition_exchange_memory.test @@ -1,3 +1,4 @@ +--source include/long_test.inc --source include/have_partition.inc --source include/have_debug_sync.inc diff --git a/mysql-test/suite/parts/t/partition_exchange_myisam.test b/mysql-test/suite/parts/t/partition_exchange_myisam.test index 68e55090a9c..ab3fb388efd 100644 --- a/mysql-test/suite/parts/t/partition_exchange_myisam.test +++ b/mysql-test/suite/parts/t/partition_exchange_myisam.test @@ -1,3 +1,4 @@ +--source include/long_test.inc --source include/have_partition.inc --source include/have_debug_sync.inc diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test index a8857091ef6..0e1ac93882d 100644 --- a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test +++ b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test @@ -9,6 +9,7 @@ # * Various states of master and heartbeat # * Circular replication ############################################################# +--source include/long_test.inc --source include/master-slave.inc # # The test runs long and does not have any specifics to diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync.test b/mysql-test/suite/rpl/t/rpl_semi_sync.test index c3cd918b5fc..0c8c797af56 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync.test @@ -4,6 +4,7 @@ # Please check all dependent tests after modifying it # +source include/long_test.inc; source include/not_embedded.inc; source include/have_innodb.inc; source include/master-slave.inc; diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_after_sync.test b/mysql-test/suite/rpl/t/rpl_semi_sync_after_sync.test index 2d91d2e4118..015dcceb043 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_after_sync.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_after_sync.test @@ -1,3 +1,4 @@ +--source include/long_test.inc --source include/have_binlog_format_statement.inc set global rpl_semi_sync_master_wait_point=AFTER_SYNC; source rpl_semi_sync.test; diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_after_sync_row.test b/mysql-test/suite/rpl/t/rpl_semi_sync_after_sync_row.test index 47af6c34fcf..0ce94b82a67 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_after_sync_row.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_after_sync_row.test @@ -1,3 +1,4 @@ +--source include/long_test.inc --source include/have_binlog_format_row.inc set global rpl_semi_sync_master_wait_point=AFTER_SYNC; source rpl_semi_sync.test; diff --git a/mysql-test/suite/rpl/t/rpl_typeconv.test b/mysql-test/suite/rpl/t/rpl_typeconv.test index 9e566258882..5d8dc67c463 100644 --- a/mysql-test/suite/rpl/t/rpl_typeconv.test +++ b/mysql-test/suite/rpl/t/rpl_typeconv.test @@ -4,6 +4,7 @@ # Please check all dependent tests after modifying it # +--source include/long_test.inc --source include/have_binlog_format_row.inc --source include/master-slave.inc From d931bb8174dd09998493547799a627e92603e863 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Thu, 13 Mar 2025 14:50:25 +0100 Subject: [PATCH 04/10] MDEV-36287: Server crash in SHOW SLAVE STATUS concurrent with STOP SLAVE In SHOW SLAVE STATUS, do not access members of the SQL thread's THD without holding mi->run_lock. Otherwise the THD can go away in case of concurrent STOP SLAVE, leading to invalid memory references and server crash. Reviewed-by: Monty Reviewed-by: Brandon Nesterenko Signed-off-by: Kristian Nielsen --- sql/slave.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index 6f4176f233d..8006c528195 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3162,19 +3162,24 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, if (full) protocol->store(mi->connection_name.str, mi->connection_name.length, &my_charset_bin); + mysql_mutex_lock(&mi->run_lock); + THD *sql_thd= mi->rli.sql_driver_thd; + const char *slave_sql_running_state= + sql_thd ? sql_thd->get_proc_info() : ""; + THD *io_thd= mi->io_thd; + const char *slave_io_running_state= io_thd ? io_thd->get_proc_info() : ""; + mysql_mutex_unlock(&mi->run_lock); + if (full) { /* Show what the sql driver replication thread is doing This is only meaningful if there is only one slave thread. */ - protocol->store(mi->rli.sql_driver_thd ? - mi->rli.sql_driver_thd->get_proc_info() : "", - &my_charset_bin); + protocol->store(slave_sql_running_state, &my_charset_bin); } - protocol->store(mi->io_thd ? mi->io_thd->get_proc_info() : "", &my_charset_bin); - mysql_mutex_unlock(&mi->run_lock); + protocol->store(slave_io_running_state, &my_charset_bin); mysql_mutex_lock(&mi->data_lock); mysql_mutex_lock(&mi->rli.data_lock); @@ -3341,10 +3346,6 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, protocol->store((uint32) mi->rli.get_sql_delay()); // SQL_Remaining_Delay - // THD::proc_info is not protected by any lock, so we read it once - // to ensure that we use the same value throughout this function. - const char *slave_sql_running_state= - mi->rli.sql_driver_thd ? mi->rli.sql_driver_thd->proc_info : ""; if (slave_sql_running_state == stage_sql_thd_waiting_until_delay.m_name) { time_t t= my_time(0), sql_delay_end= mi->rli.get_sql_delay_end(); From 64ea539f7666eca7151b23587fe8903b45f67876 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Mon, 17 Mar 2025 11:46:34 +0300 Subject: [PATCH 05/10] MDEV-36208 dbug_print_table_row is broken: prints empty rows in debugger --- sql/filesort.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/filesort.cc b/sql/filesort.cc index a0e16791f89..442597efe49 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -667,7 +667,7 @@ const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names) move_back_guard.engage(); } - SCOPE_VALUE(table->read_set, (table->read_set && table->write_set) ? + SCOPE_VALUE(table->read_set, (table->reginfo.lock_type >= TL_WRITE_ALLOW_WRITE) ? table->write_set : table->read_set); output.length(0); From 56bc6901d6b3fda9fbf7798ed6c764cb0e09f879 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 19 Mar 2025 00:03:03 +0700 Subject: [PATCH 06/10] MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables Attempt to create a procedure with the DEFINER clause resulted in abnormal server termination in case the server run with the option --skip-grant-tables=1. The reason of abnormal termination is that on handling of the DEFINER clause, not initialized data members of acl_cache is accessed, that led to server crash. Behaviour of the server for considered use case must be the same as for embedded server. Than means, if a security subsytem wasn't initialized (server is started with the option --skip-grant-tables=1) return success from get_current_user() without further access to the acl_cache that obviously not initialized. Additionlly, AUTHID::is_role was modified to handle the case when a host part of the user name isn't provided. Treat this case as if the empty host name is provided. --- mysql-test/main/skip_grants.result | 8 ++++++++ mysql-test/main/skip_grants.test | 11 +++++++++++ mysql-test/main/sp-bugs.result | 9 +++++++++ mysql-test/main/sp-bugs.test | 20 ++++++++++++++++++++ sql/sql_acl.cc | 3 +++ sql/structs.h | 2 +- 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/skip_grants.result b/mysql-test/main/skip_grants.result index a8633807571..daf4191a555 100644 --- a/mysql-test/main/skip_grants.result +++ b/mysql-test/main/skip_grants.result @@ -139,3 +139,11 @@ drop user baz@baz; # # End of 10.3 tests # +# +# MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables +# +CREATE DEFINER=a PROCEDURE p() SELECT 1; +CREATE DEFINER=a FUNCTION f() RETURNS INT RETURN 100; +DROP PROCEDURE p; +DROP FUNCTION f; +# End of 10.5 tests diff --git a/mysql-test/main/skip_grants.test b/mysql-test/main/skip_grants.test index eb8d3c3df88..2c4eddda2b2 100644 --- a/mysql-test/main/skip_grants.test +++ b/mysql-test/main/skip_grants.test @@ -164,3 +164,14 @@ drop user baz@baz; --echo # --echo # End of 10.3 tests --echo # + +--echo # +--echo # MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables +--echo # +CREATE DEFINER=a PROCEDURE p() SELECT 1; +CREATE DEFINER=a FUNCTION f() RETURNS INT RETURN 100; + +DROP PROCEDURE p; +DROP FUNCTION f; + +--echo # End of 10.5 tests diff --git a/mysql-test/main/sp-bugs.result b/mysql-test/main/sp-bugs.result index bd5883f0a04..c1f64a1fa14 100644 --- a/mysql-test/main/sp-bugs.result +++ b/mysql-test/main/sp-bugs.result @@ -388,5 +388,14 @@ ERROR 23000: Column 'c2' in from clause is ambiguous DROP PROCEDURE p2; DROP TABLE t1, t2; # +# MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables +# +# This test is a duplicate of the one located in the file skip_grants.test +# and placed here to check the same test case against embedded-server +CREATE DEFINER=a PROCEDURE p() SELECT 1; +CREATE DEFINER=a FUNCTION f() RETURNS INT RETURN 100; +DROP PROCEDURE p; +DROP FUNCTION f; +# # End of 10.5 tests # diff --git a/mysql-test/main/sp-bugs.test b/mysql-test/main/sp-bugs.test index f44216fbf46..9a4b867a92b 100644 --- a/mysql-test/main/sp-bugs.test +++ b/mysql-test/main/sp-bugs.test @@ -414,6 +414,26 @@ CALL p2 (@a,@c); DROP PROCEDURE p2; DROP TABLE t1, t2; +--echo # +--echo # MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables +--echo # +--echo # This test is a duplicate of the one located in the file skip_grants.test +--echo # and placed here to check the same test case against embedded-server + +# Disable warnings before running the following CREATE PROCEDURE/FUNCTION +# statement since the warning message +# "The user specified as a definer ('a'@'%') does not exist" +# is output in case the test be run against a regular server +# and isn't output if embedded server is used (@sa sp_process_definer() +# in sql_parse.cc). +--disable_warnings +CREATE DEFINER=a PROCEDURE p() SELECT 1; +CREATE DEFINER=a FUNCTION f() RETURNS INT RETURN 100; +--enable_warnings + +DROP PROCEDURE p; +DROP FUNCTION f; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index a7e9ea7d6f7..385d3da18e2 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -12944,6 +12944,9 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock) if (is_invalid_role_name(user->user.str)) return 0; + if (!initialized) + return dup; + if (lock) mysql_mutex_lock(&acl_cache->lock); if (find_acl_role(dup->user.str)) diff --git a/sql/structs.h b/sql/structs.h index aa50035ac7a..2fbd263c825 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -227,7 +227,7 @@ struct AUTHID LEX_CSTRING user, host; void init() { memset(this, 0, sizeof(*this)); } void copy(MEM_ROOT *root, const LEX_CSTRING *usr, const LEX_CSTRING *host); - bool is_role() const { return user.str[0] && !host.str[0]; } + bool is_role() const { return user.str[0] && (!host.str || !host.str[0]); } void set_lex_string(LEX_CSTRING *l, char *buf) { if (is_role()) From f1deebbb0bcff9bd83c057c3164eefb345619a6f Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 14 Mar 2025 13:45:09 +0530 Subject: [PATCH 07/10] MDEV-35420 Server aborts while deleting the record in spatial index - This issue caused by commit a032f14b342c782b82dfcd9235805bee446e6fe8(MDEV-33559). In MDEV-33559, matched_rec::block was changed to pointer and assinged with the help of buf_block_alloc(). But patch fails to check for the block can be nullptr in rtr_check_discard_page(). rtr_cur_search_with_match(): Acquire rtr_match_mutex before creating shadow block for the matched records rtr_pcur_move_to_next(): Copy the shadow block to page cursor block under rtr_match_mutex --- mysql-test/suite/innodb_gis/r/rollback.result | 13 ++++++++++ mysql-test/suite/innodb_gis/t/rollback.test | 13 ++++++++++ storage/innobase/gis/gis0sea.cc | 26 +++++++++++++------ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/innodb_gis/r/rollback.result b/mysql-test/suite/innodb_gis/r/rollback.result index 9e0db79667e..29d4f0884ba 100644 --- a/mysql-test/suite/innodb_gis/r/rollback.result +++ b/mysql-test/suite/innodb_gis/r/rollback.result @@ -412,3 +412,16 @@ update t1 set a=point(5,5), b=point(5,5), c=5 where i < 3; ERROR HY000: Lost connection to MySQL server during query insert into t1 values(5, point(5,5), point(5,5), 5); drop table t1; +# +# MDEV-35420 Server aborts while deleting the record +# in spatial index +# +CREATE TABLE t1 (c POINT NOT NULL, SPATIAL(c)) engine=InnoDB; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SET STATEMENT unique_checks=0,foreign_key_checks=0 FOR +START TRANSACTION; +INSERT INTO t1 SELECT ST_GeomFromText('POINT(114368751 656950466)') FROM seq_1_to_512; +ROLLBACK; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_gis/t/rollback.test b/mysql-test/suite/innodb_gis/t/rollback.test index a09986692ee..06fe6591a9a 100644 --- a/mysql-test/suite/innodb_gis/t/rollback.test +++ b/mysql-test/suite/innodb_gis/t/rollback.test @@ -8,6 +8,7 @@ # Avoid CrashReporter popup on Mac --source include/not_crashrep.inc --source include/have_innodb_16k.inc +--source include/have_sequence.inc CREATE TABLE t4 (id bigint(12) unsigned NOT NULL auto_increment, c2 varchar(15) collate utf8_bin default NULL, @@ -475,3 +476,15 @@ update t1 set a=point(5,5), b=point(5,5), c=5 where i < 3; insert into t1 values(5, point(5,5), point(5,5), 5); drop table t1; + +--echo # +--echo # MDEV-35420 Server aborts while deleting the record +--echo # in spatial index +--echo # +CREATE TABLE t1 (c POINT NOT NULL, SPATIAL(c)) engine=InnoDB; +CHECK TABLE t1; +SET STATEMENT unique_checks=0,foreign_key_checks=0 FOR +START TRANSACTION; +INSERT INTO t1 SELECT ST_GeomFromText('POINT(114368751 656950466)') FROM seq_1_to_512; +ROLLBACK; +DROP TABLE t1; diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index b9567ff03c3..66537a1ee11 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -495,10 +495,10 @@ rtr_pcur_move_to_next( rtr_rec_t rec; rec = rtr_info->matches->matched_recs->back(); rtr_info->matches->matched_recs->pop_back(); + cursor->btr_cur.page_cur.block = rtr_info->matches->block; mutex_exit(&rtr_info->matches->rtr_match_mutex); cursor->btr_cur.page_cur.rec = rec.r_rec; - cursor->btr_cur.page_cur.block = rtr_info->matches->block; DEBUG_SYNC_C("rtr_pcur_move_to_next_return"); return(true); @@ -1204,8 +1204,11 @@ rtr_check_discard_page( if (rtr_info->matches) { mutex_enter(&rtr_info->matches->rtr_match_mutex); - if (rtr_info->matches->block->page.id().page_no() - == pageno) { + /* matches->block could be nullptr when cursor + encounters empty table */ + if (rtr_info->matches->block + && rtr_info->matches->block->page.id().page_no() + == pageno) { if (!rtr_info->matches->matched_recs->empty()) { rtr_info->matches->matched_recs->clear(); } @@ -1849,6 +1852,15 @@ rtr_cur_search_with_match( ut_ad(orig_mode != PAGE_CUR_RTREE_LOCATE); + /* Collect matched records on page */ + offsets = rec_get_offsets( + rec, index, offsets, + index->n_fields, + ULINT_UNDEFINED, &heap); + + mutex_enter( + &rtr_info->matches->rtr_match_mutex); + if (!match_init) { rtr_init_match( rtr_info->matches, @@ -1856,14 +1868,12 @@ rtr_cur_search_with_match( match_init = true; } - /* Collect matched records on page */ - offsets = rec_get_offsets( - rec, index, offsets, - index->n_fields, - ULINT_UNDEFINED, &heap); rtr_leaf_push_match_rec( rec, rtr_info, offsets, page_is_comp(page)); + + mutex_exit( + &rtr_info->matches->rtr_match_mutex); } last_match_rec = rec; From 1277f9b4513a0f4c3303a41e142465dc7e403ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 24 Mar 2025 12:00:30 +0200 Subject: [PATCH 08/10] MDEV-36372: Compilation is broken with the PLUGIN_PARTITION=NO Fixed a compilation error caused by MDEV-27861 that occurs when building with cmake -DPLUGIN_PARTITION=NO, because the default_part_plugin variable is only visible when WITH_PARTITION_STORAGE_ENGINE is defined. Signed-off-by: Julius Goryavsky --- sql/sql_truncate.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index e86325d31a5..863c1bd795e 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -271,7 +271,7 @@ Sql_cmd_truncate_table::handler_truncate(THD *thd, TABLE_LIST *table_ref, bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref, bool *hton_can_recreate) { - handlerton *hton; + const handlerton *hton; bool versioned; bool sequence= false; TABLE *table= NULL; @@ -342,8 +342,12 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref, table we need to find out default partition handlerton. */ - const handlerton *ht= share->default_part_plugin ? - plugin_hton(share->default_part_plugin) : hton; + const handlerton* const ht= +#ifdef WITH_PARTITION_STORAGE_ENGINE + share->default_part_plugin ? + plugin_hton(share->default_part_plugin) : +#endif + hton; if (ht && !wsrep_should_replicate_ddl(thd, ht)) { From 2469963f052b4dcb11ecfc0fcf5a38881c426df0 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 14 Mar 2025 11:32:27 +0530 Subject: [PATCH 09/10] MDEV-36270 mariabackup.incremental_compressed fails in 10.11+ - During prepare of incremental backup, mariabackup does create new file in target directory with default file size of 4 * innodb_page_size. While applying .delta file to corresponding data file, it encounters the FSP_SIZE modification on page0 and tries to extend the file to the size which is 4 in our case. Since the table is in compressed row format, page_size for the table is 8k. This lead to shrinking of tablespace file from 65536 to 32768. This issue happens only in windows because os_file_set_size() doesn't check for the current size and shrinks the file. Solution: ======== xtrabackup_apply_delta(): Check for the current size before doing setting size for the file. --- extra/mariabackup/xtrabackup.cc | 13 +++++++++++++ .../suite/mariabackup/incremental_compressed.result | 3 +++ .../suite/mariabackup/incremental_compressed.test | 12 +++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index a59e8f0858f..9b6a8b4c316 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -5508,9 +5508,22 @@ xtrabackup_apply_delta( buf + FSP_HEADER_OFFSET + FSP_SIZE); if (mach_read_from_4(buf + FIL_PAGE_SPACE_ID)) { +#ifdef _WIN32 + os_offset_t last_page = + os_file_get_size(dst_file) / + page_size; + + /* os_file_set_size() would + shrink the size of the file */ + if (last_page < n_pages && + !os_file_set_size( + dst_path, dst_file, + n_pages * page_size)) +#else if (!os_file_set_size( dst_path, dst_file, n_pages * page_size)) +#endif /* _WIN32 */ goto error; } else if (fil_space_t* space = fil_system.sys_space) { diff --git a/mysql-test/suite/mariabackup/incremental_compressed.result b/mysql-test/suite/mariabackup/incremental_compressed.result index f8b01808642..aeb52019aa0 100644 --- a/mysql-test/suite/mariabackup/incremental_compressed.result +++ b/mysql-test/suite/mariabackup/incremental_compressed.result @@ -4,6 +4,9 @@ # CREATE TABLE t (pk INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; ALTER TABLE t PARTITION BY KEY(pk); +# Incremental backup +# Prepare fullbackup +# Prepare incremental backup # shutdown server # remove datadir # xtrabackup move back diff --git a/mysql-test/suite/mariabackup/incremental_compressed.test b/mysql-test/suite/mariabackup/incremental_compressed.test index 15aff909a43..de7f588290f 100644 --- a/mysql-test/suite/mariabackup/incremental_compressed.test +++ b/mysql-test/suite/mariabackup/incremental_compressed.test @@ -16,12 +16,18 @@ CREATE TABLE t (pk INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; ALTER TABLE t PARTITION BY KEY(pk); +--echo # Incremental backup --exec $XTRABACKUP --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --protocol=tcp --port=$MASTER_MYPORT --user=root > $incremental_dir.log 2>&1 +--echo # Prepare fullbackup --exec $XTRABACKUP --prepare --target-dir=$basedir --user=root > $MYSQL_TMP_DIR/backup_prepare_0.log 2>&1 ---exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir --user=root > $MYSQL_TMP_DIR/backup_prepare_1.log ---cat_file $MYSQL_TMP_DIR/backup_prepare_1.log +--echo # Prepare incremental backup +--exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir --user=root > $MYSQL_TMP_DIR/backup_prepare_1.log 2>&1 let $targetdir=$basedir; -- source include/restart_and_restore.inc - SHOW CREATE TABLE t; DROP TABLE t; +remove_file $incremental_dir.log; +remove_file $MYSQL_TMP_DIR/backup_prepare_0.log; +remove_file $MYSQL_TMP_DIR/backup_prepare_1.log; +rmdir $basedir; +rmdir $incremental_dir; From 85ecb80fa3192035b3beff9578dc254a857175dc Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 6 Mar 2025 15:29:17 +1100 Subject: [PATCH 10/10] MDEV-36229: Remove CAP_DAC_OVERRIDE CAP_AUDIT_WRITE from AmbientCapabilities In resolving MDEV-33301 (76a27155b4cd8174e900577dd01df2db1327b120) we moved all the capabilities from CapabilityBoundingSet to AmbientCapabilities where only add/moving CAP_IPC_LOCK was intended. The effect of this is the defaulting running MariaDB HAS the capabiltiy CAP_DAC_OVERRIDE CAP_AUDIT_WRITE allowing it to access any file, even while running as a non-root user. Resolve this by making CAP_IPC_LOCK apply to AmbientCapabilities and leave the remaining CAP_DAC_OVERRIDE CAP_AUDIT_WRITE to CapabilityBoundingSet for the use by auth_pam_tool. --- support-files/mariadb.service.in | 5 ++++- support-files/mariadb@.service.in | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in index 27e6ac08184..f53a0b8ceda 100644 --- a/support-files/mariadb.service.in +++ b/support-files/mariadb.service.in @@ -48,10 +48,13 @@ User=mysql Group=mysql # CAP_IPC_LOCK To allow memlock to be used as non-root user +# These are enabled by default +AmbientCapabilities=CAP_IPC_LOCK + # CAP_DAC_OVERRIDE To allow auth_pam_tool (which is SUID root) to read /etc/shadow when it's chmod 0 # does nothing for non-root, not needed if /etc/shadow is u+r # CAP_AUDIT_WRITE auth_pam_tool needs it on Debian for whatever reason -AmbientCapabilities=CAP_IPC_LOCK CAP_DAC_OVERRIDE CAP_AUDIT_WRITE +CapabilityBoundingSet=CAP_DAC_OVERRIDE CAP_AUDIT_WRITE # PrivateDevices=true implies NoNewPrivileges=true and # SUID auth_pam_tool suddenly doesn't do setuid anymore diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in index b53711ef7e0..cb5e885e1aa 100644 --- a/support-files/mariadb@.service.in +++ b/support-files/mariadb@.service.in @@ -178,10 +178,13 @@ PrivateNetwork=false ## # CAP_IPC_LOCK To allow memlock to be used as non-root user +# These are enabled by default +AmbientCapabilities=CAP_IPC_LOCK + # CAP_DAC_OVERRIDE To allow auth_pam_tool (which is SUID root) to read /etc/shadow when it's chmod 0 # does nothing for non-root, not needed if /etc/shadow is u+r # CAP_AUDIT_WRITE auth_pam_tool needs it on Debian for whatever reason -AmbientCapabilities=CAP_IPC_LOCK CAP_DAC_OVERRIDE CAP_AUDIT_WRITE +CapabilityBoundingSet=CAP_DAC_OVERRIDE CAP_AUDIT_WRITE # PrivateDevices=true implies NoNewPrivileges=true and # SUID auth_pam_tool suddenly doesn't do setuid anymore