From e7d40e2b548dce201f551b4fb38ee297779cfcb4 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 6 Jul 2021 03:00:27 +0200 Subject: [PATCH 01/11] MDEV-25978: minor post-merge fix for .result file --- mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result index dabbaeaab4f..9b56a09d369 100644 --- a/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result +++ b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result @@ -172,4 +172,3 @@ COUNT(*) = 0 1 DROP TABLE t1; COMMIT; -SET AUTOCOMMIT=ON; From 2e3230a5fcc35ed73732ed01ec4d0489958ce2f4 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 2 Jul 2021 12:40:51 +1000 Subject: [PATCH 02/11] mtr: fix innodb_bug53756 on aix --skip-stack-trace isn't there on AIX. --- mysql-test/suite/innodb/t/innodb_bug53756-master.opt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/t/innodb_bug53756-master.opt b/mysql-test/suite/innodb/t/innodb_bug53756-master.opt index 425fda95086..590d44a6d12 100644 --- a/mysql-test/suite/innodb/t/innodb_bug53756-master.opt +++ b/mysql-test/suite/innodb/t/innodb_bug53756-master.opt @@ -1 +1 @@ ---skip-stack-trace --skip-core-file +--loose-skip-stack-trace --skip-core-file From a8136d13b2a4226f731f2f024e8199ca40133962 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 2 Jul 2021 13:00:34 +1000 Subject: [PATCH 03/11] mtr: aix - no pool of threads --- mysql-test/include/maybe_pool_of_threads.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/include/maybe_pool_of_threads.inc b/mysql-test/include/maybe_pool_of_threads.inc index 51a179b4426..d25e3864333 100644 --- a/mysql-test/include/maybe_pool_of_threads.inc +++ b/mysql-test/include/maybe_pool_of_threads.inc @@ -1 +1,2 @@ # run with and without threadpool +--source include/not_aix.inc From f84b3b88070f83ddfde05b9e6c6b72664dd3372e Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 6 Jul 2021 15:50:58 +1000 Subject: [PATCH 04/11] mtr: aix has no thread_pool --- mysql-test/include/have_pool_of_threads.inc | 3 ++- .../suite/sys_vars/t/thread_pool_idle_timeout_basic.test | 1 + .../suite/sys_vars/t/thread_pool_idle_timeout_grant.test | 1 + mysql-test/suite/sys_vars/t/thread_pool_max_threads_basic.test | 1 + mysql-test/suite/sys_vars/t/thread_pool_max_threads_grant.test | 1 + mysql-test/suite/sys_vars/t/thread_pool_min_threads_basic.test | 1 + .../suite/sys_vars/t/thread_pool_oversubscribe_basic.test | 1 + .../suite/sys_vars/t/thread_pool_oversubscribe_grant.test | 1 + mysql-test/suite/sys_vars/t/thread_pool_stall_limit_basic.test | 1 + mysql-test/suite/sys_vars/t/thread_pool_stall_limit_grant.test | 1 + 10 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mysql-test/include/have_pool_of_threads.inc b/mysql-test/include/have_pool_of_threads.inc index 432c6216804..62460127d88 100644 --- a/mysql-test/include/have_pool_of_threads.inc +++ b/mysql-test/include/have_pool_of_threads.inc @@ -1,4 +1,5 @@ --- require include/have_pool_of_threads.require +--source include/not_aix.inc +--require include/have_pool_of_threads.require disable_query_log; show variables like 'thread_handling'; enable_query_log; diff --git a/mysql-test/suite/sys_vars/t/thread_pool_idle_timeout_basic.test b/mysql-test/suite/sys_vars/t/thread_pool_idle_timeout_basic.test index 4afcc0379f0..b06a5069514 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_idle_timeout_basic.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_idle_timeout_basic.test @@ -1,6 +1,7 @@ # uint global --source include/not_windows.inc --source include/not_embedded.inc +--source include/not_aix.inc SET @start_global_value = @@global.thread_pool_idle_timeout; # diff --git a/mysql-test/suite/sys_vars/t/thread_pool_idle_timeout_grant.test b/mysql-test/suite/sys_vars/t/thread_pool_idle_timeout_grant.test index 71b007bde23..8f5f2491e12 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_idle_timeout_grant.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_idle_timeout_grant.test @@ -1,5 +1,6 @@ --source include/not_windows.inc --source include/not_embedded.inc +--source include/not_aix.inc SET @global=@@global.thread_pool_idle_timeout; diff --git a/mysql-test/suite/sys_vars/t/thread_pool_max_threads_basic.test b/mysql-test/suite/sys_vars/t/thread_pool_max_threads_basic.test index 3d5cd5f5198..392dbd3a145 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_max_threads_basic.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_max_threads_basic.test @@ -1,5 +1,6 @@ # uint global --source include/not_embedded.inc +--source include/not_aix.inc SET @start_global_value = @@global.thread_pool_max_threads; # diff --git a/mysql-test/suite/sys_vars/t/thread_pool_max_threads_grant.test b/mysql-test/suite/sys_vars/t/thread_pool_max_threads_grant.test index 29a9ac42ea0..299d5ff4f44 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_max_threads_grant.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_max_threads_grant.test @@ -1,5 +1,6 @@ # uint global --source include/not_embedded.inc +--source include/not_aix.inc SET @global=@@global.thread_pool_max_threads; diff --git a/mysql-test/suite/sys_vars/t/thread_pool_min_threads_basic.test b/mysql-test/suite/sys_vars/t/thread_pool_min_threads_basic.test index 131fbe98502..1447c83d39c 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_min_threads_basic.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_min_threads_basic.test @@ -1,6 +1,7 @@ # uint global --source include/not_embedded.inc --source include/windows.inc +--source include/not_aix.inc SET @start_global_value = @@global.thread_pool_min_threads; # diff --git a/mysql-test/suite/sys_vars/t/thread_pool_oversubscribe_basic.test b/mysql-test/suite/sys_vars/t/thread_pool_oversubscribe_basic.test index 74f0f5e6ea7..43817febafd 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_oversubscribe_basic.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_oversubscribe_basic.test @@ -1,6 +1,7 @@ # uint global --source include/not_windows.inc --source include/not_embedded.inc +--source include/not_aix.inc SET @start_global_value = @@global.thread_pool_oversubscribe; # diff --git a/mysql-test/suite/sys_vars/t/thread_pool_oversubscribe_grant.test b/mysql-test/suite/sys_vars/t/thread_pool_oversubscribe_grant.test index cbffb94c297..f3a96c69e8a 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_oversubscribe_grant.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_oversubscribe_grant.test @@ -1,5 +1,6 @@ --source include/not_windows.inc --source include/not_embedded.inc +--source include/not_aix.inc SET @global=@@global.thread_pool_oversubscribe; diff --git a/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_basic.test b/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_basic.test index 1ab27907535..2d1dc59476c 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_basic.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_basic.test @@ -1,5 +1,6 @@ # uint global --source include/not_embedded.inc +--source include/not_aix.inc SET @start_global_value = @@global.thread_pool_stall_limit; # diff --git a/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_grant.test b/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_grant.test index 8c0908fe2c0..ae0ed8a785b 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_grant.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_grant.test @@ -1,5 +1,6 @@ # uint global --source include/not_embedded.inc +--source include/not_aix.inc SET @global=@@global.thread_pool_stall_limit; From e8e7dde3b6af2e243a67038ff985c0b6ca792d0f Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 6 Jul 2021 17:56:47 +1000 Subject: [PATCH 05/11] mtr: aix fix mysqld--help - no thread-pool --- mysql-test/main/mysqld--help,aix.rdiff | 76 ++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/mysql-test/main/mysqld--help,aix.rdiff b/mysql-test/main/mysqld--help,aix.rdiff index e69de29bb2d..972f8b1844b 100644 --- a/mysql-test/main/mysqld--help,aix.rdiff +++ b/mysql-test/main/mysqld--help,aix.rdiff @@ -0,0 +1,76 @@ +diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result +index 7b0ce27ead3..38176dcaa86 100644 +--- a/mysql-test/main/mysqld--help.result ++++ b/mysql-test/main/mysqld--help.result +@@ -1301,8 +1301,6 @@ The following specify which files/extra groups are read (specified before remain + WHERE clause, or a LIMIT clause, or else they will + aborted. Prevents the common mistake of accidentally + deleting or updating every row in a table. +- --stack-trace Print a symbolic stack trace on failure +- (Defaults to on; use --skip-stack-trace to disable.) + --standard-compliant-cte + Allow only CTEs compliant to SQL standard + (Defaults to on; use --skip-standard-compliant-cte to disable.) +@@ -1367,39 +1365,6 @@ The following specify which files/extra groups are read (specified before remain + --thread-cache-size=# + How many threads we should keep in a cache for reuse. + These are freed after 5 minutes of idle time +- --thread-pool-dedicated-listener +- If set to 1,listener thread will not pick up queries +- --thread-pool-exact-stats +- If set to 1, provides better statistics in +- information_schema threadpool tables +- --thread-pool-idle-timeout=# +- Timeout in seconds for an idle thread in the thread +- pool.Worker thread will be shut down after timeout +- --thread-pool-max-threads=# +- Maximum allowed number of worker threads in the thread +- pool +- --thread-pool-oversubscribe=# +- How many additional active worker threads in a group are +- allowed. +- --thread-pool-prio-kickup-timer=# +- The number of milliseconds before a dequeued low-priority +- statement is moved to the high-priority queue +- --thread-pool-priority=name +- Threadpool priority. High priority connections usually +- start executing earlier than low priority.If priority set +- to 'auto', the the actual priority(low or high) is +- determined based on whether or not connection is inside +- transaction. +- --thread-pool-size=# +- Number of thread groups in the pool. This parameter is +- roughly equivalent to maximum number of concurrently +- executing threads (threads in a waiting state do not +- count as executing). +- --thread-pool-stall-limit=# +- Maximum query execution time in milliseconds,before an +- executing non-yielding thread is considered stalled.If a +- worker thread is stalled, additional worker thread may be +- created to handle remaining clients. + --thread-stack=# The stack size for each thread + --time-format=name The TIME format (ignored) + --tls-version=name TLS protocol version for secure connections.. Any +@@ -1788,7 +1753,6 @@ slow-query-log FALSE + sort-buffer-size 2097152 + sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION + sql-safe-updates FALSE +-stack-trace TRUE + standard-compliant-cte TRUE + stored-program-cache 256 + strict-password-validation TRUE +@@ -1807,14 +1771,6 @@ tcp-keepalive-probes 0 + tcp-keepalive-time 0 + tcp-nodelay TRUE + thread-cache-size 151 +-thread-pool-dedicated-listener FALSE +-thread-pool-exact-stats FALSE +-thread-pool-idle-timeout 60 +-thread-pool-max-threads 65536 +-thread-pool-oversubscribe 3 +-thread-pool-prio-kickup-timer 1000 +-thread-pool-priority auto +-thread-pool-stall-limit 500 + thread-stack 299008 + time-format %H:%i:%s + tmp-disk-table-size 18446744073709551615 From c262ccac027e71f22fc1329cf295a6bf687e4684 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 6 Jul 2021 17:59:30 +1000 Subject: [PATCH 06/11] mtr: aix disable mysqld--defaults-file AIX grep doesn't support the grep -A syntax used in the test case. --- mysql-test/main/mysqld--defaults-file.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/main/mysqld--defaults-file.test b/mysql-test/main/mysqld--defaults-file.test index 4859cc17b42..9ca427568ef 100644 --- a/mysql-test/main/mysqld--defaults-file.test +++ b/mysql-test/main/mysqld--defaults-file.test @@ -4,6 +4,7 @@ source include/not_embedded.inc; source include/not_windows.inc; +source include/not_aix.inc; # All these tests refer to configuration files that do not exist From 35294053b281294bb49a6217da07b93eb6c2595b Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 7 Jul 2021 18:51:13 +0300 Subject: [PATCH 07/11] MDEV-26106: [ERROR] InnoDB: Unlock row could not find a 2 mode lock on the record Port the following patch from MySQL: commit 1b2e8ea269c80cb93cc79d8be934c40b1c58e947 Author: Kailasnath Nagarkar Date: Fri Nov 30 16:43:13 2018 +0530 Bug #20939184: INNODB: UNLOCK ROW COULD NOT FIND A 2 MODE LOCK ON THE RECORD Issue: ------ Consdier tables t1 and t2 such that t1 has multiple rows and join condition for t1 left join t2 results in only single row from t2. In this case, access to table t2 is const since there is a single row that qualifies the join condition. However, while executing the query, attempt is made to unlock t2's row multiple times. The current algorithm to fetch rows approximates to: 1) Retrieve the row for t1. 2) Retrieve the row for t2. 3) Apply the join conditions. a) If condition evaluates to true: Project the row to the result. b) If condition evaluates to false: i) If t2's qep_tab->not_null_complement is true, unlock t2's row. ii) Null-complement the row by calling "evaluate_null_complemented_join_record()". In this function qep_tab->not_null_complement is set to false. The t2's only one row, that qualifies join condition, is unlocked in Step i) when t1's row is evaluated to false. When t1's next row is also evaluated to false, another attempt is made to unlock t2's already unlocked row. This results in following error being logged in error.log: "[ERROR] InnoDB: Unlock row could not find a 3 mode lock on the record. Current statement: select * from t1 left join t2 ......" Solution: --------- When a table's access method is "const", set record unlock method for this table to do no operation. --- mysql-test/main/join_outer_innodb.result | 19 +++++++++++++++ mysql-test/main/join_outer_innodb.test | 17 +++++++++++++ sql/sql_select.cc | 31 +++++++++++++++++++++--- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/join_outer_innodb.result b/mysql-test/main/join_outer_innodb.result index 0b34a399d77..09a37a29702 100644 --- a/mysql-test/main/join_outer_innodb.result +++ b/mysql-test/main/join_outer_innodb.result @@ -496,3 +496,22 @@ natural right outer join t3; drop table t1,t2,t3; set optimizer_prune_level=@mdev4270_opl; set optimizer_search_depth=@mdev4270_osd; +# +# Bug #20939184:INNODB: UNLOCK ROW COULD NOT FIND A 2 MODE LOCK ON THE +# RECORD +# +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,c2) ) engine=innodb; +CREATE TABLE t2 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1), KEY (c2)) engine=innodb; +INSERT INTO t1 VALUES (1,2,3),(2,3,4),(3,4,5); +INSERT INTO t2 SELECT * FROM t1; +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +START TRANSACTION; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c2=t2.c2 AND t2.c1=1 FOR UPDATE; +c1 c2 c3 c1 c2 c3 +1 2 3 1 2 3 +2 3 4 NULL NULL NULL +3 4 5 NULL NULL NULL +UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c2 AND t2.c1 = 3 SET t1.c3 = RAND()*10; +COMMIT; +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +DROP TABLE t1,t2; diff --git a/mysql-test/main/join_outer_innodb.test b/mysql-test/main/join_outer_innodb.test index c26cd62fbc7..6b332f3d155 100644 --- a/mysql-test/main/join_outer_innodb.test +++ b/mysql-test/main/join_outer_innodb.test @@ -374,3 +374,20 @@ drop table t1,t2,t3; set optimizer_prune_level=@mdev4270_opl; set optimizer_search_depth=@mdev4270_osd; +--echo # +--echo # Bug #20939184:INNODB: UNLOCK ROW COULD NOT FIND A 2 MODE LOCK ON THE +--echo # RECORD +--echo # +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,c2) ) engine=innodb; +CREATE TABLE t2 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1), KEY (c2)) engine=innodb; +INSERT INTO t1 VALUES (1,2,3),(2,3,4),(3,4,5); +INSERT INTO t2 SELECT * FROM t1; +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +START TRANSACTION; +#unlocks rows in table t2 where c1 = 1 +SELECT * FROM t1 LEFT JOIN t2 ON t1.c2=t2.c2 AND t2.c1=1 FOR UPDATE; +UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c2 AND t2.c1 = 3 SET t1.c3 = RAND()*10; +COMMIT; +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +DROP TABLE t1,t2; + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 8800fbf5b6d..ab54bd3b94d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -189,6 +189,7 @@ static int join_read_system(JOIN_TAB *tab); static int join_read_const(JOIN_TAB *tab); static int join_read_key(JOIN_TAB *tab); static void join_read_key_unlock_row(st_join_table *tab); +static void join_const_unlock_row(JOIN_TAB *tab); static int join_read_always_key(JOIN_TAB *tab); static int join_read_last_key(JOIN_TAB *tab); static int join_no_more_records(READ_RECORD *info); @@ -10968,8 +10969,12 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, else j->type=JT_EQ_REF; - j->read_record.unlock_row= (j->type == JT_EQ_REF)? - join_read_key_unlock_row : rr_unlock_row; + if (j->type == JT_EQ_REF) + j->read_record.unlock_row= join_read_key_unlock_row; + else if (j->type == JT_CONST) + j->read_record.unlock_row= join_const_unlock_row; + else + j->read_record.unlock_row= rr_unlock_row; DBUG_RETURN(0); } @@ -13232,6 +13237,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) /* Only happens with outer joins */ tab->read_first_record= tab->type == JT_SYSTEM ? join_read_system : join_read_const; + tab->read_record.unlock_row= join_const_unlock_row; if (!(table->covering_keys.is_set(tab->ref.key) && !table->no_keyread) && (!jcl || jcl > 4) && !tab->ref.is_access_triggered()) push_index_cond(tab, tab->ref.key); @@ -21532,6 +21538,19 @@ join_read_key_unlock_row(st_join_table *tab) tab->ref.use_count--; } +/** + Rows from const tables are read once but potentially used + multiple times during execution of a query. + Ensure such rows are never unlocked during query execution. +*/ + +void +join_const_unlock_row(JOIN_TAB *tab) +{ + DBUG_ASSERT(tab->type == JT_CONST); +} + + /* ref access method implementation: "read_first" function @@ -23938,8 +23957,12 @@ check_reverse_order: else if (select && select->quick) select->quick->need_sorted_output(); - tab->read_record.unlock_row= (tab->type == JT_EQ_REF) ? - join_read_key_unlock_row : rr_unlock_row; + if (tab->type == JT_EQ_REF) + tab->read_record.unlock_row= join_read_key_unlock_row; + else if (tab->type == JT_CONST) + tab->read_record.unlock_row= join_const_unlock_row; + else + tab->read_record.unlock_row= rr_unlock_row; } // QEP has been modified From f88d130e710338607adf2517bef436de624c76b9 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Tue, 8 Jun 2021 11:25:47 +0530 Subject: [PATCH 08/11] MDEV-24248: my_print_defaults is not taking all the values when using -e option which is called from mysql.server (extra_args). Fix: change mysql.server script to use --defaults-extra-file instead of -e --- mysql-test/main/my_print_defaults.result | 18 +++++++++++++++ mysql-test/main/my_print_defaults.test | 29 ++++++++++++++++++++++++ support-files/mysql.server.sh | 4 ++-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 mysql-test/main/my_print_defaults.result create mode 100644 mysql-test/main/my_print_defaults.test diff --git a/mysql-test/main/my_print_defaults.result b/mysql-test/main/my_print_defaults.result new file mode 100644 index 00000000000..5303fa55a9e --- /dev/null +++ b/mysql-test/main/my_print_defaults.result @@ -0,0 +1,18 @@ +# +# Beginning of 10.5 Test +# +# +# MDEV-24248: my_print_defaults is not taking all the values when using +# -e option which is called from mysql.server (extra_args). +# +# checking for mysql.server +--key_buffer_size=20M +--max_allowed_packet=250M +--table_open_cache=1000 +--table_definition_cache=2000 +--read_buffer_size=1M +--thread_cache_size=8 +--max_connections=1024 +--long_query_time=60 +--slow_query_log=1 +# End of 10.5 test diff --git a/mysql-test/main/my_print_defaults.test b/mysql-test/main/my_print_defaults.test new file mode 100644 index 00000000000..cc467ff09dc --- /dev/null +++ b/mysql-test/main/my_print_defaults.test @@ -0,0 +1,29 @@ +--echo # +--echo # Beginning of 10.5 Test +--echo # +--echo # +--echo # MDEV-24248: my_print_defaults is not taking all the values when using +--echo # -e option which is called from mysql.server (extra_args). +--echo # + +--echo # checking for mysql.server + +--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf + +[mariadb] +key_buffer_size=20M +max_allowed_packet=250M +table_open_cache=1000 +table_definition_cache=2000 +read_buffer_size=1M +thread_cache_size=8 +max_connections=1024 +long_query_time=60 +slow_query_log=1 +EOF + +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mysqld mysql.server + +--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf + +--echo # End of 10.5 test diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index cefb3225e9e..f26b95aea78 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -200,11 +200,11 @@ su_kill() { extra_args="" if test -r "$basedir/my.cnf" then - extra_args="-e $basedir/my.cnf" + extra_args="--defaults-extra-file=$basedir/my.cnf" else if test -r "$datadir/my.cnf" then - extra_args="-e $datadir/my.cnf" + extra_args="--defaults-extra-file=$datadir/my.cnf" fi fi From 826eab3f9b28dbc370e5d7a2f81dc42d2f09ed40 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Thu, 15 Jul 2021 17:07:22 +0530 Subject: [PATCH 09/11] Revert "MDEV-24248: my_print_defaults is not taking all the values when using -e" This reverts commit f88d130e710338607adf2517bef436de624c76b9. --- mysql-test/main/my_print_defaults.result | 18 --------------- mysql-test/main/my_print_defaults.test | 29 ------------------------ support-files/mysql.server.sh | 4 ++-- 3 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 mysql-test/main/my_print_defaults.result delete mode 100644 mysql-test/main/my_print_defaults.test diff --git a/mysql-test/main/my_print_defaults.result b/mysql-test/main/my_print_defaults.result deleted file mode 100644 index 5303fa55a9e..00000000000 --- a/mysql-test/main/my_print_defaults.result +++ /dev/null @@ -1,18 +0,0 @@ -# -# Beginning of 10.5 Test -# -# -# MDEV-24248: my_print_defaults is not taking all the values when using -# -e option which is called from mysql.server (extra_args). -# -# checking for mysql.server ---key_buffer_size=20M ---max_allowed_packet=250M ---table_open_cache=1000 ---table_definition_cache=2000 ---read_buffer_size=1M ---thread_cache_size=8 ---max_connections=1024 ---long_query_time=60 ---slow_query_log=1 -# End of 10.5 test diff --git a/mysql-test/main/my_print_defaults.test b/mysql-test/main/my_print_defaults.test deleted file mode 100644 index cc467ff09dc..00000000000 --- a/mysql-test/main/my_print_defaults.test +++ /dev/null @@ -1,29 +0,0 @@ ---echo # ---echo # Beginning of 10.5 Test ---echo # ---echo # ---echo # MDEV-24248: my_print_defaults is not taking all the values when using ---echo # -e option which is called from mysql.server (extra_args). ---echo # - ---echo # checking for mysql.server - ---write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf - -[mariadb] -key_buffer_size=20M -max_allowed_packet=250M -table_open_cache=1000 -table_definition_cache=2000 -read_buffer_size=1M -thread_cache_size=8 -max_connections=1024 -long_query_time=60 -slow_query_log=1 -EOF - ---exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mysqld mysql.server - ---remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf - ---echo # End of 10.5 test diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index f26b95aea78..cefb3225e9e 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -200,11 +200,11 @@ su_kill() { extra_args="" if test -r "$basedir/my.cnf" then - extra_args="--defaults-extra-file=$basedir/my.cnf" + extra_args="-e $basedir/my.cnf" else if test -r "$datadir/my.cnf" then - extra_args="--defaults-extra-file=$datadir/my.cnf" + extra_args="-e $datadir/my.cnf" fi fi From a7d880f0b095939118594ecbeba953959ae8e351 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Mon, 22 Jun 2020 18:21:21 +0200 Subject: [PATCH 10/11] MDEV-21916: COM_STMT_BULK_EXECUTE with RETURNING insert wrong values The problem is that array binding uses net buffer to read parameters for each execution while each execiting with RETURNING write in the same buffer. Solution is to allocate new net buffer to avoid changing buffer we are reading from. --- sql/net_serv.cc | 20 ++++- sql/protocol.cc | 1 + sql/sql_delete.cc | 7 +- sql/sql_error.cc | 22 +++-- sql/sql_error.h | 11 ++- sql/sql_insert.cc | 24 +++++- sql/sql_parse.cc | 2 +- sql/sql_prepare.cc | 46 +++++++--- storage/perfschema/pfs.cc | 2 + tests/mysql_client_test.c | 174 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 282 insertions(+), 27 deletions(-) diff --git a/sql/net_serv.cc b/sql/net_serv.cc index a96c43a94fe..1d2409f16cf 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -179,14 +179,26 @@ my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags) DBUG_RETURN(0); } + +/** + Allocate and assign new net buffer + + @note In case of error the old buffer left + + @retval TRUE error + @retval FALSE success +*/ + my_bool net_allocate_new_packet(NET *net, void *thd, uint my_flags) { + uchar *tmp; DBUG_ENTER("net_allocate_new_packet"); - if (!(net->buff=(uchar*) my_malloc(key_memory_NET_buff, - (size_t) net->max_packet + - NET_HEADER_SIZE + COMP_HEADER_SIZE + 1, - MYF(MY_WME | my_flags)))) + if (!(tmp= (uchar*) my_malloc(key_memory_NET_buff, + (size_t) net->max_packet + + NET_HEADER_SIZE + COMP_HEADER_SIZE + 1, + MYF(MY_WME | my_flags)))) DBUG_RETURN(1); + net->buff= tmp; net->buff_end=net->buff+net->max_packet; net->write_pos=net->read_pos = net->buff; DBUG_RETURN(0); diff --git a/sql/protocol.cc b/sql/protocol.cc index 08b874adba1..eb50b02cf3c 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -598,6 +598,7 @@ void Protocol::end_statement() thd->get_stmt_da()->get_sqlstate()); break; case Diagnostics_area::DA_EOF: + case Diagnostics_area::DA_EOF_BULK: error= send_eof(thd->server_status, thd->get_stmt_da()->statement_warn_count()); break; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 870eecdd494..1966a77aa3e 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -698,7 +698,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, !table->prepare_triggers_for_delete_stmt_or_event()) will_batch= !table->file->start_bulk_delete(); - if (returning) + /* + thd->get_stmt_da()->is_set() means first iteration of prepared statement + with array binding operation execution (non optimized so it is not + INSERT) + */ + if (returning && !thd->get_stmt_da()->is_set()) { if (result->send_result_set_metadata(returning->item_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/sql_error.cc b/sql/sql_error.cc index b3ef0d89a98..80cdc0bc734 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -372,7 +372,7 @@ Diagnostics_area::set_eof_status(THD *thd) { DBUG_ENTER("set_eof_status"); /* Only allowed to report eof if has not yet reported an error */ - DBUG_ASSERT(! is_set()); + DBUG_ASSERT(!is_set() || (m_status == DA_EOF_BULK && is_bulk_op())); /* In production, refuse to overwrite an error or a custom response with an EOF packet. @@ -385,11 +385,23 @@ Diagnostics_area::set_eof_status(THD *thd) number of warnings, since they are not available to the client anyway. */ - m_statement_warn_count= (thd->spcont ? - 0 : - current_statement_warn_count()); + if (m_status == DA_EOF_BULK) + { + if (!thd->spcont) + m_statement_warn_count+= current_statement_warn_count(); + } + else + { + if (thd->spcont) + { + m_statement_warn_count= 0; + m_affected_rows= 0; + } + else + m_statement_warn_count= current_statement_warn_count(); + m_status= (is_bulk_op() ? DA_EOF_BULK : DA_EOF); + } - m_status= DA_EOF; DBUG_VOID_RETURN; } diff --git a/sql/sql_error.h b/sql/sql_error.h index a0497af78cb..c4ac88d6414 100644 --- a/sql/sql_error.h +++ b/sql/sql_error.h @@ -960,6 +960,8 @@ public: DA_EOF, /** Set whenever one calls my_ok() in PS bulk mode. */ DA_OK_BULK, + /** Set whenever one calls my_eof() in PS bulk mode. */ + DA_EOF_BULK, /** Set whenever one calls my_error() or my_message(). */ DA_ERROR, /** Set in case of a custom response, such as one from COM_STMT_PREPARE. */ @@ -1019,8 +1021,11 @@ public: enum_diagnostics_status status() const { return m_status; } const char *message() const - { DBUG_ASSERT(m_status == DA_ERROR || m_status == DA_OK || - m_status == DA_OK_BULK); return m_message; } + { + DBUG_ASSERT(m_status == DA_ERROR || m_status == DA_OK || + m_status == DA_OK_BULK || m_status == DA_EOF_BULK); + return m_message; + } bool skip_flush() const { @@ -1055,7 +1060,7 @@ public: uint statement_warn_count() const { DBUG_ASSERT(m_status == DA_OK || m_status == DA_OK_BULK || - m_status == DA_EOF); + m_status == DA_EOF ||m_status == DA_EOF_BULK ); return m_statement_warn_count; } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index ab2c479af5c..9d3444a5ac6 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -710,6 +710,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, Name_resolution_context *context; Name_resolution_context_state ctx_state; SELECT_LEX *returning= thd->lex->has_returning() ? thd->lex->returning() : 0; + unsigned char *readbuff= NULL; #ifndef EMBEDDED_LIBRARY char *query= thd->query(); @@ -786,7 +787,25 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, /* Prepares LEX::returing_list if it is not empty */ if (returning) + { result->prepare(returning->item_list, NULL); + if (thd->is_bulk_op()) + { + /* + It is RETURNING which needs network buffer to write result set and + it is array binfing which need network buffer to read parameters. + So we allocate yet another network buffer. + The old buffer will be freed at the end of operation. + */ + DBUG_ASSERT(thd->protocol == &thd->protocol_binary); + readbuff= thd->net.buff; // old buffer + if (net_allocate_new_packet(&thd->net, thd, MYF(MY_THREAD_SPECIFIC))) + { + readbuff= NULL; // failure, net_allocate_new_packet keeps old buffer + goto abort; + } + } + } context= &thd->lex->first_select_lex()->context; /* @@ -1316,7 +1335,8 @@ values_loop_end: thd->lex->current_select->save_leaf_tables(thd); thd->lex->current_select->first_cond_optimization= 0; } - + if (readbuff) + my_free(readbuff); DBUG_RETURN(FALSE); abort: @@ -1330,6 +1350,8 @@ abort: if (!joins_freed) free_underlaid_joins(thd, thd->lex->first_select_lex()); thd->abort_on_warning= 0; + if (readbuff) + my_free(readbuff); DBUG_RETURN(retval); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 63898ad4db7..19f80606e34 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2356,7 +2356,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, size_t next_length_length= packet_start - packet; unsigned char *readbuff= net->buff; - if (net_allocate_new_packet(net, thd, MYF(0))) + if (net_allocate_new_packet(net, thd, MYF(MY_THREAD_SPECIFIC))) break; PSI_statement_locker *save_locker= thd->m_statement_psi; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 5fac9071575..0684f8c5e51 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -894,6 +894,9 @@ static bool insert_bulk_params(Prepared_statement *stmt, case STMT_INDICATOR_IGNORE: param->set_ignore(); break; + default: + DBUG_ASSERT(0); + DBUG_RETURN(1); } } else @@ -4567,6 +4570,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query, uchar *packet_end_arg) { Reprepare_observer reprepare_observer; + unsigned char *readbuff= NULL; bool error= 0; packet= packet_arg; packet_end= packet_end_arg; @@ -4580,24 +4584,37 @@ Prepared_statement::execute_bulk_loop(String *expanded_query, if (state == Query_arena::STMT_ERROR) { my_message(last_errno, last_error, MYF(0)); - thd->set_bulk_execution(0); - return TRUE; + goto err; } /* Check for non zero parameter count*/ if (param_count == 0) { DBUG_PRINT("error", ("Statement with no parameters for bulk execution.")); my_error(ER_UNSUPPORTED_PS, MYF(0)); - thd->set_bulk_execution(0); - return TRUE; + goto err; } if (!(sql_command_flags[lex->sql_command] & CF_PS_ARRAY_BINDING_SAFE)) { DBUG_PRINT("error", ("Command is not supported in bulk execution.")); my_error(ER_UNSUPPORTED_PS, MYF(0)); - thd->set_bulk_execution(0); - return TRUE; + goto err; + } + /* + Here second buffer for not optimized commands, + optimized commands do it inside thier internal loop. + */ + if (!(sql_command_flags[lex->sql_command] & CF_PS_ARRAY_BINDING_OPTIMIZED) && + this->lex->has_returning()) + { + // Above check can be true for SELECT in future + DBUG_ASSERT(lex->sql_command != SQLCOM_SELECT); + readbuff= thd->net.buff; // old buffer + if (net_allocate_new_packet(&thd->net, thd, MYF(MY_THREAD_SPECIFIC))) + { + readbuff= NULL; // failure, net_allocate_new_packet keeps old buffer + goto err; + } } #ifndef EMBEDDED_LIBRARY @@ -4609,9 +4626,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query, { my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysqld_stmt_bulk_execute"); - reset_stmt_params(this); - thd->set_bulk_execution(0); - return true; + goto err; } read_types= FALSE; @@ -4628,8 +4643,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query, { if (set_bulk_parameters(TRUE)) { - thd->set_bulk_execution(0); - return true; + goto err; } } @@ -4693,8 +4707,16 @@ reexecute: } reset_stmt_params(this); thd->set_bulk_execution(0); - + if (readbuff) + my_free(readbuff); return error; + +err: + reset_stmt_params(this); + thd->set_bulk_execution(0); + if (readbuff) + my_free(readbuff); + return true; } diff --git a/storage/perfschema/pfs.cc b/storage/perfschema/pfs.cc index 1bb712f64cc..3e9198a6b6c 100644 --- a/storage/perfschema/pfs.cc +++ b/storage/perfschema/pfs.cc @@ -5466,6 +5466,7 @@ void pfs_end_statement_v1(PSI_statement_locker *locker, void *stmt_da) switch(da->status()) { case Diagnostics_area::DA_OK_BULK: + case Diagnostics_area::DA_EOF_BULK: case Diagnostics_area::DA_EMPTY: break; case Diagnostics_area::DA_OK: @@ -5706,6 +5707,7 @@ void pfs_end_statement_v1(PSI_statement_locker *locker, void *stmt_da) switch (da->status()) { case Diagnostics_area::DA_OK_BULK: + case Diagnostics_area::DA_EOF_BULK: case Diagnostics_area::DA_EMPTY: break; case Diagnostics_area::DA_OK: diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 4b3e0a5b446..7587e08e727 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -20547,6 +20547,178 @@ static void test_bulk_replace() rc= mysql_query(mysql, "DROP TABLE t1"); myquery(rc); } + + +static void test_bulk_insert_returning() +{ + int rc; + MYSQL_STMT *stmt; + MYSQL_BIND bind[2], res_bind[2]; + MYSQL_ROW row; + MYSQL_RES *result; + int i, + id[]= {1, 2, 3, 4}, + val[]= {1, 1, 1, 1}, + count= sizeof(id)/sizeof(id[0]); + unsigned long length[2]; + my_bool is_null[2]; + my_bool error[2]; + int32 res[2]; + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + rc= mysql_query(mysql, + "CREATE TABLE t1 (id int not null primary key, active int)"); + myquery(rc); + + stmt= mysql_stmt_init(mysql); + rc= mysql_stmt_prepare(stmt, + "insert into t1 values (?, ?) returning id, active", + -1); + check_execute(stmt, rc); + + memset(bind, 0, sizeof(bind)); + bind[0].buffer_type = MYSQL_TYPE_LONG; + bind[0].buffer = (void *)id; + bind[0].buffer_length = 0; + bind[1].buffer_type = MYSQL_TYPE_LONG; + bind[1].buffer = (void *)val; + bind[1].buffer_length = 0; + + mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, (void*)&count); + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + myquery(rc); + + memset(res_bind, 0, sizeof(res_bind)); + for (i= 0; i < 2; i++) + { + res_bind[i].buffer_type= MYSQL_TYPE_LONG; + res_bind[i].buffer= (char *)&res[i]; + res_bind[i].is_null= &is_null[i]; + res_bind[i].length= &length[i]; + res_bind[i].error= &error[i]; + } + rc= mysql_stmt_bind_result(stmt, res_bind); + myquery(rc); + rc= mysql_stmt_store_result(stmt); + myquery(rc); + + i= 0; + while (!mysql_stmt_fetch(stmt)) + { + i++; + DIE_IF(is_null[0] || is_null[1]); + DIE_IF(res[0] != i); + DIE_IF(res[1] != 1); + } + DIE_IF(i != 4); + + mysql_stmt_close(stmt); + + rc= mysql_query(mysql, "SELECT id,active FROM t1"); + myquery(rc); + + result= mysql_store_result(mysql); + mytest(result); + + i= 0; + while ((row= mysql_fetch_row(result))) + { + i++; + DIE_IF(atoi(row[0]) != i); + DIE_IF(atoi(row[1]) != 1); + } + DIE_IF(i != 4); + mysql_free_result(result); + + + rc= mysql_query(mysql, "DROP TABLE t1"); + myquery(rc); +} + +static void test_bulk_delete_returning() +{ + int rc; + MYSQL_STMT *stmt; + MYSQL_BIND bind[2], res_bind[2]; + MYSQL_ROW row; + MYSQL_RES *result; + int i, + id[]= {1, 2, 3, 4}, + count= sizeof(id)/sizeof(id[0]); + unsigned long length[1]; + my_bool is_null[1]; + my_bool error[1]; + int32 res[1]; + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE t1 (id int not null primary key)"); + myquery(rc); + rc= mysql_query(mysql, "insert into t1 values (1), (2), (3), (4)"); + myquery(rc); + verify_affected_rows(4); + + stmt= mysql_stmt_init(mysql); + rc= mysql_stmt_prepare(stmt, "DELETE FROM t1 WHERE id=? RETURNING id", -1); + check_execute(stmt, rc); + + memset(bind, 0, sizeof(bind)); + bind[0].buffer_type = MYSQL_TYPE_LONG; + bind[0].buffer = (void *)id; + bind[0].buffer_length = 0; + + mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, (void*)&count); + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + myquery(rc); + + memset(res_bind, 0, sizeof(res_bind)); + res_bind[0].buffer_type= MYSQL_TYPE_LONG; + res_bind[0].buffer= (char *)&res[0]; + res_bind[0].is_null= &is_null[0]; + res_bind[0].length= &length[0]; + res_bind[0].error= &error[0]; + rc= mysql_stmt_bind_result(stmt, res_bind); + myquery(rc); + rc= mysql_stmt_store_result(stmt); + myquery(rc); + + i= 0; + while (!mysql_stmt_fetch(stmt)) + { + i++; + DIE_IF(is_null[0]); + DIE_IF(res[0] != i); + } + DIE_IF(i != 4); + + mysql_stmt_close(stmt); + + rc= mysql_query(mysql, "SELECT id FROM t1"); + myquery(rc); + + result= mysql_store_result(mysql); + mytest(result); + + i= 0; + while ((row= mysql_fetch_row(result))) + { + i++; + printf("\nResult (SHOULD NOT BE HERE!!!) %d %s \n", i, row[0]); + } + DIE_IF(i != 0 ); + mysql_free_result(result); + + + rc= mysql_query(mysql, "DROP TABLE t1"); + myquery(rc); +} #endif @@ -21427,6 +21599,8 @@ static struct my_tests_st my_tests[]= { { "test_bulk_autoinc", test_bulk_autoinc}, { "test_bulk_delete", test_bulk_delete }, { "test_bulk_replace", test_bulk_replace }, + { "test_bulk_insert_returning", test_bulk_insert_returning }, + { "test_bulk_delete_returning", test_bulk_delete_returning }, #endif { "test_ps_params_in_ctes", test_ps_params_in_ctes }, { "test_explain_meta", test_explain_meta }, From fc2ec25733c6f1a305bf14df960ee7a02b48ef2c Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 16 Jul 2021 11:27:41 +0200 Subject: [PATCH 11/11] MDEV-26166 replace log_write_up_to(LSN_MAX,...) with log_buffer_flush_to_disk() Also, remove comparison lsn > flush/write lsn, prior to calling log_write_up_to. The checks and early returns are part of this function. --- storage/innobase/buf/buf0dblwr.cc | 3 +-- storage/innobase/include/log0log.h | 9 --------- storage/innobase/log/log0log.cc | 1 + storage/innobase/mtr/mtr0mtr.cc | 2 +- storage/innobase/row/row0mysql.cc | 4 ++-- storage/innobase/srv/srv0srv.cc | 2 +- storage/innobase/srv/srv0start.cc | 2 +- storage/innobase/trx/trx0purge.cc | 2 +- 8 files changed, 8 insertions(+), 17 deletions(-) diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 845aa749856..52e947b7c5e 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -681,8 +681,7 @@ void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request) static_cast(frame))); ut_ad(lsn); ut_ad(lsn >= bpage->oldest_modification()); - if (lsn > log_sys.get_flushed_lsn()) - log_write_up_to(lsn, true); + log_write_up_to(lsn, true); e.request.node->space->io(e.request, bpage->physical_offset(), e_size, frame, bpage); } diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 849485eae5a..fbcc30ee7ca 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -699,15 +699,6 @@ public: /** Shut down the redo log subsystem. */ void close(); - - /** Initiate a write of the log buffer to the file if needed. - @param flush whether to initiate a durable write */ - inline void initiate_write(bool flush) - { - const lsn_t lsn= get_lsn(); - if (!flush || get_flushed_lsn() < lsn) - log_write_up_to(lsn, flush); - } }; /** Redo log system */ diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 83036d81658..ece26ded72e 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -792,6 +792,7 @@ void log_write_up_to(lsn_t lsn, bool flush_to_disk, bool rotate_key) { ut_ad(!srv_read_only_mode); ut_ad(!rotate_key || flush_to_disk); + ut_ad(lsn != LSN_MAX); if (recv_no_ibuf_operations) { diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index f6747686eb5..691b393561f 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -689,7 +689,7 @@ static lsn_t log_reserve_and_open(size_t len) DEBUG_SYNC_C("log_buf_size_exceeded"); /* Not enough free space, do a write of the log buffer */ - log_sys.initiate_write(false); + log_write_up_to(log_sys.get_lsn(), false); srv_stats.log_waits.inc(); diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index ce0746f20c6..6998a5730f9 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -2989,13 +2989,13 @@ row_discard_tablespace_end( } DBUG_EXECUTE_IF("ib_discard_before_commit_crash", - log_write_up_to(LSN_MAX, true); + log_buffer_flush_to_disk(); DBUG_SUICIDE();); trx_commit_for_mysql(trx); DBUG_EXECUTE_IF("ib_discard_after_commit_crash", - log_write_up_to(LSN_MAX, true); + log_buffer_flush_to_disk(); DBUG_SUICIDE();); row_mysql_unlock_data_dictionary(trx); diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 02711e99c07..ad221dc205c 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1518,7 +1518,7 @@ srv_sync_log_buffer_in_background(void) srv_main_thread_op_info = "flushing log"; if (difftime(current_time, srv_last_log_flush_time) >= srv_flush_log_at_timeout) { - log_sys.initiate_write(true); + log_buffer_flush_to_disk(); srv_last_log_flush_time = current_time; srv_log_writes_and_flush++; } diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index c4bf7ccb68b..aa6e7ce11f9 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -331,7 +331,7 @@ static dberr_t create_log_file(bool create_new_db, lsn_t lsn, mysql_mutex_unlock(&log_sys.mutex); log_make_checkpoint(); - log_write_up_to(LSN_MAX, true); + log_buffer_flush_to_disk(); return DB_SUCCESS; } diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 563ce9d0e23..28491853150 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -792,7 +792,7 @@ not_free: DBUG_EXECUTE_IF("ib_undo_trunc", ib::info() << "ib_undo_trunc"; - log_write_up_to(LSN_MAX, true); + log_buffer_flush_to_disk(); DBUG_SUICIDE();); for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) {