[Commits] d52cff9: MDEV-15611 Due to the failure of foreign key detection, Galera...

sachin sachin.setiya at mariadb.com
Wed Apr 4 09:56:19 EEST 2018


revision-id: d52cff9f10aeea208a1058f7b5527e602125584c (mariadb-10.2.14-25-gd52cff9)
parent(s): bc2501453c3ab9a2cf3516bc3557de8665bc2776
author: Sachin Setiya
committer: Sachin Setiya
timestamp: 2018-04-04 12:26:06 +0530
message:

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 2f342c4. wsrep_must_process_fk should be used
with negation.

---
 mysql-test/suite/galera/r/galera_mdev_15611.result | 16 ++++++++++++
 mysql-test/suite/galera/t/galera_mdev_15611.test   | 30 ++++++++++++++++++++++
 storage/innobase/row/row0upd.cc                    |  6 ++---
 3 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/mysql-test/suite/galera/r/galera_mdev_15611.result b/mysql-test/suite/galera/r/galera_mdev_15611.result
new file mode 100644
index 0000000..9ea1684
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_mdev_15611.result
@@ -0,0 +1,16 @@
+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;
diff --git a/mysql-test/suite/galera/t/galera_mdev_15611.test b/mysql-test/suite/galera/t/galera_mdev_15611.test
new file mode 100644
index 0000000..d32d7e7
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_mdev_15611.test
@@ -0,0 +1,30 @@
+--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;
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index 5009ac0..fe13fc3 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -2434,7 +2434,7 @@ row_upd_sec_index_entry(
 			}
 #ifdef WITH_WSREP
 			if (!referenced && foreign
-			    && wsrep_must_process_fk(node, trx)
+			    && !wsrep_must_process_fk(node, trx)
 			    && !wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
 
 				ulint*	offsets = rec_get_offsets(
@@ -2744,7 +2744,7 @@ row_upd_clust_rec_by_insert(
 				goto err_exit;
 			}
 #ifdef WITH_WSREP
-		} else if (foreign && wsrep_must_process_fk(node, trx)) {
+		} else if (foreign && !wsrep_must_process_fk(node, trx)) {
 			err = wsrep_row_upd_check_foreign_constraints(
 				node, pcur, table, index, offsets, thr, mtr);
 
@@ -2973,7 +2973,7 @@ row_upd_del_mark_clust_rec(
 		err = row_upd_check_references_constraints(
 			node, pcur, index->table, index, offsets, thr, mtr);
 #ifdef WITH_WSREP
-	} else if (foreign && wsrep_must_process_fk(node, trx)) {
+	} else if (foreign && !wsrep_must_process_fk(node, trx)) {
 		err = wsrep_row_upd_check_foreign_constraints(
 			node, pcur, index->table, index, offsets, thr, mtr);
 


More information about the commits mailing list