Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Reduce diff footprint by reverting wsrep_thd_LOCK/UNLOCK
behavior to original. More fine grained locking is not needed
anymore.
  • Loading branch information
temeo committed Apr 14, 2023
1 parent 69067e0 commit f31f824
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
6 changes: 2 additions & 4 deletions sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7608,8 +7608,7 @@ int ha_abort_transaction(THD *bf_thd, THD *victim_thd, my_bool signal)
if (!WSREP(bf_thd) &&
!(bf_thd->variables.wsrep_OSU_method == WSREP_OSU_RSU &&
wsrep_thd_is_toi(bf_thd))) {
mysql_mutex_unlock(&victim_thd->LOCK_thd_data);
mysql_mutex_unlock(&victim_thd->LOCK_thd_kill);
wsrep_thd_UNLOCK(victim_thd);
DBUG_RETURN(0);
}

Expand All @@ -7621,8 +7620,7 @@ int ha_abort_transaction(THD *bf_thd, THD *victim_thd, my_bool signal)
else
{
WSREP_WARN("Cannot abort InnoDB transaction");
mysql_mutex_unlock(&victim_thd->LOCK_thd_data);
mysql_mutex_unlock(&victim_thd->LOCK_thd_kill);
wsrep_thd_UNLOCK(victim_thd);
}

DBUG_RETURN(0);
Expand Down
2 changes: 2 additions & 0 deletions sql/service_wsrep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ extern "C" my_bool wsrep_on(const THD *thd)

extern "C" void wsrep_thd_LOCK(const THD *thd)
{
mysql_mutex_lock(&thd->LOCK_thd_kill);
mysql_mutex_lock(&thd->LOCK_thd_data);
}

extern "C" void wsrep_thd_UNLOCK(const THD *thd)
{
mysql_mutex_unlock(&thd->LOCK_thd_data);
mysql_mutex_unlock(&thd->LOCK_thd_kill);
}

extern "C" void wsrep_thd_kill_LOCK(const THD *thd)
Expand Down
17 changes: 5 additions & 12 deletions sql/wsrep_mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2677,8 +2677,7 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
accessed after any of those calls. Moreover all other if branches
must release those locks.
*/
mysql_mutex_lock(&granted_thd->LOCK_thd_kill);
mysql_mutex_lock(&granted_thd->LOCK_thd_data);
wsrep_thd_LOCK(granted_thd);

if (wsrep_thd_is_toi(granted_thd) ||
wsrep_thd_is_applying(granted_thd))
Expand All @@ -2687,8 +2686,7 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
{
WSREP_DEBUG("BF thread waiting for SR in aborting state");
ticket->wsrep_report(wsrep_debug);
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
mysql_mutex_unlock(&granted_thd->LOCK_thd_kill);
wsrep_thd_UNLOCK(granted_thd);
}
else if (wsrep_thd_is_SR(granted_thd) && !wsrep_thd_is_SR(request_thd))
{
Expand All @@ -2701,8 +2699,7 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
WSREP_MDL_LOG(INFO, "MDL BF-BF conflict", schema, schema_len,
request_thd, granted_thd);
ticket->wsrep_report(true);
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
mysql_mutex_unlock(&granted_thd->LOCK_thd_kill);
wsrep_thd_UNLOCK(granted_thd);
unireg_abort(1);
}
}
Expand All @@ -2711,8 +2708,7 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
{
WSREP_DEBUG("BF thread waiting for FLUSH");
ticket->wsrep_report(wsrep_debug);
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
mysql_mutex_unlock(&granted_thd->LOCK_thd_kill);
wsrep_thd_UNLOCK(granted_thd);
}
else if (request_thd->lex->sql_command == SQLCOM_DROP_TABLE)
{
Expand Down Expand Up @@ -2746,8 +2742,7 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
WSREP_MDL_LOG(INFO, "MDL unknown BF-BF conflict", schema, schema_len,
request_thd, granted_thd);
ticket->wsrep_report(true);
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
mysql_mutex_unlock(&granted_thd->LOCK_thd_kill);
wsrep_thd_UNLOCK(granted_thd);
unireg_abort(1);
}
}
Expand All @@ -2763,7 +2758,6 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
static bool abort_replicated(THD *thd)
{
bool ret_code= false;
wsrep_thd_kill_LOCK(thd);
wsrep_thd_LOCK(thd);
if (thd->wsrep_trx().state() == wsrep::transaction::s_committing)
{
Expand All @@ -2777,7 +2771,6 @@ static bool abort_replicated(THD *thd)
/* wsrep_abort_thd() above releases LOCK_thd_data and LOCK_thd_kill, so
must do it here too. */
wsrep_thd_UNLOCK(thd);
wsrep_thd_kill_UNLOCK(thd);
}
return ret_code;
}
Expand Down
3 changes: 1 addition & 2 deletions sql/wsrep_thd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ void wsrep_abort_thd(THD *bf_thd,
bf_thd->variables.wsrep_OSU_method == WSREP_OSU_RSU,
wsrep_thd_is_toi(bf_thd),
wsrep_thd_is_aborting(victim_thd));
mysql_mutex_unlock(&victim_thd->LOCK_thd_data);
mysql_mutex_unlock(&victim_thd->LOCK_thd_kill);
wsrep_thd_UNLOCK(victim_thd);
}

DBUG_VOID_RETURN;
Expand Down
3 changes: 0 additions & 3 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18835,7 +18835,6 @@ wsrep_innobase_kill_one_trx(
}

DEBUG_SYNC(bf_thd, "wsrep_before_BF_victim_lock");
wsrep_thd_kill_LOCK(thd);
wsrep_thd_LOCK(thd);
DEBUG_SYNC(bf_thd, "wsrep_after_BF_victim_lock");

Expand Down Expand Up @@ -18869,7 +18868,6 @@ wsrep_innobase_kill_one_trx(

wsrep_kill_victim(bf_thd, thd, victim_trx, signal);
wsrep_thd_UNLOCK(thd);
wsrep_thd_kill_UNLOCK(thd);
DBUG_VOID_RETURN;
}

Expand Down Expand Up @@ -18899,7 +18897,6 @@ wsrep_abort_transaction(
trx_t* victim_trx= thd_to_trx(victim_thd);
trx_id_t victim_trx_id= victim_trx ? victim_trx->id : 0;
wsrep_thd_UNLOCK(victim_thd);
wsrep_thd_kill_UNLOCK(victim_thd);
/* After this point must use find_thread_by_id() is victim_thd
is needed again. */

Expand Down

0 comments on commit f31f824

Please sign in to comment.