Skip to content

Commit 50ef006

Browse files
committed
Merge branch '10.0' into bb-10.0-serg
2 parents 928edb5 + d6d5458 commit 50ef006

13 files changed

+390
-7
lines changed

mysql-test/r/sp.result

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7858,3 +7858,56 @@ v1
78587858
DROP PROCEDURE p1;
78597859
DROP TABLE t1;
78607860
# End of 5.5 test
7861+
#
7862+
# MDEV-7040: Crash in field_conv, memcpy_field_possible, part#2
7863+
#
7864+
create table t1 (
7865+
col1 bigint(20),
7866+
col2 char(1),
7867+
col3 char(2)
7868+
);
7869+
insert into t1 values (1,'a','a'), (2,'b','b');
7870+
create table t2 as select * from t1;
7871+
create table t3 as select * from t1;
7872+
create table t4 as select * from t1;
7873+
create table t5 as select * from t1;
7874+
create table t6 as select * from t1;
7875+
flush tables;
7876+
CREATE PROCEDURE p1()
7877+
begin
7878+
DECLARE _var1 bigint(20) UNSIGNED;
7879+
DECLARE _var2 CHAR(1) DEFAULT NULL;
7880+
DECLARE _var3 CHAR(1) DEFAULT NULL;
7881+
DECLARE _done BOOLEAN DEFAULT 0;
7882+
declare cur1 cursor for
7883+
select col1, col2, col3
7884+
from t1
7885+
where
7886+
col1 in (select t2.col1 from t2 where t2.col2=t1.col2) or
7887+
col2 in (select t3.col3 from t3 where t3.col3=t1.col2) ;
7888+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _done = 1;
7889+
OPEN cur1;
7890+
set _var1 = (select _var1 from t4 limit 1);
7891+
set _var1 = (select _var1 from t5 limit 1);
7892+
set _var1 = (select _var1 from t6 limit 1);
7893+
label1:
7894+
LOOP
7895+
SET _done = 0;
7896+
FETCH cur1 INTO _var1, _var2, _var3;
7897+
IF _done THEN
7898+
LEAVE label1;
7899+
END IF;
7900+
END LOOP label1;
7901+
CLOSE cur1;
7902+
end|
7903+
set @tmp_toc= @@table_open_cache;
7904+
set @tmp_tdc= @@table_definition_cache;
7905+
set global table_open_cache=1;
7906+
set global table_definition_cache=1;
7907+
Warnings:
7908+
Warning 1292 Truncated incorrect table_definition_cache value: '1'
7909+
call p1();
7910+
set global table_open_cache= @tmp_toc;
7911+
set global table_definition_cache= @tmp_tdc;
7912+
drop procedure p1;
7913+
drop table t1,t2,t3,t4,t5,t6;

mysql-test/r/subselect_mat.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,6 +2215,24 @@ Handler_read_rnd_next 6003
22152215
Handler_tmp_write 2000
22162216
Handler_write 1000
22172217
drop table t0,t1,t2,t3;
2218+
#
2219+
# MDEV-7971: Assertion `name != __null' failed in ACL_internal_schema_registry::lookup
2220+
# on 2nd execution os PS with multi-table update
2221+
#
2222+
CREATE TABLE t1 (f1 INT);
2223+
INSERT INTO t1 VALUES (1),(2);
2224+
CREATE TABLE t2 (f2 INT);
2225+
INSERT INTO t2 VALUES (3),(4);
2226+
CREATE TABLE t3 (f3 INT);
2227+
INSERT INTO t3 VALUES (5),(6);
2228+
PREPARE stmt FROM '
2229+
UPDATE t1, t2
2230+
SET f1 = 5
2231+
WHERE 8 IN ( SELECT MIN(f3) FROM t3 )
2232+
';
2233+
EXECUTE stmt;
2234+
EXECUTE stmt;
2235+
DROP TABLE t1,t2,t3;
22182236
set @subselect_mat_test_optimizer_switch_value=null;
22192237
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
22202238
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';

