Commit efae1268 authored by Sachin Setiya's avatar Sachin Setiya

MDEV-15611 Due to the failure of foreign key detection, Galera...

slave node killed himself.

Problem:- If we try to delete table with foreign key and table whom it is
referring with wsrep_slave_threads>1 then galera tries to execute both
Delete_rows_log-event in parallel, which should not happen.

Solution:- This is happening because we do not have foreign key info in
write set. Upto version 10.2.7 it used to work fine. Actually it happening
because of issue in commit 2f342c45. wsrep_must_process_fk has changed to
make it similar to original condition.
parent 66c14d3a
connection node_1;
CREATE TABLE t1 (
id int primary key
);
CREATE TABLE t2 (
id int primary key ,
f_id int DEFAULT NULL, FOREIGN KEY(f_id) REFERENCES t1 (id)
);
insert into t1 select 1;
#Running 200 insert in t2 table
select count(*) from t2;
count(*)
200
delete from t2;
delete from t1;
drop table t2,t1;
!include ../galera_2nodes.cnf
[mysqld.1]
[mysqld.2]
wsrep_slave_threads=6
--source include/galera_cluster.inc
--source include/have_innodb.inc
--connection node_1
CREATE TABLE t1 (
id int primary key
);
CREATE TABLE t2 (
id int primary key ,
f_id int DEFAULT NULL, FOREIGN KEY(f_id) REFERENCES t1 (id)
);
insert into t1 select 1;
--disable_query_log
--let $count=200
--echo #Running 200 insert in t2 table
while($count)
{
#Repeatedly execute the following SQL until you generate thousands of data
--eval insert into t2 values ($count, 1);
--dec $count
}
--enable_query_log
select count(*) from t2;
delete from t2;
delete from t1;
drop table t2,t1;
......@@ -466,17 +466,15 @@ wsrep_row_upd_check_foreign_constraints(
@param[in] node query node
@param[in] trx transaction
@return whether the node cannot be ignored */
inline
bool
wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx)
inline bool wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx)
{
if (que_node_get_type(node->common.parent) != QUE_NODE_UPDATE
|| !wsrep_on_trx(trx)) {
if (!wsrep_on_trx(trx)) {
return false;
}
return static_cast<upd_node_t*>(node->common.parent)->cascade_node
== node;
return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE
|| static_cast<upd_node_t*>(node->common.parent)->cascade_node
!= node;
}
#endif /* WITH_WSREP */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment