Commit adb640e2 authored by Eugene Kosov's avatar Eugene Kosov

MDEV-17441 InnoDB transition to C++11 atomics

zip_pad_info_t::mutex_created: remove along with corresponding stuff

zip_pad_info_t::mutex: make member value instead of a pointer
parent 52a50977
...@@ -568,33 +568,6 @@ dict_table_get_nth_v_col_mysql( ...@@ -568,33 +568,6 @@ dict_table_get_nth_v_col_mysql(
return(dict_table_get_nth_v_col(table, i)); return(dict_table_get_nth_v_col(table, i));
} }
/** Allocate and init the zip_pad_mutex of a given index.
This function must not be called concurrently on the same index object.
@param[in,out] index_void index whose zip_pad_mutex to create */
static
void
dict_index_zip_pad_alloc(
void* index_void)
{
dict_index_t* index = static_cast<dict_index_t*>(index_void);
index->zip_pad.mutex = UT_NEW_NOKEY(SysMutex());
ut_a(index->zip_pad.mutex != NULL);
mutex_create(LATCH_ID_ZIP_PAD_MUTEX, index->zip_pad.mutex);
}
/** Acquire the zip_pad_mutex latch.
@param[in,out] index the index whose zip_pad_mutex to acquire.*/
static
void
dict_index_zip_pad_lock(
dict_index_t* index)
{
os_once::do_or_wait_for_done(
&index->zip_pad.mutex_created,
dict_index_zip_pad_alloc, index);
mutex_enter(index->zip_pad.mutex);
}
/** Get all the FTS indexes on a table. /** Get all the FTS indexes on a table.
@param[in] table table @param[in] table table
...@@ -6453,10 +6426,10 @@ dict_index_zip_success( ...@@ -6453,10 +6426,10 @@ dict_index_zip_success(
return; return;
} }
dict_index_zip_pad_lock(index); mutex_enter(&index->zip_pad.mutex);
++index->zip_pad.success; ++index->zip_pad.success;
dict_index_zip_pad_update(&index->zip_pad, zip_threshold); dict_index_zip_pad_update(&index->zip_pad, zip_threshold);
dict_index_zip_pad_unlock(index); mutex_exit(&index->zip_pad.mutex);
} }
/*********************************************************************//** /*********************************************************************//**
...@@ -6473,10 +6446,10 @@ dict_index_zip_failure( ...@@ -6473,10 +6446,10 @@ dict_index_zip_failure(
return; return;
} }
dict_index_zip_pad_lock(index); mutex_enter(&index->zip_pad.mutex);
++index->zip_pad.failure; ++index->zip_pad.failure;
dict_index_zip_pad_update(&index->zip_pad, zip_threshold); dict_index_zip_pad_update(&index->zip_pad, zip_threshold);
dict_index_zip_pad_unlock(index); mutex_exit(&index->zip_pad.mutex);
} }
/*********************************************************************//** /*********************************************************************//**
......
...@@ -740,7 +740,7 @@ dict_mem_index_create( ...@@ -740,7 +740,7 @@ dict_mem_index_create(
dict_mem_fill_index_struct(index, heap, index_name, type, n_fields); dict_mem_fill_index_struct(index, heap, index_name, type, n_fields);
dict_index_zip_pad_mutex_create_lazy(index); mutex_create(LATCH_ID_ZIP_PAD_MUTEX, &index->zip_pad.mutex);
if (type & DICT_SPATIAL) { if (type & DICT_SPATIAL) {
mutex_create(LATCH_ID_RTR_SSN_MUTEX, &index->rtr_ssn.mutex); mutex_create(LATCH_ID_RTR_SSN_MUTEX, &index->rtr_ssn.mutex);
...@@ -1050,7 +1050,7 @@ dict_mem_index_free( ...@@ -1050,7 +1050,7 @@ dict_mem_index_free(
ut_ad(index); ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
dict_index_zip_pad_mutex_destroy(index); mutex_free(&index->zip_pad.mutex);
if (dict_index_is_spatial(index)) { if (dict_index_is_spatial(index)) {
for (auto& rtr_info : index->rtr_track->rtr_active) { for (auto& rtr_info : index->rtr_track->rtr_active) {
......
...@@ -883,7 +883,7 @@ extern ulong zip_pad_max; ...@@ -883,7 +883,7 @@ extern ulong zip_pad_max;
an uncompressed page should be left as padding to avoid compression an uncompressed page should be left as padding to avoid compression
failures. This estimate is based on a self-adapting heuristic. */ failures. This estimate is based on a self-adapting heuristic. */
struct zip_pad_info_t { struct zip_pad_info_t {
SysMutex* mutex; /*!< mutex protecting the info */ SysMutex mutex; /*!< mutex protecting the info */
Atomic_counter<ulint> Atomic_counter<ulint>
pad; /*!< number of bytes used as pad */ pad; /*!< number of bytes used as pad */
ulint success;/*!< successful compression ops during ulint success;/*!< successful compression ops during
...@@ -892,9 +892,6 @@ struct zip_pad_info_t { ...@@ -892,9 +892,6 @@ struct zip_pad_info_t {
current round */ current round */
ulint n_rounds;/*!< number of currently successful ulint n_rounds;/*!< number of currently successful
rounds */ rounds */
volatile os_once::state_t
mutex_created;
/*!< Creation state of mutex member */
}; };
/** Number of samples of data size kept when page compression fails for /** Number of samples of data size kept when page compression fails for
...@@ -2286,45 +2283,6 @@ struct dict_foreign_add_to_referenced_table { ...@@ -2286,45 +2283,6 @@ struct dict_foreign_add_to_referenced_table {
} }
}; };
/** Request a lazy creation of dict_index_t::zip_pad::mutex.
This function is only called from either single threaded environment
or from a thread that has not shared the table object with other threads.
@param[in,out] index index whose zip_pad mutex is to be created */
inline
void
dict_index_zip_pad_mutex_create_lazy(
dict_index_t* index)
{
index->zip_pad.mutex = NULL;
index->zip_pad.mutex_created = os_once::NEVER_DONE;
}
/** Destroy the zip_pad_mutex of the given index.
This function is only called from either single threaded environment
or from a thread that has not shared the table object with other threads.
@param[in,out] table table whose stats latch to destroy */
inline
void
dict_index_zip_pad_mutex_destroy(
dict_index_t* index)
{
if (index->zip_pad.mutex_created == os_once::DONE
&& index->zip_pad.mutex != NULL) {
mutex_free(index->zip_pad.mutex);
UT_DELETE(index->zip_pad.mutex);
}
}
/** Release the zip_pad_mutex of a given index.
@param[in,out] index index whose zip_pad_mutex is to be released */
inline
void
dict_index_zip_pad_unlock(
dict_index_t* index)
{
mutex_exit(index->zip_pad.mutex);
}
/** Check whether the col is used in spatial index or regular index. /** Check whether the col is used in spatial index or regular index.
@param[in] col column to check @param[in] col column to check
@return spatial status */ @return spatial status */
......
...@@ -1602,7 +1602,7 @@ page_zip_fields_free( ...@@ -1602,7 +1602,7 @@ page_zip_fields_free(
{ {
if (index) { if (index) {
dict_table_t* table = index->table; dict_table_t* table = index->table;
dict_index_zip_pad_mutex_destroy(index); mutex_free(&index->zip_pad.mutex);
mem_heap_free(index->heap); mem_heap_free(index->heap);
dict_mem_table_free(table); dict_mem_table_free(table);
......
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