Skip to content

Commit 4918fc5

Browse files
committed
MDEV-30764 : Assertion `transaction.is_streaming()' failed in void wsrep::transaction::adopt(const wsrep::transaction&)
This is very special case because test first sets read_only=ON disabling some of the writes. Based on documentation replication (slave) threads are not affected by this option. However, threads executing streaming replication recovery were effected by read_only setting. Fix is to set thd->security_ctx->skip_grants() for streaming replication threads so that they are not affected by read_only setting.
1 parent 34a8209 commit 4918fc5

File tree

3 files changed

+167
-0
lines changed

3 files changed

+167
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
connection node_2;
2+
connection node_1;
3+
connection node_1;
4+
connection node_2;
5+
connection node_1;
6+
SET GLOBAL wsrep_provider_options ='pc.ignore_sb=true;pc.weight=2';
7+
connection node_2;
8+
SET GLOBAL read_only=1;
9+
SET SESSION wsrep_trx_fragment_size = 64;
10+
set default_storage_engine=SEQUENCE;
11+
SET AUTOCOMMIT = OFF;
12+
CREATE TABLE t1(c1 NUMERIC NOT NULL);
13+
ERROR HY000: Can't create table `test`.`t1` (errno: 131 "Command not supported by the engine")
14+
CREATE TABLE t1 (id INT PRIMARY KEY) engine=innodb;
15+
SET SESSION SQL_MODE='HIGH_NOT_PRECEDENCE';
16+
INSERT INTO t1 VALUES (1),(2),(3);
17+
SET GLOBAL SQL_MODE='NO_ENGINE_SUBSTITUTION';
18+
DROP TABLE dummy;
19+
ERROR 42S02: Unknown table 'test.dummy'
20+
INSERT INTO t1 VALUES('a');
21+
Warnings:
22+
Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`id` at row 1
23+
# In this point there should be one fragment
24+
select count(*) AS EXPECT_1 from mysql.wsrep_streaming_log;
25+
EXPECT_1
26+
1
27+
SET @@global.wsrep_cluster_address='gcomm://';
28+
SET SESSION SQL_MODE='TRADITIONAL ';
29+
# Killing cluster because we have messed with wsrep_cluster_address
30+
connection node_2;
31+
SET SESSION wsrep_sync_wait = 0;
32+
Killing server ...
33+
connection node_1;
34+
SET SESSION wsrep_sync_wait = 0;
35+
Killing server ...
36+
connection node_2;
37+
call mtr.add_suppression("WSREP: BF applier thread");
38+
call mtr.add_suppression("WSREP: Event");
39+
call mtr.add_suppression("WSREP: SR trx recovery applying returned 1290");
40+
call mtr.add_suppression("WSREP: Adopting a transaction");
41+
call mtr.add_suppression("WSREP: Could not find applier context for");
42+
call mtr.add_suppression("WSREP: It may not be safe to bootstrap the cluster");
43+
call mtr.add_suppression("WSREP: Failed to vote on request for");
44+
select count(*) AS EXPECT_0 from mysql.wsrep_streaming_log;
45+
EXPECT_0
46+
0
47+
SELECT * FROM t1;
48+
c1
49+
connection node_1;
50+
select count(*) AS EXPECT_0 from mysql.wsrep_streaming_log;
51+
EXPECT_0
52+
0
53+
SELECT * FROM t1;
54+
c1
55+
DROP TABLE t1;
56+
SET GLOBAL wsrep_provider_options ='pc.ignore_sb=false;pc.weight=1';
57+
connection node_2;
58+
connection node_1;
59+
call mtr.add_suppression("WSREP: Event");
60+
call mtr.add_suppression("WSREP: Inconsistency detected: Inconsistent by consensus on");
61+
call mtr.add_suppression("WSREP: Failed to apply write set: gtid");
62+
call mtr.add_suppression("WSREP: It may not be safe to bootstrap the cluster");
63+
call mtr.add_suppression("WSREP: Could not find applier context for");
64+
call mtr.add_suppression("WSREP: Failed to vote on request for");
65+
disconnect node_2;
66+
disconnect node_1;
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
--source include/galera_cluster.inc
2+
--source include/have_sequence.inc
3+
4+
# Save original auto_increment_offset values.
5+
--let $node_1=node_1
6+
--let $node_2=node_2
7+
--source include/auto_increment_offset_save.inc
8+
9+
--connection node_1
10+
SET GLOBAL wsrep_provider_options ='pc.ignore_sb=true;pc.weight=2';
11+
12+
--connection node_2
13+
--let $wsrep_cluster_address_saved = `SELECT @@global.wsrep_cluster_address`
14+
SET GLOBAL read_only=1;
15+
SET SESSION wsrep_trx_fragment_size = 64;
16+
set default_storage_engine=SEQUENCE;
17+
SET AUTOCOMMIT = OFF;
18+
--error 1005
19+
CREATE TABLE t1(c1 NUMERIC NOT NULL);
20+
CREATE TABLE t1 (id INT PRIMARY KEY) engine=innodb;
21+
SET SESSION SQL_MODE='HIGH_NOT_PRECEDENCE';
22+
INSERT INTO t1 VALUES (1),(2),(3);
23+
SET GLOBAL SQL_MODE='NO_ENGINE_SUBSTITUTION';
24+
--error 1051
25+
DROP TABLE dummy;
26+
INSERT INTO t1 VALUES('a');
27+
--echo # In this point there should be one fragment
28+
select count(*) AS EXPECT_1 from mysql.wsrep_streaming_log;
29+
SET @@global.wsrep_cluster_address='gcomm://';
30+
SET SESSION SQL_MODE='TRADITIONAL ';
31+
32+
#
33+
# Kill the entire cluster and restart
34+
#
35+
--echo # Killing cluster because we have messed with wsrep_cluster_address
36+
--connection node_2
37+
SET SESSION wsrep_sync_wait = 0;
38+
--source include/kill_galera.inc
39+
40+
--connection node_1
41+
SET SESSION wsrep_sync_wait = 0;
42+
--source include/kill_galera.inc
43+
44+
--remove_file $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
45+
--let $start_mysqld_params =--wsrep-new-cluster
46+
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
47+
--source include/start_mysqld.inc
48+
--source include/wait_until_ready.inc
49+
50+
--connection node_2
51+
--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
52+
--let $start_mysqld_params =
53+
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
54+
--source include/start_mysqld.inc
55+
--source include/wait_until_ready.inc
56+
57+
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
58+
--source include/wait_condition.inc
59+
60+
call mtr.add_suppression("WSREP: BF applier thread");
61+
call mtr.add_suppression("WSREP: Event");
62+
call mtr.add_suppression("WSREP: SR trx recovery applying returned 1290");
63+
call mtr.add_suppression("WSREP: Adopting a transaction");
64+
call mtr.add_suppression("WSREP: Could not find applier context for");
65+
call mtr.add_suppression("WSREP: It may not be safe to bootstrap the cluster");
66+
call mtr.add_suppression("WSREP: Failed to vote on request for");
67+
68+
select count(*) AS EXPECT_0 from mysql.wsrep_streaming_log;
69+
70+
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'
71+
--source include/wait_condition.inc
72+
73+
SELECT * FROM t1;
74+
75+
--connection node_1
76+
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
77+
--source include/wait_condition.inc
78+
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'
79+
--source include/wait_condition.inc
80+
select count(*) AS EXPECT_0 from mysql.wsrep_streaming_log;
81+
SELECT * FROM t1;
82+
DROP TABLE t1;
83+
SET GLOBAL wsrep_provider_options ='pc.ignore_sb=false;pc.weight=1';
84+
85+
--connection node_2
86+
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'
87+
--source include/wait_condition.inc
88+
89+
--connection node_1
90+
call mtr.add_suppression("WSREP: Event");
91+
call mtr.add_suppression("WSREP: Inconsistency detected: Inconsistent by consensus on");
92+
call mtr.add_suppression("WSREP: Failed to apply write set: gtid");
93+
call mtr.add_suppression("WSREP: It may not be safe to bootstrap the cluster");
94+
call mtr.add_suppression("WSREP: Could not find applier context for");
95+
call mtr.add_suppression("WSREP: Failed to vote on request for");
96+
97+
# Restore original auto_increment_offset values.
98+
--source include/auto_increment_offset_restore.inc
99+
100+
--source include/galera_end.inc

sql/wsrep_server_service.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static void init_service_thd(THD* thd, void* thread_stack)
3939
thd->thread_stack= thread_stack;
4040
thd->real_id= pthread_self();
4141
thd->prior_thr_create_utime= thd->start_utime= microsecond_interval_timer();
42+
thd->security_ctx->skip_grants();
4243
thd->mark_connection_idle();
4344
thd->reset_for_next_command(true);
4445
server_threads.insert(thd); // as wsrep_innobase_kill_one_trx() uses find_thread_by_id()

0 commit comments

Comments
 (0)