Skip to content

Commit

Permalink
Merge 10.3 into 10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Nov 12, 2019
2 parents e5f99a0 + 5098d70 commit 33cb10d
Show file tree
Hide file tree
Showing 18 changed files with 543 additions and 498 deletions.
56 changes: 56 additions & 0 deletions mysql-test/main/selectivity.result
Expand Up @@ -1810,5 +1810,61 @@ b a a b
9 9 10 10
set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
drop table t1,t2,t3;
#
# MDEV-20519: Query plan regression with optimizer_use_condition_selectivity=4
#
create table t1 (id int, a int, PRIMARY KEY(id), key(a));
insert into t1 select seq,seq from seq_1_to_100;
create table t2 (id int, a int, b int, PRIMARY KEY(id), key(a), key(b));
insert into t2 select seq,seq,seq from seq_1_to_100;
set optimizer_switch='exists_to_in=off';
set optimizer_use_condition_selectivity=2;
SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id a
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1
1 SIMPLE B ref a a 5 const 1
explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
32 changes: 32 additions & 0 deletions mysql-test/main/selectivity.test
Expand Up @@ -1235,6 +1235,38 @@ set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;

drop table t1,t2,t3;


--echo #
--echo # MDEV-20519: Query plan regression with optimizer_use_condition_selectivity=4
--echo #



create table t1 (id int, a int, PRIMARY KEY(id), key(a));
insert into t1 select seq,seq from seq_1_to_100;

create table t2 (id int, a int, b int, PRIMARY KEY(id), key(a), key(b));
insert into t2 select seq,seq,seq from seq_1_to_100;

set optimizer_switch='exists_to_in=off';
set optimizer_use_condition_selectivity=2;

let $query= SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);

eval $query;
eval explain $query;

EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65;

eval explain $query;

set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;

--echo # End of 10.1 tests

#
Expand Down
56 changes: 56 additions & 0 deletions mysql-test/main/selectivity_innodb.result
Expand Up @@ -1820,6 +1820,62 @@ b a a b
9 9 10 10
set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
drop table t1,t2,t3;
#
# MDEV-20519: Query plan regression with optimizer_use_condition_selectivity=4
#
create table t1 (id int, a int, PRIMARY KEY(id), key(a));
insert into t1 select seq,seq from seq_1_to_100;
create table t2 (id int, a int, b int, PRIMARY KEY(id), key(a), key(b));
insert into t2 select seq,seq,seq from seq_1_to_100;
set optimizer_switch='exists_to_in=off';
set optimizer_use_condition_selectivity=2;
SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id a
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1
1 SIMPLE B ref a a 5 const 1 Using index
explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/suite/binlog_encryption/rpl_corruption.result
Expand Up @@ -30,7 +30,7 @@ SET GLOBAL master_verify_checksum=0;
SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set";
connection slave;
START SLAVE IO_THREAD;
include/wait_for_slave_io_error.inc [errno=1595,1913]
include/wait_for_slave_io_error.inc [errno=1595,1743]
connection master;
SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set";
SET GLOBAL debug_dbug= "";
Expand All @@ -39,7 +39,7 @@ SET GLOBAL master_verify_checksum=1;
connection slave;
SET GLOBAL debug_dbug="+d,corrupt_queue_event";
START SLAVE IO_THREAD;
include/wait_for_slave_io_error.inc [errno=1595,1913]
include/wait_for_slave_io_error.inc [errno=1595,1743]
SET GLOBAL debug_dbug="-d,corrupt_queue_event";
# 6. Slave. Corruption in relay log
SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char";
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/rpl/include/rpl_corruption.inc
Expand Up @@ -122,11 +122,11 @@ SET GLOBAL master_verify_checksum=0;
SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set";
--connection slave
START SLAVE IO_THREAD;
# When the checksum error is detected, the slave sets error code 1913
# When the checksum error is detected, the slave sets error code 1743
# (ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE) in queue_event(), then immediately
# sets error 1595 (ER_SLAVE_RELAY_LOG_WRITE_FAILURE) in handle_slave_io().
# So we usually get 1595, but it is occasionally possible to get 1913.
let $slave_io_errno= 1595,1913;
# So we usually get 1595, but it is occasionally possible to get 1743.
let $slave_io_errno= 1595,1743; # ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
--source include/wait_for_slave_io_error.inc
--connection master
SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set";
Expand All @@ -138,7 +138,7 @@ SET GLOBAL master_verify_checksum=1;
--connection slave
SET GLOBAL debug_dbug="+d,corrupt_queue_event";
START SLAVE IO_THREAD;
let $slave_io_errno= 1595,1913;
let $slave_io_errno= 1595,1743; # ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
--source include/wait_for_slave_io_error.inc
SET GLOBAL debug_dbug="-d,corrupt_queue_event";