mysql-test/r/subselect_sj_mat.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,3 +2255,21 @@ Handler_read_rnd_next 6003
22552255
Handler_tmp_write 2000
22562256
Handler_write 1000
22572257
drop table t0,t1,t2,t3;
2258+
#
2259+
# MDEV-7971: Assertion `name != __null' failed in ACL_internal_schema_registry::lookup
2260+
# on 2nd execution os PS with multi-table update
2261+
#
2262+
CREATE TABLE t1 (f1 INT);
2263+
INSERT INTO t1 VALUES (1),(2);
2264+
CREATE TABLE t2 (f2 INT);
2265+
INSERT INTO t2 VALUES (3),(4);
2266+
CREATE TABLE t3 (f3 INT);
2267+
INSERT INTO t3 VALUES (5),(6);
2268+
PREPARE stmt FROM '
2269+
UPDATE t1, t2
2270+
SET f1 = 5
2271+
WHERE 8 IN ( SELECT MIN(f3) FROM t3 )
2272+
';
2273+
EXECUTE stmt;
2274+
EXECUTE stmt;
2275+
DROP TABLE t1,t2,t3;

mysql-test/suite/rpl/r/rpl_parallel.result

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,46 @@ include/stop_slave.inc
16491649
SET GLOBAL debug_dbug= @old_debg;
16501650
SET GLOBAL max_relay_log_size= @old_max;
16511651
include/start_slave.inc
1652+
*** MDEV-8302: Duplicate key with parallel replication ***
1653+
include/stop_slave.inc
1654+
/* Inject a small sleep which makes the race easier to hit. */
1655+
SET @old_dbug=@@GLOBAL.debug_dbug;
1656+
SET GLOBAL debug_dbug="+d,inject_mdev8302";
1657+
INSERT INTO t7 VALUES (100,1), (101,2), (102,3), (103,4), (104,5);
1658+
SET @old_dbug= @@SESSION.debug_dbug;
1659+
SET @commit_id= 20000;
1660+
SET SESSION debug_dbug="+d,binlog_force_commit_id";
1661+
SET SESSION debug_dbug=@old_dbug;
1662+
SELECT * FROM t7 ORDER BY a;
1663+
a b
1664+
1 1
1665+
2 2
1666+
3 86
1667+
4 4
1668+
5 5
1669+
100 5
1670+
101 1
1671+
102 2
1672+
103 3
1673+
104 4
1674+
include/save_master_gtid.inc
1675+
include/start_slave.inc
1676+
include/sync_with_master_gtid.inc
1677+
SELECT * FROM t7 ORDER BY a;
1678+
a b
1679+
1 1
1680+
2 2
1681+
3 86
1682+
4 4
1683+
5 5
1684+
100 5
1685+
101 1
1686+
102 2
1687+
103 3
1688+
104 4
1689+
include/stop_slave.inc
1690+
SET GLOBAL debug_dbug=@old_dbug;
1691+
include/start_slave.inc
16521692
include/stop_slave.inc
16531693
SET GLOBAL slave_parallel_threads=@old_parallel_threads;
16541694
include/start_slave.inc

mysql-test/suite/rpl/t/rpl_parallel.test

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,6 +2314,60 @@ SET GLOBAL max_relay_log_size= @old_max;
23142314
--source include/start_slave.inc
23152315

23162316

