MDEV-32176 Contention in ha_innobase::info_low()

During a Sysbench oltp_point_select workload with 1 table and 400
concurrent connections, a bottleneck on dict_table_t::lock_mutex was
observed in ha_innobase::info_low().

dict_table_t::lock_latch: Replaces lock_mutex.

In ha_innobase::info_low() and several other places, we will acquire
a shared dict_table_t::lock_latch or we may elide the latch if
hardware memory transactions are available.

innobase_build_v_templ(): Remove the parameter "bool locked", and
require the caller to hold exclusive dict_table_t::lock_latch
(instead of holding an exclusive dict_sys.latch).

Tested by: Vladislav Vaintroub
Reviewed by: Vladislav Vaintroub
This commit is contained in:
Marko Mäkelä 2024-06-28 15:57:07 +03:00
commit d1ecf5cc5f
8 changed files with 119 additions and 170 deletions

View file

@ -6521,16 +6521,16 @@ acquire_lock:
acquiring an InnoDB table lock even for online operation,
to ensure that the rollback of recovered transactions will
not run concurrently with online ADD INDEX. */
user_table->lock_mutex_lock();
user_table->lock_shared_lock();
for (lock_t *lock = UT_LIST_GET_FIRST(user_table->locks);
lock;
lock = UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock)) {
if (lock->trx->is_recovered) {
user_table->lock_mutex_unlock();
user_table->lock_shared_unlock();
goto acquire_lock;
}
}
user_table->lock_mutex_unlock();
user_table->lock_shared_unlock();
}
if (fts_exist) {
@ -8781,10 +8781,11 @@ ok_exit:
}
s_templ = UT_NEW_NOKEY(dict_vcol_templ_t());
ctx->new_table->lock_mutex_lock();
innobase_build_v_templ(
altered_table, ctx->new_table, s_templ, NULL, false);
altered_table, ctx->new_table, s_templ);
ctx->new_table->vc_templ = s_templ;
ctx->new_table->lock_mutex_unlock();
} else if (ctx->num_to_add_vcol > 0 && ctx->num_to_drop_vcol == 0) {
/* if there is ongoing drop virtual column, then we disallow
inplace add index on newly added virtual column, so it does
@ -8799,10 +8800,12 @@ ok_exit:
add_v->v_col = ctx->add_vcol;
add_v->v_col_name = ctx->add_vcol_name;
ctx->new_table->lock_mutex_lock();
innobase_build_v_templ(
altered_table, ctx->new_table, s_templ, add_v, false);
altered_table, ctx->new_table, s_templ, add_v);
old_templ = ctx->new_table->vc_templ;
ctx->new_table->vc_templ = s_templ;
ctx->new_table->lock_mutex_unlock();
}
/* Drop virtual column without rebuild will keep dict table
@ -11075,11 +11078,10 @@ static bool alter_rebuild_apply_log(
if (ctx->new_table->n_v_cols > 0) {
s_templ = UT_NEW_NOKEY(
dict_vcol_templ_t());
s_templ->vtempl = NULL;
innobase_build_v_templ(altered_table, ctx->new_table, s_templ,
NULL, true);
ctx->new_table->lock_mutex_lock();
innobase_build_v_templ(altered_table, ctx->new_table, s_templ);
ctx->new_table->vc_templ = s_templ;
ctx->new_table->lock_mutex_unlock();
}
dberr_t error = row_log_table_apply(