Skip to content

Commit 6a524ca

Browse files
sjaakolaJan Lindström
authored andcommitted
MW-402 cascading FK issue (5.7 version)
Optimizing cascade node list traversal, which could turn out as performance bottleneck Even this current cascade node check could be skipped, but a dedicated mtr test is needed to confirm that
1 parent efb673f commit 6a524ca

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

storage/innobase/row/row0upd.cc

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,15 +2434,24 @@ row_upd_sec_index_entry(
24342434
row_ins_sec_index_entry() below */
24352435
if (!rec_get_deleted_flag(
24362436
rec, dict_table_is_comp(index->table))) {
2437+
2438+
#ifdef WITH_WSREP
2439+
que_node_t *parent = que_node_get_parent(node);
2440+
#endif /* WITH_WSREP */
2441+
24372442
err = btr_cur_del_mark_set_sec_rec(
24382443
flags, btr_cur, TRUE, thr, &mtr);
2444+
24392445
if (err != DB_SUCCESS) {
24402446
break;
24412447
}
24422448
#ifdef WITH_WSREP
2443-
if (!referenced && foreign
2444-
&& wsrep_must_process_fk(node, trx)
2445-
&& !wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
2449+
if (!referenced && foreign &&
2450+
wsrep_on(trx->mysql_thd) &&
2451+
!wsrep_thd_is_BF(trx->mysql_thd, FALSE) &&
2452+
(!parent || (que_node_get_type(parent) !=
2453+
QUE_NODE_UPDATE) ||
2454+
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
24462455
ulint* offsets = rec_get_offsets(
24472456
rec, index, NULL, ULINT_UNDEFINED,
24482457
&heap);
@@ -2661,6 +2670,9 @@ row_upd_clust_rec_by_insert(
26612670
rec_t* rec;
26622671
ulint* offsets = NULL;
26632672

2673+
#ifdef WITH_WSREP
2674+
que_node_t *parent = que_node_get_parent(node);
2675+
#endif /* WITH_WSREP */
26642676
ut_ad(node);
26652677
ut_ad(dict_index_is_clust(index));
26662678

@@ -2748,7 +2760,13 @@ row_upd_clust_rec_by_insert(
27482760
goto err_exit;
27492761
}
27502762
#ifdef WITH_WSREP
2751-
} else if (foreign && wsrep_must_process_fk(node, trx)) {
2763+
} else if (foreign && wsrep_on(trx->mysql_thd) &&
2764+
(!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) ||
2765+
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
2766+
2767+
err = wsrep_row_upd_check_foreign_constraints(
2768+
node, pcur, table, index, offsets, thr, mtr);
2769+
27522770
switch (err) {
27532771
case DB_SUCCESS:
27542772
case DB_NO_REFERENCED_ROW:
@@ -2956,10 +2974,15 @@ row_upd_del_mark_clust_rec(
29562974
dberr_t err;
29572975
rec_t* rec;
29582976
trx_t* trx = thr_get_trx(thr);
2977+
29592978
ut_ad(node);
29602979
ut_ad(dict_index_is_clust(index));
29612980
ut_ad(node->is_delete);
29622981

2982+
#ifdef WITH_WSREP
2983+
que_node_t *parent = que_node_get_parent(node);
2984+
#endif /* WITH_WSREP */
2985+
29632986
pcur = node->pcur;
29642987
btr_cur = btr_pcur_get_btr_cur(pcur);
29652988

@@ -2985,9 +3008,13 @@ row_upd_del_mark_clust_rec(
29853008
err = row_upd_check_references_constraints(
29863009
node, pcur, index->table, index, offsets, thr, mtr);
29873010
#ifdef WITH_WSREP
2988-
} else if (foreign && wsrep_must_process_fk(node, trx)) {
3011+
} else if (trx && wsrep_on(trx->mysql_thd) &&
3012+
(!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) ||
3013+
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
3014+
29893015
err = wsrep_row_upd_check_foreign_constraints(
29903016
node, pcur, index->table, index, offsets, thr, mtr);
3017+
29913018
switch (err) {
29923019
case DB_SUCCESS:
29933020
case DB_NO_REFERENCED_ROW:

0 commit comments

Comments
 (0)