Skip to content

Commit 1d76794

Browse files
committed
Merge 10.6 into 10.11
2 parents 4ca355d + d1ecf5c commit 1d76794

File tree

8 files changed

+119
-170
lines changed

8 files changed

+119
-170
lines changed

storage/innobase/handler/ha_innodb.cc

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,9 +3196,9 @@ static bool innobase_query_caching_table_check_low(
31963196
}
31973197
#endif
31983198

3199-
table->lock_mutex_lock();
3199+
table->lock_shared_lock();
32003200
auto len= UT_LIST_GET_LEN(table->locks);
3201-
table->lock_mutex_unlock();
3201+
table->lock_shared_unlock();
32023202
return len == 0;
32033203
}
32043204

@@ -5542,43 +5542,29 @@ is done when the table first opened.
55425542
@param[in] ib_table InnoDB dict_table_t
55435543
@param[in,out] s_templ InnoDB template structure
55445544
@param[in] add_v new virtual columns added along with
5545-
add index call
5546-
@param[in] locked true if dict_sys.latch is held */
5545+
add index call */
55475546
void
55485547
innobase_build_v_templ(
55495548
const TABLE* table,
55505549
const dict_table_t* ib_table,
55515550
dict_vcol_templ_t* s_templ,
5552-
const dict_add_v_col_t* add_v,
5553-
bool locked)
5551+
const dict_add_v_col_t* add_v)
55545552
{
55555553
ulint ncol = unsigned(ib_table->n_cols) - DATA_N_SYS_COLS;
55565554
ulint n_v_col = ib_table->n_v_cols;
55575555
bool marker[REC_MAX_N_FIELDS];
55585556

55595557
DBUG_ENTER("innobase_build_v_templ");
55605558
ut_ad(ncol < REC_MAX_N_FIELDS);
5559+
ut_ad(ib_table->lock_mutex_is_owner());
55615560

55625561
if (add_v != NULL) {
55635562
n_v_col += add_v->n_v_col;
55645563
}
55655564

55665565
ut_ad(n_v_col > 0);
55675566

5568-
if (!locked) {
5569-
dict_sys.lock(SRW_LOCK_CALL);
5570-
}
5571-
5572-
#if 0
5573-
/* This does not (need to) hold for ctx->new_table in
5574-
alter_rebuild_apply_log() */
5575-
ut_ad(dict_sys.locked());
5576-
#endif
5577-
55785567
if (s_templ->vtempl) {
5579-
if (!locked) {
5580-
dict_sys.unlock();
5581-
}
55825568
DBUG_VOID_RETURN;
55835569
}
55845570

@@ -5682,12 +5668,9 @@ innobase_build_v_templ(
56825668
j++;
56835669
}
56845670

5685-
if (!locked) {
5686-
dict_sys.unlock();
5687-
}
5688-
56895671
s_templ->db_name = table->s->db.str;
56905672
s_templ->tb_name = table->s->table_name.str;
5673+
56915674
DBUG_VOID_RETURN;
56925675
}
56935676

@@ -5965,15 +5948,15 @@ ha_innobase::open(const char* name, int, uint)
59655948
key_used_on_scan = m_primary_key;
59665949

59675950
if (ib_table->n_v_cols) {
5968-
dict_sys.lock(SRW_LOCK_CALL);
5951+
ib_table->lock_mutex_lock();
5952+
59695953
if (ib_table->vc_templ == NULL) {
59705954
ib_table->vc_templ = UT_NEW_NOKEY(dict_vcol_templ_t());
59715955
innobase_build_v_templ(
5972-
table, ib_table, ib_table->vc_templ, NULL,
5973-
true);
5956+
table, ib_table, ib_table->vc_templ);
59745957
}
59755958

5976-
dict_sys.unlock();
5959+
ib_table->lock_mutex_unlock();
59775960
}
59785961

