Commit 16b374b9 authored by Jan Lindström's avatar Jan Lindström

MDEV-13678: DELETE with CASCADE takes a long time when Galera is enabled

Use wsrep_must_process_fk function to check if foreign key
constraint needs to be processed in case of Galera is enabled.
parent 6a524ca5
...@@ -464,15 +464,10 @@ static ...@@ -464,15 +464,10 @@ static
bool bool
wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx) wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx)
{ {
if (que_node_get_type(node->common.parent) != QUE_NODE_UPDATE const upd_node_t* parent = static_cast<const upd_node_t*>(node->common.parent);
|| !wsrep_on(trx->mysql_thd)) {
return false;
}
const upd_cascade_t& nodes = *static_cast<const upd_node_t*>( return (!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) ||
node->common.parent)->cascade_upd_nodes; parent->cascade_upd_nodes->empty());
const upd_cascade_t::const_iterator end = nodes.end();
return std::find(nodes.begin(), end, node) == end;
} }
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
...@@ -2435,10 +2430,6 @@ row_upd_sec_index_entry( ...@@ -2435,10 +2430,6 @@ row_upd_sec_index_entry(
if (!rec_get_deleted_flag( if (!rec_get_deleted_flag(
rec, dict_table_is_comp(index->table))) { 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( err = btr_cur_del_mark_set_sec_rec(
flags, btr_cur, TRUE, thr, &mtr); flags, btr_cur, TRUE, thr, &mtr);
...@@ -2449,9 +2440,7 @@ row_upd_sec_index_entry( ...@@ -2449,9 +2440,7 @@ row_upd_sec_index_entry(
if (!referenced && foreign && if (!referenced && foreign &&
wsrep_on(trx->mysql_thd) && wsrep_on(trx->mysql_thd) &&
!wsrep_thd_is_BF(trx->mysql_thd, FALSE) && !wsrep_thd_is_BF(trx->mysql_thd, FALSE) &&
(!parent || (que_node_get_type(parent) != wsrep_must_process_fk(node, trx)) {
QUE_NODE_UPDATE) ||
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
ulint* offsets = rec_get_offsets( ulint* offsets = rec_get_offsets(
rec, index, NULL, ULINT_UNDEFINED, rec, index, NULL, ULINT_UNDEFINED,
&heap); &heap);
...@@ -2670,9 +2659,6 @@ row_upd_clust_rec_by_insert( ...@@ -2670,9 +2659,6 @@ row_upd_clust_rec_by_insert(
rec_t* rec; rec_t* rec;
ulint* offsets = NULL; ulint* offsets = NULL;
#ifdef WITH_WSREP
que_node_t *parent = que_node_get_parent(node);
#endif /* WITH_WSREP */
ut_ad(node); ut_ad(node);
ut_ad(dict_index_is_clust(index)); ut_ad(dict_index_is_clust(index));
...@@ -2761,8 +2747,7 @@ row_upd_clust_rec_by_insert( ...@@ -2761,8 +2747,7 @@ row_upd_clust_rec_by_insert(
} }
#ifdef WITH_WSREP #ifdef WITH_WSREP
} else if (foreign && wsrep_on(trx->mysql_thd) && } else if (foreign && wsrep_on(trx->mysql_thd) &&
(!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) || wsrep_must_process_fk(node, trx)) {
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
err = wsrep_row_upd_check_foreign_constraints( err = wsrep_row_upd_check_foreign_constraints(
node, pcur, table, index, offsets, thr, mtr); node, pcur, table, index, offsets, thr, mtr);
...@@ -2979,10 +2964,6 @@ row_upd_del_mark_clust_rec( ...@@ -2979,10 +2964,6 @@ row_upd_del_mark_clust_rec(
ut_ad(dict_index_is_clust(index)); ut_ad(dict_index_is_clust(index));
ut_ad(node->is_delete); ut_ad(node->is_delete);
#ifdef WITH_WSREP
que_node_t *parent = que_node_get_parent(node);
#endif /* WITH_WSREP */
pcur = node->pcur; pcur = node->pcur;
btr_cur = btr_pcur_get_btr_cur(pcur); btr_cur = btr_pcur_get_btr_cur(pcur);
...@@ -3009,8 +2990,7 @@ row_upd_del_mark_clust_rec( ...@@ -3009,8 +2990,7 @@ row_upd_del_mark_clust_rec(
node, pcur, index->table, index, offsets, thr, mtr); node, pcur, index->table, index, offsets, thr, mtr);
#ifdef WITH_WSREP #ifdef WITH_WSREP
} else if (trx && wsrep_on(trx->mysql_thd) && } else if (trx && wsrep_on(trx->mysql_thd) &&
(!parent || (que_node_get_type(parent) != QUE_NODE_UPDATE) || wsrep_must_process_fk(node, trx)) {
((upd_node_t*)parent)->cascade_upd_nodes->empty())) {
err = wsrep_row_upd_check_foreign_constraints( err = wsrep_row_upd_check_foreign_constraints(
node, pcur, index->table, index, offsets, thr, mtr); node, pcur, index->table, index, offsets, thr, mtr);
......
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