diff options
author | Haidong Ji <ji@haidongji.com> | 2022-03-07 21:17:39 -0600 |
---|---|---|
committer | Daniel Black <daniel@mariadb.org> | 2022-03-08 15:13:09 +1100 |
commit | 114476f2ec8244bd02b0f51fdaca05e055a2c1dc (patch) | |
tree | 69135c289e526e6681757075d60883f271d3c768 | |
parent | a92f07f4bd450f7368a998ce63443dd66374262a (diff) | |
download | mariadb-git-114476f2ec8244bd02b0f51fdaca05e055a2c1dc.tar.gz |
MDEV-27978 fix wrong name in error when max_session_mem_used exceeded
Fixed typo in my_malloc_size_cb_func. There is no max-thread-mem-used
sys variable in MariaDB, only max-session-mem-used. The relevant entry
in sys_vars.cc is also fixed.
Added a fallback case in case we could allocate the 256 bytes for the
error message containing the exact setting.
-rw-r--r-- | mysql-test/r/error_simulation.result | 10 | ||||
-rw-r--r-- | mysql-test/r/truncate_notembedded.result | 2 | ||||
-rw-r--r-- | mysql-test/t/error_simulation.test | 13 | ||||
-rw-r--r-- | sql/mysqld.cc | 7 | ||||
-rw-r--r-- | sql/sys_vars.cc | 2 |
5 files changed, 31 insertions, 3 deletions
diff --git a/mysql-test/r/error_simulation.result b/mysql-test/r/error_simulation.result index 457e5c8ec9c..680937accfd 100644 --- a/mysql-test/r/error_simulation.result +++ b/mysql-test/r/error_simulation.result @@ -128,3 +128,13 @@ SELECT f1(1); Got one of the listed errors DROP FUNCTION f1; SET debug_dbug= @saved_dbug; +# +# MDEV-27978 wrong option name in error when exceeding max_session_mem_used +# +SET SESSION max_session_mem_used = 8192; +SELECT * FROM information_schema.processlist; +ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement +SET SESSION max_session_mem_used = DEFAULT; +# +# End of 10.2 tests +# diff --git a/mysql-test/r/truncate_notembedded.result b/mysql-test/r/truncate_notembedded.result index dabd5474141..90f27fd2688 100644 --- a/mysql-test/r/truncate_notembedded.result +++ b/mysql-test/r/truncate_notembedded.result @@ -13,7 +13,7 @@ a UNLOCK TABLES; connection con1; TRUNCATE TABLE t1; -ERROR HY000: The MariaDB server is running with the --max-thread-mem-used=45500 option so it cannot execute this statement +ERROR HY000: The MariaDB server is running with the --max-session-mem-used=45500 option so it cannot execute this statement disconnect con1; connection default; DROP TABLE t1; diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test index f713e2da6ba..2c155bc9a22 100644 --- a/mysql-test/t/error_simulation.test +++ b/mysql-test/t/error_simulation.test @@ -158,3 +158,16 @@ SET SESSION debug_dbug="+d,simulate_create_virtual_tmp_table_out_of_memory"; SELECT f1(1); DROP FUNCTION f1; SET debug_dbug= @saved_dbug; + +--echo # +--echo # MDEV-27978 wrong option name in error when exceeding max_session_mem_used +--echo # +SET SESSION max_session_mem_used = 8192; +--error ER_OPTION_PREVENTS_STATEMENT +SELECT * FROM information_schema.processlist; +SET SESSION max_session_mem_used = DEFAULT; + + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6a7ea117c84..7f18f758d13 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4090,13 +4090,18 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific) /* Ensure we don't get called here again */ char buf[50], *buf2; thd->set_killed(KILL_QUERY); - my_snprintf(buf, sizeof(buf), "--max-thread-mem-used=%llu", + my_snprintf(buf, sizeof(buf), "--max-session-mem-used=%llu", thd->variables.max_mem_used); if ((buf2= (char*) thd->alloc(256))) { my_snprintf(buf2, 256, ER_THD(thd, ER_OPTION_PREVENTS_STATEMENT), buf); thd->set_killed(KILL_QUERY, ER_OPTION_PREVENTS_STATEMENT, buf2); } + else + { + thd->set_killed(KILL_QUERY, ER_OPTION_PREVENTS_STATEMENT, + "--max-session-mem-used"); + } } DBUG_ASSERT((longlong) thd->status_var.local_memory_used >= 0 || !debug_assert_on_not_freed_memory); diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index ee862e4936e..6a35176bd99 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -5719,7 +5719,7 @@ static Sys_var_ulong Sys_log_tc_size( BLOCK_SIZE(my_getpagesize())); #endif -static Sys_var_ulonglong Sys_max_thread_mem( +static Sys_var_ulonglong Sys_max_session_mem_used( "max_session_mem_used", "Amount of memory a single user session " "is allowed to allocate. This limits the value of the " "session variable MEM_USED", SESSION_VAR(max_mem_used), |