Commit 6a524ca5 authored by sjaakola's avatar sjaakola Committed by Jan Lindström

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
parent efb673fe
......@@ -2434,15 +2434,24 @@ row_upd_sec_index_entry(
row_ins_sec_index_entry() below */
if (!rec_get_deleted_flag(
rec, dict_table_is_comp(index->table))) {
#ifdef WITH_WSREP
que_node_t *parent = que_node_get_parent(node);
#endif /* WITH_WSREP */
err = btr_cur_del_mark_set_sec_rec(
flags, btr_cur, TRUE, thr, &mtr);
if (err != DB_SUCCESS) {
break;
}
#ifdef WITH_WSREP
if (!referenced && foreign
&& wsrep_must_process_fk(node, trx)
&& !wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
if (!referenced && foreign &&
wsrep_on(trx->mysql_thd) &&
!wsrep_thd_is_BF(trx->mysql_thd, FALSE) &&
(!parent || (que_node_get_type(parent) !=
QUE_NODE_UPDATE) ||
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
ulint* offsets = rec_get_offsets(
rec, index, NULL, ULINT_UNDEFINED,
&heap);
......@@ -2661,6 +2670,9 @@ row_upd_clust_rec_by_insert(
rec_t* rec;
ulint* offsets = NULL;
#ifdef WITH_WSREP
que_node_t *parent = que_node_get_parent(node);
#endif /* WITH_WSREP */
ut_ad(node);
ut_ad(dict_index_is_clust(index));
......@@ -2748,7 +2760,13 @@ 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_on(trx->mysql_thd) &&
(!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) ||
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
err = wsrep_row_upd_check_foreign_constraints(
node, pcur, table, index, offsets, thr, mtr);
switch (err) {
case DB_SUCCESS:
case DB_NO_REFERENCED_ROW:
......@@ -2956,10 +2974,15 @@ row_upd_del_mark_clust_rec(
dberr_t err;
rec_t* rec;
trx_t* trx = thr_get_trx(thr);
ut_ad(node);
ut_ad(dict_index_is_clust(index));
ut_ad(node->is_delete);
#ifdef WITH_WSREP
que_node_t *parent = que_node_get_parent(node);
#endif /* WITH_WSREP */
pcur = node->pcur;
btr_cur = btr_pcur_get_btr_cur(pcur);
......@@ -2985,9 +3008,13 @@ 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 (trx && wsrep_on(trx->mysql_thd) &&
(!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) ||
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
err = wsrep_row_upd_check_foreign_constraints(
node, pcur, index->table, index, offsets, thr, mtr);
switch (err) {
case DB_SUCCESS:
case DB_NO_REFERENCED_ROW:
......
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