2317+
--echo *** MDEV-8302: Duplicate key with parallel replication ***
2318+
2319+
--connection server_2
2320+
--source include/stop_slave.inc
2321+
/* Inject a small sleep which makes the race easier to hit. */
2322+
SET @old_dbug=@@GLOBAL.debug_dbug;
2323+
SET GLOBAL debug_dbug="+d,inject_mdev8302";
2324+
2325+
2326+
--connection server_1
2327+
INSERT INTO t7 VALUES (100,1), (101,2), (102,3), (103,4), (104,5);
2328+
2329+
# Artificially create a bunch of group commits with conflicting transactions.
2330+
# The bug happened when T1 and T2 was in one group commit, and T3 was in the
2331+
# following group commit. T2 is a DELETE of a row with same primary key as a
2332+
# row that T3 inserts. T1 and T2 can conflict, causing T2 to be deadlock
2333+
# killed after starting to commit. The bug was that T2 could roll back before
2334+
# doing unmark_start_commit(); this could allow T3 to run before the retry
2335+
# of T2, causing duplicate key violation.
2336+
2337+
SET @old_dbug= @@SESSION.debug_dbug;
2338+
SET @commit_id= 20000;
2339+
SET SESSION debug_dbug="+d,binlog_force_commit_id";
2340+
2341+
--let $n = 100
2342+
--disable_query_log
2343+
while ($n)
2344+
{
2345+
eval UPDATE t7 SET b=b+1 WHERE a=100+($n MOD 5);
2346+
eval DELETE FROM t7 WHERE a=100+($n MOD 5);
2347+
2348+
SET @commit_id = @commit_id + 1;
2349+
eval INSERT INTO t7 VALUES (100+($n MOD 5), $n);
2350+
SET @commit_id = @commit_id + 1;
2351+
dec $n;
2352+
}
2353+
--enable_query_log
2354+
SET SESSION debug_dbug=@old_dbug;
2355+
2356+
2357+
SELECT * FROM t7 ORDER BY a;
2358+
--source include/save_master_gtid.inc
2359+
2360+
2361+
--connection server_2
2362+
--source include/start_slave.inc
2363+
--source include/sync_with_master_gtid.inc
2364+
SELECT * FROM t7 ORDER BY a;
2365+
2366+
--source include/stop_slave.inc
2367+
SET GLOBAL debug_dbug=@old_dbug;
2368+
--source include/start_slave.inc
2369+
2370+
23172371

23182372
# Clean up.
23192373
--connection server_2

mysql-test/t/sp.test

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9303,3 +9303,71 @@ DROP PROCEDURE p1;
93039303
DROP TABLE t1;
93049304

93059305
--echo # End of 5.5 test
9306+
9307+
--echo #
9308+
--echo # MDEV-7040: Crash in field_conv, memcpy_field_possible, part#2
9309+
--echo #
9310+
create table t1 (
9311+
col1 bigint(20),
9312+
col2 char(1),
9313+
col3 char(2)
9314+
);
9315+
insert into t1 values (1,'a','a'), (2,'b','b');
9316+
9317+
create table t2 as select * from t1;
9318+
create table t3 as select * from t1;
9319+
create table t4 as select * from t1;
9320+
create table t5 as select * from t1;
9321+
create table t6 as select * from t1;
9322+
9323+
flush tables;
9324+
9325+
DELIMITER |;
9326+
9327+
CREATE PROCEDURE p1()
9328+
begin
9329+
DECLARE _var1 bigint(20) UNSIGNED;
9330+
DECLARE _var2 CHAR(1) DEFAULT NULL;
9331+
DECLARE _var3 CHAR(1) DEFAULT NULL;
9332+
9333+
DECLARE _done BOOLEAN DEFAULT 0;
9334+
9335+
declare cur1 cursor for
9336+
select col1, col2, col3
9337+
from t1
9338+
where
9339+
col1 in (select t2.col1 from t2 where t2.col2=t1.col2) or
9340+
col2 in (select t3.col3 from t3 where t3.col3=t1.col2) ;
9341+
9342+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _done = 1;
9343+
9344+
OPEN cur1;
9345+
9346+
set _var1 = (select _var1 from t4 limit 1);
9347+
set _var1 = (select _var1 from t5 limit 1);
9348+
set _var1 = (select _var1 from t6 limit 1);
9349+
label1:
9350+
LOOP
9351+
SET _done = 0;
9352+
FETCH cur1 INTO _var1, _var2, _var3;
9353+
IF _done THEN
9354+
LEAVE label1;
9355+
END IF;
9356+
END LOOP label1;
9357+
CLOSE cur1;
9358+
end|
9359+
DELIMITER ;|
9360+
9361+
set @tmp_toc= @@table_open_cache;
9362+
set @tmp_tdc= @@table_definition_cache;
9363+
9364+
set global table_open_cache=1;
9365+
set global table_definition_cache=1;
9366+
call p1();
9367+
9368+
set global table_open_cache= @tmp_toc;
9369+
set global table_definition_cache= @tmp_tdc;
9370+
drop procedure p1;
9371+
9372+
drop table t1,t2,t3,t4,t5,t6;
9373+