59795962
if (!check_index_consistency(table, ib_table)) {
@@ -14667,7 +14650,7 @@ fsp_get_available_space_in_free_extents(const fil_space_t& space)
1466714650
Returns statistics information of the table to the MySQL interpreter,
1466814651
in various fields of the handle object.
1466914652
@return HA_ERR_* error code or 0 */
14670-
14653+
TRANSACTIONAL_TARGET
1467114654
int
1467214655
ha_innobase::info_low(
1467314656
/*==================*/
@@ -14748,19 +14731,37 @@ ha_innobase::info_low(
1474814731
ulint stat_clustered_index_size;
1474914732
ulint stat_sum_of_other_index_sizes;
1475014733

14751-
ib_table->stats_mutex_lock();
14752-
1475314734
ut_a(ib_table->stat_initialized);
1475414735

14755-
n_rows = ib_table->stat_n_rows;
14736+
#if !defined NO_ELISION && !defined SUX_LOCK_GENERIC
14737+
if (xbegin()) {
14738+
if (ib_table->stats_mutex_is_locked())
14739+
xabort();
14740+
14741+
n_rows = ib_table->stat_n_rows;
14742+
14743+
stat_clustered_index_size
14744+
= ib_table->stat_clustered_index_size;
1475614745

14757-
stat_clustered_index_size
14758-
= ib_table->stat_clustered_index_size;
14746+
stat_sum_of_other_index_sizes
14747+
= ib_table->stat_sum_of_other_index_sizes;
1475914748

14760-
stat_sum_of_other_index_sizes
14761-
= ib_table->stat_sum_of_other_index_sizes;
14749+
xend();
14750+
} else
14751+
#endif
14752+
{
14753+
ib_table->stats_shared_lock();
14754+
14755+
n_rows = ib_table->stat_n_rows;
1476214756

14763-
ib_table->stats_mutex_unlock();
14757+
stat_clustered_index_size
14758+
= ib_table->stat_clustered_index_size;
14759+
14760+
stat_sum_of_other_index_sizes
14761+
= ib_table->stat_sum_of_other_index_sizes;
14762+
14763+
ib_table->stats_shared_unlock();
14764+
}
1476414765

1476514766
/*
1476614767
The MySQL optimizer seems to assume in a left join that n_rows
@@ -14880,9 +14881,9 @@ ha_innobase::info_low(
1488014881
stats.create_time = (ulong) stat_info.ctime;
1488114882
}
1488214883

14883-
ib_table->stats_mutex_lock();
14884+
ib_table->stats_shared_lock();
1488414885
auto _ = make_scope_exit([ib_table]() {
14885-
ib_table->stats_mutex_unlock(); });
14886+
ib_table->stats_shared_unlock(); });
1488614887

1488714888
ut_a(ib_table->stat_initialized);
1488814889

storage/innobase/handler/ha_innodb.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,15 +880,13 @@ innodb_rec_per_key(
880880
@param[in] ib_table InnoDB dict_table_t
881881
@param[in,out] s_templ InnoDB template structure
882882
@param[in] add_v new virtual columns added along with
883-
add index call
884-
@param[in] locked true if innobase_share_mutex is held */
883+
add index call */
885884
void
886885
innobase_build_v_templ(
887886
const TABLE* table,
888887
const dict_table_t* ib_table,
889888
dict_vcol_templ_t* s_templ,
890-
const dict_add_v_col_t* add_v,
891-
bool locked);
889+
const dict_add_v_col_t* add_v = nullptr);
892890

893891
/** callback used by MySQL server layer to initialized
894892
the table virtual columns' template

storage/innobase/handler/handler0alter.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6538,16 +6538,16 @@ prepare_inplace_alter_table_dict(
65386538
acquiring an InnoDB table lock even for online operation,
65396539
to ensure that the rollback of recovered transactions will
65406540
not run concurrently with online ADD INDEX. */
6541-
user_table->lock_mutex_lock();
6541+
user_table->lock_shared_lock();
65426542
for (lock_t *lock = UT_LIST_GET_FIRST(user_table->locks);
65436543
lock;
65446544
lock = UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock)) {
65456545
if (lock->trx->is_recovered) {
6546-
user_table->lock_mutex_unlock();
6546+
user_table->lock_shared_unlock();
65476547
goto acquire_lock;
65486548
}
65496549
}
6550-
user_table->lock_mutex_unlock();
6550+
user_table->lock_shared_unlock();
65516551
}
65526552

