Skip to content

Commit

Permalink
MDEV-13678: DELETE with CASCADE takes a long time when Galera is enabled
Browse files Browse the repository at this point in the history
Use wsrep_must_process_fk function to check if foreign key
constraint needs to be processed in case of Galera is enabled.
  • Loading branch information
Jan Lindström committed Sep 18, 2017
1 parent 6a524ca commit 16b374b
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions storage/innobase/row/row0upd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,10 @@ static
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->mysql_thd)) {
return false;
}
const upd_node_t* parent = static_cast<const upd_node_t*>(node->common.parent);

const upd_cascade_t& nodes = *static_cast<const upd_node_t*>(
node->common.parent)->cascade_upd_nodes;
const upd_cascade_t::const_iterator end = nodes.end();
return std::find(nodes.begin(), end, node) == end;
return (!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) ||
parent->cascade_upd_nodes->empty());
}
#endif /* WITH_WSREP */

Expand Down Expand Up @@ -2435,10 +2430,6 @@ row_upd_sec_index_entry(
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);

Expand All @@ -2449,9 +2440,7 @@ row_upd_sec_index_entry(
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())) {
wsrep_must_process_fk(node, trx)) {
ulint* offsets = rec_get_offsets(
rec, index, NULL, ULINT_UNDEFINED,
&heap);
Expand Down Expand Up @@ -2670,9 +2659,6 @@ 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));

Expand Down Expand Up @@ -2761,8 +2747,7 @@ row_upd_clust_rec_by_insert(
}
#ifdef WITH_WSREP
} 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())) {
wsrep_must_process_fk(node, trx)) {

err = wsrep_row_upd_check_foreign_constraints(
node, pcur, table, index, offsets, thr, mtr);
Expand Down Expand Up @@ -2979,10 +2964,6 @@ row_upd_del_mark_clust_rec(
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);

Expand All @@ -3009,8 +2990,7 @@ row_upd_del_mark_clust_rec(
node, pcur, index->table, index, offsets, thr, mtr);
#ifdef WITH_WSREP
} 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())) {
wsrep_must_process_fk(node, trx)) {

err = wsrep_row_upd_check_foreign_constraints(
node, pcur, index->table, index, offsets, thr, mtr);
Expand Down

0 comments on commit 16b374b

Please sign in to comment.