Expand Down
4 changes: 2 additions & 2 deletions mysql-test/suite/rpl/r/rpl_corruption.result
Expand Up @@ -30,7 +30,7 @@ SET GLOBAL master_verify_checksum=0;
SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set";
connection slave;
START SLAVE IO_THREAD;
include/wait_for_slave_io_error.inc [errno=1595,1913]
include/wait_for_slave_io_error.inc [errno=1595,1743]
connection master;
SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set";
SET GLOBAL debug_dbug= "";
Expand All @@ -39,7 +39,7 @@ SET GLOBAL master_verify_checksum=1;
connection slave;
SET GLOBAL debug_dbug="+d,corrupt_queue_event";
START SLAVE IO_THREAD;
include/wait_for_slave_io_error.inc [errno=1595,1913]
include/wait_for_slave_io_error.inc [errno=1595,1743]
SET GLOBAL debug_dbug="-d,corrupt_queue_event";
# 6. Slave. Corruption in relay log
SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char";
Expand Down
40 changes: 40 additions & 0 deletions mysql-test/suite/rpl/r/rpl_semi_sync_gtid_reconnect.result
@@ -0,0 +1,40 @@
include/master-slave.inc
[connection master]
connection master;
RESET MASTER;
SET @@GLOBAL.rpl_semi_sync_master_enabled = 1;
connection slave;
include/stop_slave.inc
SET @@GLOBAL. rpl_semi_sync_slave_enabled = 1;
include/start_slave.inc
connection master;
CREATE TABLE t1 (a INT);
INSERT INTO t1 SET a = 1;
include/save_master_gtid.inc
FLUSH LOGS;
INSERT INTO t1 SET a = 2;
connection slave;
connection slave;
include/stop_slave_sql.inc
connection master;
INSERT INTO t1 SET a = 3;
include/sync_slave_io_with_master.inc
connection slave;
include/stop_slave_io.inc
connection master;
RESET MASTER;
SET @@global.gtid_binlog_state = '0-1-2';
connection slave;
CHANGE MASTER TO MASTER_USE_GTID = slave_pos;
SET @@global.gtid_slave_pos = '0-1-2';
include/start_slave.inc
connection master;
INSERT INTO t1 SET a = 4;
connection master;
DROP TABLE t1;
SET @@GLOBAL. rpl_semi_sync_master_enabled = 0;
connection slave;
include/stop_slave.inc
SET @@GLOBAL. rpl_semi_sync_slave_enabled = 0;
include/start_slave.inc
include/rpl_end.inc
74 changes: 74 additions & 0 deletions mysql-test/suite/rpl/t/rpl_semi_sync_gtid_reconnect.test
@@ -0,0 +1,74 @@
source include/not_embedded.inc;
source include/have_binlog_format_mixed.inc;
source include/master-slave.inc;

#
# Semisync initialization
#
--connection master
RESET MASTER;
--let $sav_enabled_master=`SELECT @@GLOBAL.rpl_semi_sync_master_enabled`
SET @@GLOBAL.rpl_semi_sync_master_enabled = 1;

--connection slave
source include/stop_slave.inc;
--let $sav_enabled_slave=`SELECT @@GLOBAL.rpl_semi_sync_slave_enabled`
SET @@GLOBAL. rpl_semi_sync_slave_enabled = 1;
source include/start_slave.inc;

