summaryrefslogtreecommitdiff
path: root/storage/xtradb/row/row0ins.cc
diff options
context:
space:
mode:
authorSachin Setiya <sachin.setiya@mariadb.com>2017-06-22 11:38:50 +0530
committerSachin Setiya <sachin.setiya@mariadb.com>2017-06-22 11:38:50 +0530
commite333d8296480afc63962892f6c8e101dfcaa2686 (patch)
treee2173b25cc04f857b6d4f06fdedf0e2cd010cec2 /storage/xtradb/row/row0ins.cc
parent472c2d9b2fbb262665bdd08338ea902e8398010d (diff)
downloadmariadb-git-e333d8296480afc63962892f6c8e101dfcaa2686.tar.gz
MDEV-12398 All cluster nodes stop due to a foreign key constraint failure
Comment from Codership:- To fix the problem, we changed the certification logic in galera to treat insert on child table row as exclusive to prevent any operation on referenced parent table row. At the same time, update and delete on child table row were demoted to "shared", which makes it possible to update/delete referenced parent table row, but only in a later transaction. This change allows somewhat more concurrency for foreign key constrained transactions, but is still safe for correct certification end result.
Diffstat (limited to 'storage/xtradb/row/row0ins.cc')
-rw-r--r--storage/xtradb/row/row0ins.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc
index 6072b303d3a..00b8ce17b26 100644
--- a/storage/xtradb/row/row0ins.cc
+++ b/storage/xtradb/row/row0ins.cc
@@ -1296,11 +1296,12 @@ row_ins_foreign_check_on_constraint(
#ifdef WITH_WSREP
err = wsrep_append_foreign_key(
- thr_get_trx(thr),
- foreign,
- clust_rec,
- clust_index,
- FALSE, FALSE);
+ thr_get_trx(thr),
+ foreign,
+ clust_rec,
+ clust_index,
+ FALSE,
+ (node) ? TRUE : FALSE);
if (err != DB_SUCCESS) {
fprintf(stderr,
"WSREP: foreign key append failed: %d\n", err);
@@ -1461,6 +1462,9 @@ row_ins_check_foreign_constraint(
ulint* offsets = offsets_;
rec_offs_init(offsets_);
+#ifdef WITH_WSREP
+ upd_node= NULL;
+#endif /* WITH_WSREP */
run_again:
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_SHARED));
@@ -1651,8 +1655,9 @@ run_again:
thr_get_trx(thr),
foreign,
rec,
- check_index,
- check_ref, TRUE);
+ check_index,
+ check_ref,
+ (upd_node) ? TRUE : FALSE);
#endif /* WITH_WSREP */
goto end_scan;
} else if (foreign->type != 0) {