mysql-test/t/subselect_sj_mat.test

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,3 +1900,28 @@ select * from t1 where (a,b) in (select max(a),b from t2 group by b);
19001900
show status where Variable_name like 'Handler_read%' or Variable_name like 'Handler_%write%';
19011901

19021902
drop table t0,t1,t2,t3;
1903+
1904+
--echo #
1905+
--echo # MDEV-7971: Assertion `name != __null' failed in ACL_internal_schema_registry::lookup
1906+
--echo # on 2nd execution os PS with multi-table update
1907+
--echo #
1908+
CREATE TABLE t1 (f1 INT);
1909+
INSERT INTO t1 VALUES (1),(2);
1910+
1911+
CREATE TABLE t2 (f2 INT);
1912+
INSERT INTO t2 VALUES (3),(4);
1913+
1914+
CREATE TABLE t3 (f3 INT);
1915+
INSERT INTO t3 VALUES (5),(6);
1916+
1917+
PREPARE stmt FROM '
1918+
UPDATE t1, t2
1919+
SET f1 = 5
1920+
WHERE 8 IN ( SELECT MIN(f3) FROM t3 )
1921+
';
1922+
1923+
EXECUTE stmt;
1924+
EXECUTE stmt;
1925+
1926+
DROP TABLE t1,t2,t3;
1927+

sql/handler.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,26 @@ int ha_rollback_trans(THD *thd, bool all)
15821582
DBUG_ASSERT(thd->transaction.stmt.ha_list == NULL ||
15831583
trans == &thd->transaction.stmt);
15841584

1585+
#ifdef HAVE_REPLICATION
1586+
if (is_real_trans)
1587+
{
1588+
/*
1589+
In parallel replication, if we need to rollback during commit, we must
1590+
first inform following transactions that we are going to abort our commit
1591+
attempt. Otherwise those following transactions can run too early, and
1592+
possibly cause replication to fail. See comments in retry_event_group().
1593+
1594+
There were several bugs with this in the past that were very hard to
1595+
track down (MDEV-7458, MDEV-8302). So we add here an assertion for
1596+
rollback without signalling following transactions. And in release
1597+
builds, we explicitly do the signalling before rolling back.
1598+
*/
1599+
DBUG_ASSERT(!(thd->rgi_slave && thd->rgi_slave->did_mark_start_commit));
1600+
if (thd->rgi_slave && thd->rgi_slave->did_mark_start_commit)
1601+
thd->rgi_slave->unmark_start_commit();
1602+
}
1603+
#endif
1604+
15851605
if (thd->in_sub_stmt)
15861606
{
15871607
DBUG_ASSERT(0);

sql/log_event.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4277,7 +4277,6 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
42774277
"mysql", rpl_gtid_slave_state_table_name.str,
42784278
errcode,
42794279
thd->get_stmt_da()->message());
4280-
trans_rollback(thd);
42814280
sub_id= 0;
42824281
thd->is_slave_error= 1;
42834282
goto end;
@@ -7367,7 +7366,6 @@ int Xid_log_event::do_apply_event(rpl_group_info *rgi)
73677366
"%s.%s: %d: %s",
73687367
"mysql", rpl_gtid_slave_state_table_name.str, ec,
73697368
thd->get_stmt_da()->message());
7370-
trans_rollback(thd);
73717369
thd->is_slave_error= 1;
73727370
return err;
73737371
}

0 commit comments

Comments
 (0)