# Prove fixes to
# MDEV-19376 Assert (!m_active_tranxs->is_tranx_end_pos(trx_wait_binlog_name...)
#
#
# Run few queries to replicate/execute on slave.
# Stop the slave applier.
# Replicate/not-executed few more.
# Restart the slave.
#
--connection master
CREATE TABLE t1 (a INT);
INSERT INTO t1 SET a = 1;
--source include/save_master_gtid.inc
--let $resume_gtid = $master_pos
FLUSH LOGS;
INSERT INTO t1 SET a = 2;

--sync_slave_with_master
--connection slave
--source include/stop_slave_sql.inc

--connection master
INSERT INTO t1 SET a = 3;

# the sync connection is 'slave' by default
--source include/sync_slave_io_with_master.inc
--connection slave
--source include/stop_slave_io.inc

--connection master
RESET MASTER;
--eval SET @@global.gtid_binlog_state = '$resume_gtid'

# The resume gtid is set up to point to the very first binlog file
--connection slave
CHANGE MASTER TO MASTER_USE_GTID = slave_pos;
--eval SET @@global.gtid_slave_pos = '$resume_gtid'
# Yet the slave io first submits the last received binlog file name:pos.
--source include/start_slave.inc

# Here goes the cracker.
--connection master
INSERT INTO t1 SET a = 4;

#
# Clean up
#
--connection master
DROP TABLE t1;
--eval SET @@GLOBAL. rpl_semi_sync_master_enabled = $sav_enabled_master

--sync_slave_with_master
source include/stop_slave.inc;
--eval SET @@GLOBAL. rpl_semi_sync_slave_enabled = $sav_enabled_slave
source include/start_slave.inc;
--source include/rpl_end.inc
7 changes: 7 additions & 0 deletions scripts/wsrep_sst_mariabackup.sh
Expand Up @@ -83,7 +83,14 @@ fi
pcmd="pv $pvopts"
declare -a RC

set +e
INNOBACKUPEX_BIN=$(which mariabackup)
if test -z $INNOBACKUPEX_BIN
then
wsrep_log_error 'mariabackup binary not found in $PATH'
exit 42
fi
set -e
XBSTREAM_BIN=mbstream
XBCRYPT_BIN=xbcrypt # Not available in MariaBackup

Expand Down
5 changes: 4 additions & 1 deletion sql/sql_repl.cc
Expand Up @@ -2824,7 +2824,10 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,

/* Check if the dump thread is created by a slave with semisync enabled. */
thd->semi_sync_slave = is_semi_sync_slave();
if (repl_semisync_master.dump_start(thd, log_ident, pos))

DBUG_ASSERT(pos == linfo.pos);

if (repl_semisync_master.dump_start(thd, linfo.log_file_name, linfo.pos))
{
info->errmsg= "Failed to run hook 'transmit_start'";
info->error= ER_UNKNOWN_ERROR;
Expand Down
4 changes: 0 additions & 4 deletions sql/sql_select.cc
Expand Up @@ -9087,7 +9087,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
something went wrong.
*/
sel /= (double)table->quick_rows[key] / (double) table->stat_records();
// MDEV-20595 FIXME: DBUG_ASSERT(sel > 0 && sel <= 2.0);
set_if_smaller(sel, 1.0);
used_range_selectivity= true;
}
Expand Down Expand Up @@ -9136,7 +9135,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
if (table->field[fldno]->cond_selectivity > 0)
{
sel /= table->field[fldno]->cond_selectivity;
// MDEV-20595 FIXME: DBUG_ASSERT(sel > 0 && sel <= 2.0);
set_if_smaller(sel, 1.0);
}
/*
Expand Down Expand Up @@ -9194,7 +9192,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
if (field->cond_selectivity > 0)
{
sel/= field->cond_selectivity;
// MDEV-20595 FIXME: DBUG_ASSERT(sel > 0 && sel <= 2.0);
set_if_smaller(sel, 1.0);
}
break;
Expand All @@ -9206,7 +9203,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
sel*= table_multi_eq_cond_selectivity(join, idx, s, rem_tables,
keyparts, ref_keyuse_steps);

DBUG_ASSERT(0.0 < sel && sel <= 1.0);
return sel;
}

Expand Down

0 comments on commit 33cb10d

Please sign in to comment.