From 497a4169df5cd9837efd7a32b16426c92e3da882 Mon Sep 17 00:00:00 2001 From: Kentoku SHIBA Date: Wed, 25 Mar 2020 22:40:14 +0900 Subject: [PATCH 1/6] change from to for adding defaults-file in Spider tests --- .../spider/bugfix/r/return_found_rows_insert.result | 6 +++--- .../spider/bugfix/r/return_found_rows_update.result | 2 +- .../spider/bugfix/t/return_found_rows_insert.test | 12 ++++++------ .../spider/bugfix/t/return_found_rows_update.test | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_insert.result b/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_insert.result index df88d7a5165..2ddec02ef81 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_insert.result +++ b/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_insert.result @@ -34,7 +34,7 @@ FLUSH TABLES; select test 1 connection child2_1; TRUNCATE TABLE mysql.general_log; -EXE_MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND INSERT IGNORE INTO tbl_a (skey, dt, tm) VALUES (0, '2013-01-01', '13:00:00'),(2, '2013-02-01', '13:00:00'),(4, '2013-03-01', '13:00:00'),(7, '2013-04-01', '13:00:00'),(8, '2013-05-01', '13:00:00'),(10, '2013-06-01', '13:00:00'),(11, '2013-07-01', '13:00:00'),(12, '2013-08-01', '13:00:00'),(13, '2013-09-01', '13:00:00'),(14, '2013-10-01', '13:00:00')" auto_test_local +MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND INSERT IGNORE INTO tbl_a (skey, dt, tm) VALUES (0, '2013-01-01', '13:00:00'),(2, '2013-02-01', '13:00:00'),(4, '2013-03-01', '13:00:00'),(7, '2013-04-01', '13:00:00'),(8, '2013-05-01', '13:00:00'),(10, '2013-06-01', '13:00:00'),(11, '2013-07-01', '13:00:00'),(12, '2013-08-01', '13:00:00'),(13, '2013-09-01', '13:00:00'),(14, '2013-10-01', '13:00:00')" auto_test_local -------------- set session spider_direct_dup_insert=1 -------------- @@ -72,7 +72,7 @@ skey dt tm 13 2013-09-01 13:00:00 14 2013-10-01 13:00:00 TRUNCATE TABLE mysql.general_log; -EXE_MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND REPLACE INTO tbl_a (skey, dt, tm) VALUES (1, '2012-02-01', '12:00:00'),(3, '2012-12-01', '11:00:00'),(8, '2012-11-30', '11:00:00'),(9, '2012-11-29', '11:00:00'),(10, '2012-11-28', '11:00:00'),(15, '2012-11-27', '11:00:00'),(16, '2012-11-26', '11:00:00'),(17, '2012-11-25', '11:00:00'),(18, '2012-11-24', '11:00:00'),(19, '2012-11-23', '11:00:00')" auto_test_local +MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND REPLACE INTO tbl_a (skey, dt, tm) VALUES (1, '2012-02-01', '12:00:00'),(3, '2012-12-01', '11:00:00'),(8, '2012-11-30', '11:00:00'),(9, '2012-11-29', '11:00:00'),(10, '2012-11-28', '11:00:00'),(15, '2012-11-27', '11:00:00'),(16, '2012-11-26', '11:00:00'),(17, '2012-11-25', '11:00:00'),(18, '2012-11-24', '11:00:00'),(19, '2012-11-23', '11:00:00')" auto_test_local -------------- set session spider_direct_dup_insert=1 -------------- @@ -115,7 +115,7 @@ skey dt tm 18 2012-11-24 11:00:00 19 2012-11-23 11:00:00 TRUNCATE TABLE mysql.general_log; -EXE_MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND INSERT INTO tbl_a (skey, dt, tm) VALUES (1, '2012-11-01', '11:00:00'),(3, '2012-12-01', '11:00:00'),(11, '2012-11-30', '11:00:00'),(15, '2012-11-29', '11:00:00'),(16, '2012-11-28', '11:00:00'),(20, '2012-11-27', '11:00:00'),(21, '2012-11-26', '11:00:00'),(22, '2012-11-25', '11:00:00'),(23, '2012-11-24', '11:00:00'),(24, '2012-11-23', '11:00:00') ON DUPLICATE KEY UPDATE dt=VALUE(dt), tm=VALUE(tm)" auto_test_local +MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND INSERT INTO tbl_a (skey, dt, tm) VALUES (1, '2012-11-01', '11:00:00'),(3, '2012-12-01', '11:00:00'),(11, '2012-11-30', '11:00:00'),(15, '2012-11-29', '11:00:00'),(16, '2012-11-28', '11:00:00'),(20, '2012-11-27', '11:00:00'),(21, '2012-11-26', '11:00:00'),(22, '2012-11-25', '11:00:00'),(23, '2012-11-24', '11:00:00'),(24, '2012-11-23', '11:00:00') ON DUPLICATE KEY UPDATE dt=VALUE(dt), tm=VALUE(tm)" auto_test_local -------------- set session spider_direct_dup_insert=1 -------------- diff --git a/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_update.result b/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_update.result index 2ebc2693dc5..cd5423ed272 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_update.result +++ b/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_update.result @@ -36,7 +36,7 @@ FLUSH TABLES; select test 1 connection child2_1; TRUNCATE TABLE mysql.general_log; -EXE_MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "UPDATE tbl_a SET tm = '12:00:00' WHERE skey = 0" auto_test_local +MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "UPDATE tbl_a SET tm = '12:00:00' WHERE skey = 0" auto_test_local -------------- UPDATE tbl_a SET tm = '12:00:00' WHERE skey = 0 -------------- diff --git a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test index ea2a2147910..2beb9d9d7e4 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test +++ b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test @@ -51,8 +51,8 @@ FLUSH TABLES; TRUNCATE TABLE mysql.general_log; --disable_query_log -echo EXE_MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND INSERT IGNORE INTO tbl_a (skey, dt, tm) VALUES (0, '2013-01-01', '13:00:00'),(2, '2013-02-01', '13:00:00'),(4, '2013-03-01', '13:00:00'),(7, '2013-04-01', '13:00:00'),(8, '2013-05-01', '13:00:00'),(10, '2013-06-01', '13:00:00'),(11, '2013-07-01', '13:00:00'),(12, '2013-08-01', '13:00:00'),(13, '2013-09-01', '13:00:00'),(14, '2013-10-01', '13:00:00')" auto_test_local; -exec $EXE_MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK -e "$MASTER_1_SET_COMMAND INSERT IGNORE INTO tbl_a (skey, dt, tm) VALUES (0, '2013-01-01', '13:00:00'),(2, '2013-02-01', '13:00:00'),(4, '2013-03-01', '13:00:00'),(7, '2013-04-01', '13:00:00'),(8, '2013-05-01', '13:00:00'),(10, '2013-06-01', '13:00:00'),(11, '2013-07-01', '13:00:00'),(12, '2013-08-01', '13:00:00'),(13, '2013-09-01', '13:00:00'),(14, '2013-10-01', '13:00:00')" auto_test_local; +echo MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND INSERT IGNORE INTO tbl_a (skey, dt, tm) VALUES (0, '2013-01-01', '13:00:00'),(2, '2013-02-01', '13:00:00'),(4, '2013-03-01', '13:00:00'),(7, '2013-04-01', '13:00:00'),(8, '2013-05-01', '13:00:00'),(10, '2013-06-01', '13:00:00'),(11, '2013-07-01', '13:00:00'),(12, '2013-08-01', '13:00:00'),(13, '2013-09-01', '13:00:00'),(14, '2013-10-01', '13:00:00')" auto_test_local; +exec $MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK -e "$MASTER_1_SET_COMMAND INSERT IGNORE INTO tbl_a (skey, dt, tm) VALUES (0, '2013-01-01', '13:00:00'),(2, '2013-02-01', '13:00:00'),(4, '2013-03-01', '13:00:00'),(7, '2013-04-01', '13:00:00'),(8, '2013-05-01', '13:00:00'),(10, '2013-06-01', '13:00:00'),(11, '2013-07-01', '13:00:00'),(12, '2013-08-01', '13:00:00'),(13, '2013-09-01', '13:00:00'),(14, '2013-10-01', '13:00:00')" auto_test_local; --enable_query_log --connection child2_1 @@ -62,8 +62,8 @@ eval $CHILD2_1_SELECT_TABLES; TRUNCATE TABLE mysql.general_log; --disable_query_log -echo EXE_MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND REPLACE INTO tbl_a (skey, dt, tm) VALUES (1, '2012-02-01', '12:00:00'),(3, '2012-12-01', '11:00:00'),(8, '2012-11-30', '11:00:00'),(9, '2012-11-29', '11:00:00'),(10, '2012-11-28', '11:00:00'),(15, '2012-11-27', '11:00:00'),(16, '2012-11-26', '11:00:00'),(17, '2012-11-25', '11:00:00'),(18, '2012-11-24', '11:00:00'),(19, '2012-11-23', '11:00:00')" auto_test_local; -exec $EXE_MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK -e "$MASTER_1_SET_COMMAND REPLACE INTO tbl_a (skey, dt, tm) VALUES (1, '2012-02-01', '12:00:00'),(3, '2012-12-01', '11:00:00'),(8, '2012-11-30', '11:00:00'),(9, '2012-11-29', '11:00:00'),(10, '2012-11-28', '11:00:00'),(15, '2012-11-27', '11:00:00'),(16, '2012-11-26', '11:00:00'),(17, '2012-11-25', '11:00:00'),(18, '2012-11-24', '11:00:00'),(19, '2012-11-23', '11:00:00')" auto_test_local; +echo MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND REPLACE INTO tbl_a (skey, dt, tm) VALUES (1, '2012-02-01', '12:00:00'),(3, '2012-12-01', '11:00:00'),(8, '2012-11-30', '11:00:00'),(9, '2012-11-29', '11:00:00'),(10, '2012-11-28', '11:00:00'),(15, '2012-11-27', '11:00:00'),(16, '2012-11-26', '11:00:00'),(17, '2012-11-25', '11:00:00'),(18, '2012-11-24', '11:00:00'),(19, '2012-11-23', '11:00:00')" auto_test_local; +exec $MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK -e "$MASTER_1_SET_COMMAND REPLACE INTO tbl_a (skey, dt, tm) VALUES (1, '2012-02-01', '12:00:00'),(3, '2012-12-01', '11:00:00'),(8, '2012-11-30', '11:00:00'),(9, '2012-11-29', '11:00:00'),(10, '2012-11-28', '11:00:00'),(15, '2012-11-27', '11:00:00'),(16, '2012-11-26', '11:00:00'),(17, '2012-11-25', '11:00:00'),(18, '2012-11-24', '11:00:00'),(19, '2012-11-23', '11:00:00')" auto_test_local; --enable_query_log --connection child2_1 @@ -73,8 +73,8 @@ eval $CHILD2_1_SELECT_TABLES; TRUNCATE TABLE mysql.general_log; --disable_query_log -echo EXE_MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND INSERT INTO tbl_a (skey, dt, tm) VALUES (1, '2012-11-01', '11:00:00'),(3, '2012-12-01', '11:00:00'),(11, '2012-11-30', '11:00:00'),(15, '2012-11-29', '11:00:00'),(16, '2012-11-28', '11:00:00'),(20, '2012-11-27', '11:00:00'),(21, '2012-11-26', '11:00:00'),(22, '2012-11-25', '11:00:00'),(23, '2012-11-24', '11:00:00'),(24, '2012-11-23', '11:00:00') ON DUPLICATE KEY UPDATE dt=VALUE(dt), tm=VALUE(tm)" auto_test_local; -exec $EXE_MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK -e "$MASTER_1_SET_COMMAND INSERT INTO tbl_a (skey, dt, tm) VALUES (1, '2012-11-01', '11:00:00'),(3, '2012-12-01', '11:00:00'),(11, '2012-11-30', '11:00:00'),(15, '2012-11-29', '11:00:00'),(16, '2012-11-28', '11:00:00'),(20, '2012-11-27', '11:00:00'),(21, '2012-11-26', '11:00:00'),(22, '2012-11-25', '11:00:00'),(23, '2012-11-24', '11:00:00'),(24, '2012-11-23', '11:00:00') ON DUPLICATE KEY UPDATE dt=VALUE(dt), tm=VALUE(tm)" auto_test_local; +echo MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "MASTER_1_SET_COMMAND INSERT INTO tbl_a (skey, dt, tm) VALUES (1, '2012-11-01', '11:00:00'),(3, '2012-12-01', '11:00:00'),(11, '2012-11-30', '11:00:00'),(15, '2012-11-29', '11:00:00'),(16, '2012-11-28', '11:00:00'),(20, '2012-11-27', '11:00:00'),(21, '2012-11-26', '11:00:00'),(22, '2012-11-25', '11:00:00'),(23, '2012-11-24', '11:00:00'),(24, '2012-11-23', '11:00:00') ON DUPLICATE KEY UPDATE dt=VALUE(dt), tm=VALUE(tm)" auto_test_local; +exec $MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK -e "$MASTER_1_SET_COMMAND INSERT INTO tbl_a (skey, dt, tm) VALUES (1, '2012-11-01', '11:00:00'),(3, '2012-12-01', '11:00:00'),(11, '2012-11-30', '11:00:00'),(15, '2012-11-29', '11:00:00'),(16, '2012-11-28', '11:00:00'),(20, '2012-11-27', '11:00:00'),(21, '2012-11-26', '11:00:00'),(22, '2012-11-25', '11:00:00'),(23, '2012-11-24', '11:00:00'),(24, '2012-11-23', '11:00:00') ON DUPLICATE KEY UPDATE dt=VALUE(dt), tm=VALUE(tm)" auto_test_local; --enable_query_log --connection child2_1 diff --git a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test index 9cf653e26b4..50d9f345dfb 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test +++ b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test @@ -53,8 +53,8 @@ FLUSH TABLES; TRUNCATE TABLE mysql.general_log; --disable_query_log -echo EXE_MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "UPDATE tbl_a SET tm = '12:00:00' WHERE skey = 0" auto_test_local; -exec $EXE_MYSQL -v -v -u root -h localhost --default-character-set=latin1 -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK -e "UPDATE tbl_a SET tm = '12:00:00' WHERE skey = 0" auto_test_local; +echo MYSQL -v -v -u root -h localhost -P MASTER_1_MYPORT -S MASTER_1_MYSOCK -e "UPDATE tbl_a SET tm = '12:00:00' WHERE skey = 0" auto_test_local; +exec $MYSQL -v -v -u root -h localhost --default-character-set=latin1 -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK -e "UPDATE tbl_a SET tm = '12:00:00' WHERE skey = 0" auto_test_local; --enable_query_log --connection child2_1 From 3a1075b93ed75c47e3c1e6819a406fcf355bb6fa Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 25 Mar 2020 18:16:36 +0100 Subject: [PATCH 2/6] MDEV-19519 mysql_install_db.exe doesn't set password_last_changed for newly created password --- sql/mysql_install_db.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 54bd46240bc..b841c64c331 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -364,11 +364,12 @@ static int create_myini() static const char update_root_passwd_part1[]= "UPDATE mysql.global_priv SET priv=json_set(priv," + "'$.password_last_changed', UNIX_TIMESTAMP()," "'$.plugin','mysql_native_password'," "'$.authentication_string',PASSWORD("; static const char update_root_passwd_part2[]= ")) where User='root';\n"; -static const char remove_default_user_cmd[]= +static const char remove_default_user_cmd[]= "DELETE FROM mysql.user where User='';\n"; static const char allow_remote_root_access_cmd[]= "CREATE TEMPORARY TABLE tmp_user LIKE global_priv;\n" From 98fc6b923f69cd054ef715f918f72da72555bad3 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 25 Mar 2020 19:45:37 +0100 Subject: [PATCH 3/6] MDEV-20388 : disable inline assembly in WolfSSL if MSAN is on A desperate attempt to workaround MemorySanitizer deficiencies. --- extra/wolfssl/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/extra/wolfssl/CMakeLists.txt b/extra/wolfssl/CMakeLists.txt index dced917169a..e2ba345e3c8 100644 --- a/extra/wolfssl/CMakeLists.txt +++ b/extra/wolfssl/CMakeLists.txt @@ -12,13 +12,16 @@ IF(MSVC) ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") IF(CMAKE_C_COMPILER_ID MATCHES GNU AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) MESSAGE_ONCE(NO_INTEL_ASSEMBLY "Disable Intel assembly for WolfSSL - compiler is too old") + ELSEIF(WITH_MSAN) + MESSAGE_ONCE(MSAN_CANT_HANDLE_IT + "Disable Intel assembly for WolfSSL - MSAN can't handle it") ELSE() MY_CHECK_C_COMPILER_FLAG(-maes) MY_CHECK_C_COMPILER_FLAG(-msse4) MY_CHECK_C_COMPILER_FLAG(-mpclmul) - ENDIF() - IF(have_C__maes AND have_C__msse4 AND have_C__mpclmul) - SET(WOLFSSL_INTELASM ON) + IF(have_C__maes AND have_C__msse4 AND have_C__mpclmul) + SET(WOLFSSL_INTELASM ON) + ENDIF() ENDIF() ENDIF() ENDIF() From 1c8de231a3ea7ef2e08b1a5cfe17c37d733ea6ce Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 25 Mar 2020 17:27:42 +0400 Subject: [PATCH 4/6] dequeued_count my_atomic to Atomic_counter Also allocate inuse_relaylog with new rather than my_malloc(MY_ZEROFILL). --- sql/rpl_parallel.cc | 2 +- sql/rpl_rli.cc | 20 ++++++++------------ sql/rpl_rli.h | 12 +++++++++++- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 4313840119e..f5a30d6f877 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -1775,7 +1775,7 @@ rpl_parallel_thread::inuse_relaylog_refcount_update() inuse_relaylog *ir= accumulated_ir_last; if (ir) { - my_atomic_add64(&ir->dequeued_count, accumulated_ir_count); + ir->dequeued_count+= accumulated_ir_count; accumulated_ir_count= 0; accumulated_ir_last= NULL; } diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 18ee6a98ed0..49b2e00882e 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1435,31 +1435,27 @@ Relay_log_info::alloc_inuse_relaylog(const char *name) uint32 gtid_count; rpl_gtid *gtid_list; - if (!(ir= (inuse_relaylog *)my_malloc(sizeof(*ir), MYF(MY_WME|MY_ZEROFILL)))) - { - my_error(ER_OUTOFMEMORY, MYF(0), (int)sizeof(*ir)); - return 1; - } gtid_count= relay_log_state.count(); if (!(gtid_list= (rpl_gtid *)my_malloc(sizeof(*gtid_list)*gtid_count, MYF(MY_WME)))) { - my_free(ir); my_error(ER_OUTOFMEMORY, MYF(0), (int)sizeof(*gtid_list)*gtid_count); return 1; } + if (!(ir= new inuse_relaylog(this, gtid_list, gtid_count, name))) + { + my_free(gtid_list); + my_error(ER_OUTOFMEMORY, MYF(0), (int) sizeof(*ir)); + return 1; + } if (relay_log_state.get_gtid_list(gtid_list, gtid_count)) { my_free(gtid_list); - my_free(ir); + delete ir; DBUG_ASSERT(0 /* Should not be possible as we allocated correct length */); my_error(ER_OUT_OF_RESOURCES, MYF(0)); return 1; } - ir->rli= this; - strmake_buf(ir->name, name); - ir->relay_log_state= gtid_list; - ir->relay_log_state_count= gtid_count; if (!inuse_relaylog_list) inuse_relaylog_list= ir; @@ -1478,7 +1474,7 @@ void Relay_log_info::free_inuse_relaylog(inuse_relaylog *ir) { my_free(ir->relay_log_state); - my_free(ir); + delete ir; } diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 0e2e42fcb08..5d2d33c397f 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -608,10 +608,20 @@ struct inuse_relaylog { /* Number of events in this relay log queued for worker threads. */ int64 queued_count; /* Number of events completed by worker threads. */ - volatile int64 dequeued_count; + Atomic_counter dequeued_count; /* Set when all events have been read from a relaylog. */ bool completed; char name[FN_REFLEN]; + + inuse_relaylog(Relay_log_info *rli_arg, rpl_gtid *relay_log_state_arg, + uint32 relay_log_state_count_arg, + const char *name_arg): + next(0), rli(rli_arg), relay_log_state(relay_log_state_arg), + relay_log_state_count(relay_log_state_count_arg), queued_count(0), + dequeued_count(0), completed(false) + { + strmake_buf(name, name_arg); + } }; From af4b2ae8588bd51cc17e66cfc8210c3225992fbe Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 26 Mar 2020 15:01:44 +0300 Subject: [PATCH 5/6] MDEV-21887: federatedx crashes on SELECT ... INTO query in select_handler code Backport to 10.4: - Don't try to push down SELECTs that have a side effect - In case the storage engine did support pushdown of SELECT with an INTO clause, write the rows we've got from it into select->join->result, and not thd->protocol. This way, SELECT ... INTO ... FROM smart_engine_table will put the result into where instructed, and NOT send it to the client. --- .../federatedx_create_handlers.result | 22 +++++++++++++++- .../federated/federatedx_create_handlers.test | 21 +++++++++++++++- sql/select_handler.cc | 25 +++---------------- storage/federatedx/federatedx_pushdown.cc | 13 +++++++++- 4 files changed, 57 insertions(+), 24 deletions(-) diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index 473972c2cd4..65a9d52803f 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -299,7 +299,27 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 7 1 PRIMARY ref key0 key0 18 federated.t3.name 2 2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE federated.t1, federated.t2, federated.t3; +# +# MDEV-21887: federatedx crashes on SELECT ... INTO query in select_handler code +# +CREATE TABLE federated.t4 ( +id int(20) NOT NULL, +name varchar(16) NOT NULL default '' +) engine=myisam; +insert into federated.t4 select * from federated.t1; +select * from federated.t4; +id name +1 zzz +3 xxx +4 xxx +5 yyy +7 yyy +select name into @var from federated.t1 where id=3 limit 1 ; +select @var; +@var +xxx +select name into outfile 'tmp.txt' from federated.t1; +DROP TABLE federated.t1, federated.t2, federated.t3, federated.t4; connection slave; DROP TABLE federated.t1, federated.t2; connection default; diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test index 373b2aaaa33..42a03e60d67 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.test +++ b/mysql-test/suite/federated/federatedx_create_handlers.test @@ -147,8 +147,27 @@ FROM federated.t3, SELECT * FROM federated.t1 WHERE id >= 5) t WHERE federated.t3.name=t.name; +--echo # +--echo # MDEV-21887: federatedx crashes on SELECT ... INTO query in select_handler code +--echo # -DROP TABLE federated.t1, federated.t2, federated.t3; +CREATE TABLE federated.t4 ( + id int(20) NOT NULL, + name varchar(16) NOT NULL default '' +) engine=myisam; +insert into federated.t4 select * from federated.t1; + +--sorted_result +select * from federated.t4; + +select name into @var from federated.t1 where id=3 limit 1 ; +select @var; +select name into outfile 'tmp.txt' from federated.t1; + +let $path=`select concat(@@datadir, 'test/tmp.txt')`; +remove_file $path; + +DROP TABLE federated.t1, federated.t2, federated.t3, federated.t4; connection slave; DROP TABLE federated.t1, federated.t2; diff --git a/sql/select_handler.cc b/sql/select_handler.cc index b364cb12341..495b6d957b1 100644 --- a/sql/select_handler.cc +++ b/sql/select_handler.cc @@ -77,18 +77,17 @@ bool Pushdown_select::init() bool Pushdown_select::send_result_set_metadata() { - THD *thd= handler->thd; - Protocol *protocol= thd->protocol; DBUG_ENTER("Pushdown_select::send_result_set_metadata"); #ifdef WITH_WSREP + THD *thd= handler->thd; if (WSREP(thd) && thd->wsrep_retry_query) { WSREP_DEBUG("skipping select metadata"); DBUG_RETURN(false); } #endif /* WITH_WSREP */ - if (protocol->send_result_set_metadata(&result_columns, + if (select->join->result->send_result_set_metadata(result_columns, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_RETURN(true); @@ -100,23 +99,13 @@ bool Pushdown_select::send_result_set_metadata() bool Pushdown_select::send_data() { THD *thd= handler->thd; - Protocol *protocol= thd->protocol; DBUG_ENTER("Pushdown_select::send_data"); if (thd->killed == ABORT_QUERY) DBUG_RETURN(false); - protocol->prepare_for_resend(); - if (protocol->send_result_set_row(&result_columns)) - { - protocol->remove_last_row(); + if (select->join->result->send_data(result_columns)) DBUG_RETURN(true); - } - - thd->inc_sent_row_count(1); - - if (thd->vio_ok()) - DBUG_RETURN(protocol->write()); DBUG_RETURN(false); } @@ -124,16 +113,10 @@ bool Pushdown_select::send_data() bool Pushdown_select::send_eof() { - THD *thd= handler->thd; DBUG_ENTER("Pushdown_select::send_eof"); - /* - Don't send EOF if we're in error condition (which implies we've already - sent or are sending an error) - */ - if (thd->is_error()) + if (select->join->result->send_eof()) DBUG_RETURN(true); - ::my_eof(thd); DBUG_RETURN(false); } diff --git a/storage/federatedx/federatedx_pushdown.cc b/storage/federatedx/federatedx_pushdown.cc index 2bcee943308..15b0b0d3d4e 100644 --- a/storage/federatedx/federatedx_pushdown.cc +++ b/storage/federatedx/federatedx_pushdown.cc @@ -182,6 +182,16 @@ create_federatedx_select_handler(THD* thd, SELECT_LEX *sel) return 0; } + /* + Currently, ha_federatedx_select_handler::init_scan just takes the + thd->query and sends it to the backend. + This obviously won't work if the SELECT uses an "INTO @var" or + "INTO OUTFILE". It is also unlikely to work if the select has some + other kind of side effect. + */ + if (sel->uncacheable & UNCACHEABLE_SIDEEFFECT) + return NULL; + handler= new ha_federatedx_select_handler(thd, sel); return handler; @@ -286,8 +296,9 @@ int ha_federatedx_select_handler::end_scan() DBUG_RETURN(0); } -void ha_federatedx_select_handler::print_error(int, unsigned long) +void ha_federatedx_select_handler::print_error(int error, myf error_flag) { + select_handler::print_error(error, error_flag); } From ba679ae52f0e9d698c1b36d28a5bc8c233e57a2e Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Thu, 26 Mar 2020 19:19:41 +0400 Subject: [PATCH 6/6] Fix for rpl_start_stop_slave failure One may access freed THD members after LOCK_thd_kill is released. With original code it can happen when killing wsrep-disabled thread on a wsrep-enabled server. With 91ab42a8 it is happening on a wsrep-disabled server. --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9af4afd4b03..ffba46b4573 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -9086,8 +9086,8 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ else error= (type == KILL_TYPE_QUERY ? ER_KILL_QUERY_DENIED_ERROR : ER_KILL_DENIED_ERROR); - mysql_mutex_unlock(&tmp->LOCK_thd_kill); if (WSREP(tmp)) mysql_mutex_unlock(&tmp->LOCK_thd_data); + mysql_mutex_unlock(&tmp->LOCK_thd_kill); } DBUG_PRINT("exit", ("%d", error)); DBUG_RETURN(error);