65536553
if (fts_exist) {
@@ -8798,10 +8798,11 @@ ha_innobase::inplace_alter_table(
87988798
}
87998799
s_templ = UT_NEW_NOKEY(dict_vcol_templ_t());
88008800

8801+
ctx->new_table->lock_mutex_lock();
88018802
innobase_build_v_templ(
8802-
altered_table, ctx->new_table, s_templ, NULL, false);
8803-
8803+
altered_table, ctx->new_table, s_templ);
88048804
ctx->new_table->vc_templ = s_templ;
8805+
ctx->new_table->lock_mutex_unlock();
88058806
} else if (ctx->num_to_add_vcol > 0 && ctx->num_to_drop_vcol == 0) {
88068807
/* if there is ongoing drop virtual column, then we disallow
88078808
inplace add index on newly added virtual column, so it does
@@ -8816,10 +8817,12 @@ ha_innobase::inplace_alter_table(
88168817
add_v->v_col = ctx->add_vcol;
88178818
add_v->v_col_name = ctx->add_vcol_name;
88188819

8820+
ctx->new_table->lock_mutex_lock();
88198821
innobase_build_v_templ(
8820-
altered_table, ctx->new_table, s_templ, add_v, false);
8822+
altered_table, ctx->new_table, s_templ, add_v);
88218823
old_templ = ctx->new_table->vc_templ;
88228824
ctx->new_table->vc_templ = s_templ;
8825+
ctx->new_table->lock_mutex_unlock();
88238826
}
88248827

88258828
/* Drop virtual column without rebuild will keep dict table
@@ -11096,11 +11099,10 @@ static bool alter_rebuild_apply_log(
1109611099
if (ctx->new_table->n_v_cols > 0) {
1109711100
s_templ = UT_NEW_NOKEY(
1109811101
dict_vcol_templ_t());
11099-
s_templ->vtempl = NULL;
11100-
11101-
innobase_build_v_templ(altered_table, ctx->new_table, s_templ,
11102-
NULL, true);
11102+
ctx->new_table->lock_mutex_lock();
11103+
innobase_build_v_templ(altered_table, ctx->new_table, s_templ);
1110311104
ctx->new_table->vc_templ = s_templ;
11105+
ctx->new_table->lock_mutex_unlock();
1110411106
}
1110511107

1110611108
dberr_t error = row_log_table_apply(

storage/innobase/handler/i_s.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4769,9 +4769,9 @@ i_s_dict_fill_sys_tablestats(THD* thd, dict_table_t *table,
47694769
Field **fields= table_to_fill->field;
47704770

47714771
{
4772-
table->stats_mutex_lock();
4772+
table->stats_shared_lock();
47734773
auto _ = make_scope_exit([table]() {
4774-
table->stats_mutex_unlock(); dict_sys.unlock(); });
4774+
table->stats_shared_unlock(); dict_sys.unlock(); });
47754775

47764776
OK(fields[SYS_TABLESTATS_ID]->store(longlong(table->id), TRUE));
47774777

storage/innobase/include/dict0dict.h

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -700,35 +700,32 @@ bool
700700
dict_table_has_indexed_v_cols(
701701
const dict_table_t* table);
702702

703-
/********************************************************************//**
704-
Gets the approximately estimated number of rows in the table.
703+
TPOOL_SUPPRESS_TSAN
704+
/** Get the estimated number of rows in the table.
705705
@return estimated number of rows */
706-
UNIV_INLINE
707-
ib_uint64_t
708-
dict_table_get_n_rows(
709-
/*==================*/
710-
const dict_table_t* table) /*!< in: table */
711-
MY_ATTRIBUTE((warn_unused_result));
712-
/********************************************************************//**
713-
Increment the number of rows in the table by one.
714-
Notice that this operation is not protected by any latch, the number is
715-
approximate. */
716-
UNIV_INLINE
717-
void
718-
dict_table_n_rows_inc(
719-
/*==================*/
720-
dict_table_t* table) /*!< in/out: table */
721-
MY_ATTRIBUTE((nonnull));
722-
/********************************************************************//**
723-
Decrement the number of rows in the table by one.
724-
Notice that this operation is not protected by any latch, the number is
725-
approximate. */
726-
UNIV_INLINE
727-
void
728-
dict_table_n_rows_dec(
729-
/*==================*/
730-
dict_table_t* table) /*!< in/out: table */
731-
MY_ATTRIBUTE((nonnull));
706+
inline uint64_t dict_table_get_n_rows(const dict_table_t *table)
707+
{
708+
ut_ad(table->stat_initialized);
709+
return table->stat_n_rows;
710+
}
711+
712+
/** Increment the number of rows in the table by one.
713+
Note that this operation is not protected by any latch,
714+
the number is approximate. */
715+
TPOOL_SUPPRESS_TSAN inline void dict_table_n_rows_inc(dict_table_t *table)
716+
{
717+
if (auto n_rows= table->stat_n_rows + 1)
718+
table->stat_n_rows= n_rows;
719+
}
720+
721+
/** Decrement the number of rows in the table by one.
722+
Note that this operation is not protected by any latch,
723+
the number is approximate. */
724+
TPOOL_SUPPRESS_TSAN inline void dict_table_n_rows_dec(dict_table_t *table)
725+
{
726+
if (auto n_rows= table->stat_n_rows)
727+
table->stat_n_rows= n_rows - 1;
728+
}
732729

733730
/** Get nth virtual column
734731
@param[in] table target table

storage/innobase/include/dict0dict.inl

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -306,56 +306,6 @@ dict_table_has_indexed_v_cols(
306306
return(false);
307307
}
308308

309-
/********************************************************************//**
310-
Gets the approximately estimated number of rows in the table.
311-
@return estimated number of rows */
312-
UNIV_INLINE
313-
ib_uint64_t
314-
dict_table_get_n_rows(
315-
/*==================*/
316-
const dict_table_t* table) /*!< in: table */
317-
{
318-
ut_ad(table->stat_initialized);
319-
320-
return(table->stat_n_rows);
321-
}
322-
323-
/********************************************************************//**
324-
Increment the number of rows in the table by one.
325-
Notice that this operation is not protected by any latch, the number is
326-
approximate. */
327-
UNIV_INLINE
328-
void
329-
dict_table_n_rows_inc(
330-
/*==================*/
331-
dict_table_t* table) /*!< in/out: table */
332-
{
333-
if (table->stat_initialized) {
334-
ib_uint64_t n_rows = table->stat_n_rows;
335-
if (n_rows < 0xFFFFFFFFFFFFFFFFULL) {
336-
table->stat_n_rows = n_rows + 1;
337-
}
338-
}
339-
}
340-
341-
/********************************************************************//**
342-
Decrement the number of rows in the table by one.
343-
Notice that this operation is not protected by any latch, the number is
344-
approximate. */
345-
UNIV_INLINE
346-
void
347-
dict_table_n_rows_dec(
348-
/*==================*/
349-
dict_table_t* table) /*!< in/out: table */
350-
{
351-
if (table->stat_initialized) {
352-
ib_uint64_t n_rows = table->stat_n_rows;
353-
if (n_rows > 0) {
354-
table->stat_n_rows = n_rows - 1;
355-
}
356-
}
357-
}
358-
359309
#ifdef UNIV_DEBUG
360310
/********************************************************************//**
361311
Gets the nth column of a table.

0 commit comments

Comments
 (0)