From 144217339d8dc2d6e00542cd25d97e39b90afa3f Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Wed, 25 Sep 2019 14:00:39 +0200 Subject: MDEV-20614: Syntax error, and option put in wrong place A syntax error in the mysqld_multi.sh script has been fixed here + a "--defaults-group-suffix" option has been moved to the top of the mysqld options list. --- scripts/mysqld_multi.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 0bd50c1974f..7cf22bdaf3c 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -349,7 +349,7 @@ sub start_mysqlds() $options[$j]= quote_shell_word($options[$j]); $tmp.= " $options[$j]"; } - elseif ("--defaults-group-suffix=" eq substr($options[$j], 0, 24)) + elsif ("--defaults-group-suffix=" eq substr($options[$j], 0, 24)) { $suffix_found= 1; } @@ -368,7 +368,6 @@ sub start_mysqlds() print "wanted mysqld binary.\n\n"; $info_sent= 1; } - $com.= $tmp; if (!$suffix_found) { @@ -376,6 +375,8 @@ sub start_mysqlds() $com.= $groups[$i]; } + $com.= $tmp; + if ($opt_wsrep_new_cluster) { $com.= " --wsrep-new-cluster"; } -- cgit v1.2.1 From 677cc64428c0e6b0f596c6e861a5a0f7344078c6 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 27 Sep 2019 13:20:00 +0200 Subject: chkconfig in RPM server scriptlets chkconfig --add and --del [might] invoke /sbin/insserv and even if chkconfig exists, insserv might not (SLES15). Ignore chkconfig --del errors - it's a "best effort" cleanup anyway --- support-files/rpm/server-preun.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/rpm/server-preun.sh b/support-files/rpm/server-preun.sh index 1d733a7d899..038f601f43c 100644 --- a/support-files/rpm/server-preun.sh +++ b/support-files/rpm/server-preun.sh @@ -9,7 +9,7 @@ if [ $1 = 0 ] ; then %{_sysconfdir}/init.d/mysql stop > /dev/null fi if [ -x /sbin/chkconfig ] ; then - /sbin/chkconfig --del mysql > /dev/null 2>&1 + /sbin/chkconfig --del mysql > /dev/null 2>&1 || : fi fi -- cgit v1.2.1 From 9b80f9300d6060f754d95d5a7b92706ee7d47e5e Mon Sep 17 00:00:00 2001 From: Sujatha Date: Mon, 30 Sep 2019 13:22:37 +0530 Subject: MDEV-20645: Replication consistency is broken as workers miss the error notification from an earlier failed group. Analysis: ======== In general if there are three groups. 1 - Inserts 32 which fails due to local entry '32' on slave. 2 - Inserts 33 3 - Inserts 34 Each group considers itself as a waiter and it waits for prior group 'waitee'. This is done in 'register_wait_for_prior_event_group_commit'. If there is no other parallel group being scheduled then no waitee will be there. Let us assume 3 groups are being scheduled in parallel. 3-> waits for 2-> waits for->1 '1' upon completion it checks is there any registered subsequent waiter. If so it wakes up the subsequent waiter with its execution status. This execution status is stored in wakeup_error. If '1' failed then it sends corresponding wakeup_error to 2. Then '2' aborts and it propagates error to '3'. So all further commits are aborted. This mechanism works only when all transactions reach a stage where they are waiting for their prior commit to complete. In case of optimistic following scenario occurs. 1,2,3 are scheduled in parallel. 3 - Reaches group_commit_code waits for 2 to complete. 1 - errors out sets stop_on_error_sub_id=1. When a group execution results in error its corresponding sub_id is set to 'stop_on_error_sub_id'. Any new groups queued for execution will check if their sub_id is > stop_on_error_sub_id. If it is true their execution will be skipped as prior group execution failed. 'skip_event_group=1' will be set. Since the execution of SQL thread is about to stop we just skip execution of all the following event groups. We still do all the normal waiting and wakeup processing between the event groups as a simple way to ensure that everything is stopped and cleaned up correctly. Upon error '1' transaction checks for registered waiters. Since no one is there it simply goes away. 2 - Starts the execution. It checks do I have a waitee. Since wait_commit_sub_id == entry->last_committed_sub_id no waitee is set. Secondly: 'entry->stop_on_error_sub_id' is set by '1'st execution. Now 'handle_parallel_thread' code checks if the current group 'sub_id' is greater than the 'sub_id' set within 'stop_on_error_sub_id'. Since the above is true 'skip_event_group=true' is set. Simply call 'wait_for_prior_commit' to wakeup all waiters. Group '2' didn't had any waitee and its execution is skipped. Hence its wakeup_error=0.It sends a positive wakeup signal to '3'. Which commits. This results in a missed transaction. i.e 33 is missed and 34 is committed. Fix: === When a worker learns that an earlier transaction execution has failed, and it should not proceed for further execution, it should mark its own execution status as failed so that it alerts its followers to abort as well. --- .../rpl_parallel_ignored_errors.result | 57 +++++++++++ .../rpl_parallel_ignored_errors.test | 1 + .../rpl/include/rpl_parallel_ignored_errors.inc | 112 +++++++++++++++++++++ .../suite/rpl/r/rpl_parallel_ignored_errors.result | 57 +++++++++++ .../suite/rpl/t/rpl_parallel_ignored_errors.test | 1 + sql/rpl_parallel.cc | 16 +++ 6 files changed, 244 insertions(+) create mode 100644 mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.result create mode 100644 mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.test create mode 100644 mysql-test/suite/rpl/include/rpl_parallel_ignored_errors.inc create mode 100644 mysql-test/suite/rpl/r/rpl_parallel_ignored_errors.result create mode 100644 mysql-test/suite/rpl/t/rpl_parallel_ignored_errors.test diff --git a/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.result b/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.result new file mode 100644 index 00000000000..9fbd329d58c --- /dev/null +++ b/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.result @@ -0,0 +1,57 @@ +include/master-slave.inc +[connection master] +connection server_2; +include/stop_slave.inc +connection server_2; +SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; +SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; +SET @old_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL slave_parallel_mode='optimistic'; +SET GLOBAL slave_parallel_threads= 3; +CHANGE MASTER TO master_use_gtid=slave_pos; +CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); +include/start_slave.inc +connection server_2; +connection server_1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=InnoDB; +include/save_master_gtid.inc +connection server_1; +connection server_2; +include/sync_with_master_gtid.inc +connection server_2; +connect con_temp2,127.0.0.1,root,,test,$SERVER_MYPORT_2,; +BEGIN; +INSERT INTO t1 VALUES (32); +connection server_1; +INSERT INTO t1 VALUES (32); +connection server_2; +SET GLOBAL debug_dbug="+d,hold_worker_on_schedule"; +SET debug_sync="debug_sync_action SIGNAL reached_pause WAIT_FOR continue_worker"; +connection server_1; +SET gtid_seq_no=100; +INSERT INTO t1 VALUES (33); +connection server_2; +SET debug_sync='now WAIT_FOR reached_pause'; +connection server_1; +INSERT INTO t1 VALUES (34); +connection server_2; +connection con_temp2; +COMMIT; +connection server_2; +include/stop_slave.inc +connection server_2; +include/assert.inc [table t1 should have zero rows where a>32] +connection server_2; +SELECT * FROM t1 WHERE a>32; +a +DELETE FROM t1 WHERE a=32; +SET GLOBAL slave_parallel_threads=@old_parallel_threads; +SET GLOBAL slave_parallel_mode=@old_parallel_mode; +SET GLOBAL debug_dbug=@old_debug; +SET DEBUG_SYNC= 'RESET'; +include/start_slave.inc +connection server_2; +connection server_1; +DROP TABLE t1; +include/rpl_end.inc diff --git a/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.test b/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.test new file mode 100644 index 00000000000..8a26778c8f2 --- /dev/null +++ b/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.test @@ -0,0 +1 @@ +--source suite/rpl/include/rpl_parallel_ignored_errors.inc diff --git a/mysql-test/suite/rpl/include/rpl_parallel_ignored_errors.inc b/mysql-test/suite/rpl/include/rpl_parallel_ignored_errors.inc new file mode 100644 index 00000000000..25da12f30a3 --- /dev/null +++ b/mysql-test/suite/rpl/include/rpl_parallel_ignored_errors.inc @@ -0,0 +1,112 @@ +# ==== Purpose ==== +# +# Test verifies that, in parallel replication, transaction failure notification +# is propagated to all the workers. Workers should abort the execution of +# transaction event groups, whose event positions are higher than the failing +# transaction group. +# +# ==== Implementation ==== +# +# Steps: +# 0 - Create a table t1 on master which has a primary key. Enable parallel +# replication on slave with slave_parallel_mode='optimistic' and +# slave_parallel_threads=3. +# 1 - On slave start a transaction and execute a local INSERT statement +# which will insert value 32. This is done to block the INSERT coming +# from master. +# 2 - On master execute an INSERT statement with value 32, so that it is +# blocked on slave. +# 3 - On slave enable a debug sync point such that it holds the worker thread +# execution as soon as work is scheduled to it. +# 4 - INSERT value 33 on master. It will be held on slave by other worker +# thread due to debug simulation. +# 5 - INSERT value 34 on master. +# 6 - On slave, enusre that INSERT 34 has reached a state where it waits for +# its prior transactions to commit. +# 7 - Commit the local INSERT 32 on slave server so that first worker will +# error out. +# 8 - Now send a continue signal to second worker processing 33. It should +# wakeup and propagate the error to INSERT 34. +# 9 - Upon slave stop due to error, check that no rows are found after the +# failed INSERT 32. +# +# ==== References ==== +# +# MDEV-20645: Replication consistency is broken as workers miss the error +# notification from an earlier failed group. +# + +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/have_binlog_format_statement.inc +--source include/master-slave.inc + +--enable_connect_log +--connection server_2 +--source include/stop_slave.inc +SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; +SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; +SET @old_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL slave_parallel_mode='optimistic'; +SET GLOBAL slave_parallel_threads= 3; +CHANGE MASTER TO master_use_gtid=slave_pos; +CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); +--source include/start_slave.inc + +--connection server_1 +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=InnoDB; +--source include/save_master_gtid.inc + +--connection server_2 +--source include/sync_with_master_gtid.inc + +--connect (con_temp2,127.0.0.1,root,,test,$SERVER_MYPORT_2,) +BEGIN; +INSERT INTO t1 VALUES (32); + +--connection server_1 +INSERT INTO t1 VALUES (32); + +--connection server_2 +--let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE info like "INSERT INTO t1 VALUES (32)" +--source include/wait_condition.inc +SET GLOBAL debug_dbug="+d,hold_worker_on_schedule"; +SET debug_sync="debug_sync_action SIGNAL reached_pause WAIT_FOR continue_worker"; + +--connection server_1 +SET gtid_seq_no=100; +INSERT INTO t1 VALUES (33); + +--connection server_2 +SET debug_sync='now WAIT_FOR reached_pause'; + +--connection server_1 +INSERT INTO t1 VALUES (34); + +--connection server_2 +--let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE state like "Waiting for prior transaction to commit" +--source include/wait_condition.inc +--connection con_temp2 +COMMIT; + +# Clean up. +--connection server_2 +--source include/stop_slave.inc +--let $assert_cond= COUNT(*) = 0 FROM t1 WHERE a>32 +--let $assert_text= table t1 should have zero rows where a>32 +--source include/assert.inc +SELECT * FROM t1 WHERE a>32; +DELETE FROM t1 WHERE a=32; + +SET GLOBAL slave_parallel_threads=@old_parallel_threads; +SET GLOBAL slave_parallel_mode=@old_parallel_mode; +SET GLOBAL debug_dbug=@old_debug; +SET DEBUG_SYNC= 'RESET'; +--source include/start_slave.inc + +--connection server_1 +DROP TABLE t1; +--disable_connect_log +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_parallel_ignored_errors.result b/mysql-test/suite/rpl/r/rpl_parallel_ignored_errors.result new file mode 100644 index 00000000000..9fbd329d58c --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_parallel_ignored_errors.result @@ -0,0 +1,57 @@ +include/master-slave.inc +[connection master] +connection server_2; +include/stop_slave.inc +connection server_2; +SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; +SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; +SET @old_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL slave_parallel_mode='optimistic'; +SET GLOBAL slave_parallel_threads= 3; +CHANGE MASTER TO master_use_gtid=slave_pos; +CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); +include/start_slave.inc +connection server_2; +connection server_1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=InnoDB; +include/save_master_gtid.inc +connection server_1; +connection server_2; +include/sync_with_master_gtid.inc +connection server_2; +connect con_temp2,127.0.0.1,root,,test,$SERVER_MYPORT_2,; +BEGIN; +INSERT INTO t1 VALUES (32); +connection server_1; +INSERT INTO t1 VALUES (32); +connection server_2; +SET GLOBAL debug_dbug="+d,hold_worker_on_schedule"; +SET debug_sync="debug_sync_action SIGNAL reached_pause WAIT_FOR continue_worker"; +connection server_1; +SET gtid_seq_no=100; +INSERT INTO t1 VALUES (33); +connection server_2; +SET debug_sync='now WAIT_FOR reached_pause'; +connection server_1; +INSERT INTO t1 VALUES (34); +connection server_2; +connection con_temp2; +COMMIT; +connection server_2; +include/stop_slave.inc +connection server_2; +include/assert.inc [table t1 should have zero rows where a>32] +connection server_2; +SELECT * FROM t1 WHERE a>32; +a +DELETE FROM t1 WHERE a=32; +SET GLOBAL slave_parallel_threads=@old_parallel_threads; +SET GLOBAL slave_parallel_mode=@old_parallel_mode; +SET GLOBAL debug_dbug=@old_debug; +SET DEBUG_SYNC= 'RESET'; +include/start_slave.inc +connection server_2; +connection server_1; +DROP TABLE t1; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_parallel_ignored_errors.test b/mysql-test/suite/rpl/t/rpl_parallel_ignored_errors.test new file mode 100644 index 00000000000..90f09a76546 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_parallel_ignored_errors.test @@ -0,0 +1 @@ +--source include/rpl_parallel_ignored_errors.inc diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 8fef2d66635..574730b96c1 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -228,6 +228,12 @@ finish_event_group(rpl_parallel_thread *rpt, uint64 sub_id, entry->stop_on_error_sub_id == (uint64)ULONGLONG_MAX) entry->stop_on_error_sub_id= sub_id; mysql_mutex_unlock(&entry->LOCK_parallel_entry); + DBUG_EXECUTE_IF("hold_worker_on_schedule", { + if (entry->stop_on_error_sub_id < (uint64)ULONGLONG_MAX) + { + debug_sync_set_action(thd, STRING_WITH_LEN("now SIGNAL continue_worker")); + } + }); if (rgi->killed_for_retry == rpl_group_info::RETRY_KILL_PENDING) wait_for_pending_deadlock_kill(thd, rgi); @@ -1096,6 +1102,13 @@ handle_rpl_parallel_thread(void *arg) bool did_enter_cond= false; PSI_stage_info old_stage; + DBUG_EXECUTE_IF("hold_worker_on_schedule", { + if (rgi->current_gtid.domain_id == 0 && + rgi->current_gtid.seq_no == 100) { + debug_sync_set_action(thd, + STRING_WITH_LEN("now SIGNAL reached_pause WAIT_FOR continue_worker")); + } + }); DBUG_EXECUTE_IF("rpl_parallel_scheduled_gtid_0_x_100", { if (rgi->current_gtid.domain_id == 0 && rgi->current_gtid.seq_no == 100) { @@ -1137,7 +1150,10 @@ handle_rpl_parallel_thread(void *arg) skip_event_group= do_gco_wait(rgi, gco, &did_enter_cond, &old_stage); if (unlikely(entry->stop_on_error_sub_id <= rgi->wait_commit_sub_id)) + { skip_event_group= true; + rgi->worker_error= 1; + } if (likely(!skip_event_group)) do_ftwrl_wait(rgi, &did_enter_cond, &old_stage); -- cgit v1.2.1 From d481f69a7de919f9d699bf18a5b0bfd669f6131b Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 1 Oct 2019 05:55:14 +0400 Subject: MDEV-20704 An index on a double column erroneously uses prefix compression --- mysql-test/r/myisam.result | 23 +++++++++++++++++++++++ mysql-test/t/myisam.test | 19 +++++++++++++++++++ sql/sql_table.cc | 16 ++++++++-------- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 81a2001c28c..38a77ceb346 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -2546,3 +2546,26 @@ myisam_block_size 1024 select @@global.myisam_block_size; @@global.myisam_block_size 1024 +# +# MDEV-20704 An index on a double column erroneously uses prefix compression +# +CREATE TABLE t1 ( +id INT NOT NULL PRIMARY KEY, +d DOUBLE, +KEY (d) +) ENGINE=MyISAM; + +MyISAM file: MYSQLD_DATADIR/test/t1 +Record format: Fixed length +Character set: latin1_swedish_ci (8) +Data records: 0 Deleted blocks: 0 +Recordlength: 13 + +table description: +Key Start Len Index Type +1 2 4 unique long +2 6 8 multip. double NULL +DROP TABLE t1; +# +# End of 5.5 tests +# diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index c4bb93b6bfe..29bc5ca187e 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1765,3 +1765,22 @@ DROP TABLE t1; # show variables like 'myisam_block_size'; select @@global.myisam_block_size; + + +--echo # +--echo # MDEV-20704 An index on a double column erroneously uses prefix compression +--echo # + +CREATE TABLE t1 ( + id INT NOT NULL PRIMARY KEY, + d DOUBLE, + KEY (d) +) ENGINE=MyISAM; +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--exec $MYISAMCHK -d $MYSQLD_DATADIR/test/t1 +DROP TABLE t1; + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9e80350f3ab..dad6ab79fae 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3725,16 +3725,16 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, /* Use packed keys for long strings on the first column */ if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) && !((create_info->table_options & HA_OPTION_NO_PACK_KEYS)) && - (key_part_length >= KEY_DEFAULT_PACK_LENGTH && - (sql_field->sql_type == MYSQL_TYPE_STRING || - sql_field->sql_type == MYSQL_TYPE_VARCHAR || - sql_field->pack_flag & FIELDFLAG_BLOB))) + (key_part_length >= KEY_DEFAULT_PACK_LENGTH && + (sql_field->sql_type == MYSQL_TYPE_STRING || + sql_field->sql_type == MYSQL_TYPE_VARCHAR || + f_is_blob(sql_field->pack_flag)))) { - if ((column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB)) || + if ((column_nr == 0 && f_is_blob(sql_field->pack_flag)) || sql_field->sql_type == MYSQL_TYPE_VARCHAR) - key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY; - else - key_info->flags|= HA_PACK_KEY; + key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY; + else + key_info->flags|= HA_PACK_KEY; } /* Check if the key segment is partial, set the key flag accordingly */ if (key_part_length != sql_field->key_length) -- cgit v1.2.1