summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-01-12 17:03:45 +0100
committerSergei Golubchik <serg@mariadb.org>2015-01-13 10:15:21 +0100
commite695db0f2d97cbba2832e0f3dc25af5add1f16ac (patch)
tree7c03822a83a0b16ae513b22659b9ac43068b0411 /sql
parent1f0ad6c6b3421a815ea6373c66aaf693852342cf (diff)
downloadmariadb-git-e695db0f2d97cbba2832e0f3dc25af5add1f16ac.tar.gz
MDEV-7437 remove suport for "atomics" with rwlocks
Diffstat (limited to 'sql')
-rw-r--r--sql/event_scheduler.cc2
-rw-r--r--sql/log.cc1
-rw-r--r--sql/mysqld.cc23
-rw-r--r--sql/mysqld.h44
-rw-r--r--sql/rpl_parallel.cc5
-rw-r--r--sql/rpl_rli.cc2
-rw-r--r--sql/rpl_rli.h2
-rw-r--r--sql/slave.cc3
-rw-r--r--sql/sql_base.cc4
-rw-r--r--sql/sql_insert.cc4
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/table_cache.cc22
12 files changed, 25 insertions, 89 deletions
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index f2b3a77f414..89a92e95a91 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -134,7 +134,7 @@ post_init_event_thread(THD *thd)
return TRUE;
}
- thread_safe_increment32(&thread_count, &thread_count_lock);
+ thread_safe_increment32(&thread_count);
mysql_mutex_lock(&LOCK_thread_count);
threads.append(thd);
mysql_mutex_unlock(&LOCK_thread_count);
diff --git a/sql/log.cc b/sql/log.cc
index bae3a968f6e..e226b593566 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -4187,7 +4187,6 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
included= 1;
to_purge_if_included= my_strdup(ir->name, MYF(0));
}
- my_atomic_rwlock_destroy(&ir->inuse_relaylog_atomic_lock);
my_free(ir);
ir= next;
}
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index ed1e67d5883..ea53e475192 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -507,11 +507,6 @@ ulonglong query_cache_size=0;
ulong query_cache_limit=0;
ulong executed_events=0;
query_id_t global_query_id;
-my_atomic_rwlock_t global_query_id_lock;
-my_atomic_rwlock_t thread_running_lock;
-my_atomic_rwlock_t thread_count_lock;
-my_atomic_rwlock_t statistics_lock;
-my_atomic_rwlock_t slave_executed_entries_lock;
ulong aborted_threads, aborted_connects;
ulong delayed_insert_timeout, delayed_insert_limit, delayed_queue_size;
ulong delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use;
@@ -2152,11 +2147,6 @@ void clean_up(bool print_message)
/* Tell main we are ready */
logger.cleanup_end();
sys_var_end();
- my_atomic_rwlock_destroy(&global_query_id_lock);
- my_atomic_rwlock_destroy(&thread_running_lock);
- my_atomic_rwlock_destroy(&thread_count_lock);
- my_atomic_rwlock_destroy(&statistics_lock);
- my_atomic_rwlock_destroy(&slave_executed_entries_lock);
free_charsets();
mysql_mutex_lock(&LOCK_thread_count);
DBUG_PRINT("quit", ("got thread count lock"));
@@ -2829,7 +2819,7 @@ void delete_running_thd(THD *thd)
delete thd;
dec_thread_running();
- thread_safe_decrement32(&thread_count, &thread_count_lock);
+ thread_safe_decrement32(&thread_count);
if (!thread_count)
{
mysql_mutex_lock(&LOCK_thread_count);
@@ -2871,7 +2861,7 @@ void unlink_thd(THD *thd)
mysql_mutex_unlock(&LOCK_thread_count);
delete thd;
- thread_safe_decrement32(&thread_count, &thread_count_lock);
+ thread_safe_decrement32(&thread_count);
DBUG_VOID_RETURN;
}
@@ -6221,7 +6211,7 @@ void create_thread_to_handle_connection(THD *thd)
thd->unlink();
mysql_mutex_unlock(&LOCK_thread_count);
delete thd;
- thread_safe_decrement32(&thread_count, &thread_count_lock);
+ thread_safe_decrement32(&thread_count);
return;
/* purecov: end */
}
@@ -6275,7 +6265,7 @@ static void create_new_thread(THD *thd)
mysql_mutex_unlock(&LOCK_connection_count);
- thread_safe_increment32(&thread_count, &thread_count_lock);
+ thread_safe_increment32(&thread_count);
/* Start a new thread to handle connection. */
mysql_mutex_lock(&LOCK_thread_count);
@@ -8477,11 +8467,6 @@ static int mysql_init_variables(void)
denied_connections= 0;
executed_events= 0;
global_query_id= thread_id= 1L;
- my_atomic_rwlock_init(&global_query_id_lock);
- my_atomic_rwlock_init(&thread_running_lock);
- my_atomic_rwlock_init(&thread_count_lock);
- my_atomic_rwlock_init(&statistics_lock);
- my_atomic_rwlock_init(&slave_executed_entries_lock);
strmov(server_version, MYSQL_SERVER_VERSION);
threads.empty();
thread_cache.empty();
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 6bddfc665fa..8bd2759b5d0 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -20,7 +20,7 @@
#include "sql_bitmap.h" /* Bitmap */
#include "my_decimal.h" /* my_decimal */
#include "mysql_com.h" /* SERVER_VERSION_LENGTH */
-#include "my_atomic.h" /* my_atomic_rwlock_t */
+#include "my_atomic.h"
#include "mysql/psi/mysql_file.h" /* MYSQL_FILE */
#include "sql_list.h" /* I_List */
#include "sql_cmd.h"
@@ -538,8 +538,6 @@ extern mysql_cond_t COND_manager;
extern mysql_cond_t COND_slave_init;
extern int32 thread_running;
extern int32 thread_count;
-extern my_atomic_rwlock_t thread_running_lock, thread_count_lock;
-extern my_atomic_rwlock_t slave_executed_entries_lock;
extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher,
*opt_ssl_key, *opt_ssl_crl, *opt_ssl_crlpath;
@@ -627,28 +625,18 @@ enum enum_query_type
/* query_id */
typedef int64 query_id_t;
extern query_id_t global_query_id;
-extern my_atomic_rwlock_t global_query_id_lock;
-extern my_atomic_rwlock_t statistics_lock;
void unireg_end(void) __attribute__((noreturn));
/* increment query_id and return it. */
inline __attribute__((warn_unused_result)) query_id_t next_query_id()
{
- query_id_t id;
- my_atomic_rwlock_wrlock(&global_query_id_lock);
- id= my_atomic_add64_explicit(&global_query_id, 1, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_wrunlock(&global_query_id_lock);
- return (id);
+ return my_atomic_add64_explicit(&global_query_id, 1, MY_MEMORY_ORDER_RELAXED);
}
inline query_id_t get_query_id()
{
- query_id_t id;
- my_atomic_rwlock_wrlock(&global_query_id_lock);
- id= my_atomic_load64_explicit(&global_query_id, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_wrunlock(&global_query_id_lock);
- return id;
+ return my_atomic_load64_explicit(&global_query_id, MY_MEMORY_ORDER_RELAXED);
}
@@ -669,44 +657,34 @@ inline void table_case_convert(char * name, uint length)
name, length, name, length);
}
-inline void thread_safe_increment32(int32 *value, my_atomic_rwlock_t *lock)
+inline void thread_safe_increment32(int32 *value)
{
- my_atomic_rwlock_wrlock(lock);
(void) my_atomic_add32_explicit(value, 1, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_wrunlock(lock);
}
-inline void thread_safe_decrement32(int32 *value, my_atomic_rwlock_t *lock)
+inline void thread_safe_decrement32(int32 *value)
{
- my_atomic_rwlock_wrlock(lock);
(void) my_atomic_add32_explicit(value, -1, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_wrunlock(lock);
}
-inline void thread_safe_increment64(int64 *value, my_atomic_rwlock_t *lock)
+inline void thread_safe_increment64(int64 *value)
{
- my_atomic_rwlock_wrlock(lock);
(void) my_atomic_add64_explicit(value, 1, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_wrunlock(lock);
}
-inline void thread_safe_decrement64(int64 *value, my_atomic_rwlock_t *lock)
+inline void thread_safe_decrement64(int64 *value)
{
- my_atomic_rwlock_wrlock(lock);
(void) my_atomic_add64_explicit(value, -1, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_wrunlock(lock);
}
-inline void
-inc_thread_running()
+inline void inc_thread_running()
{
- thread_safe_increment32(&thread_running, &thread_running_lock);
+ thread_safe_increment32(&thread_running);
}
-inline void
-dec_thread_running()
+inline void dec_thread_running()
{
- thread_safe_decrement32(&thread_running, &thread_running_lock);
+ thread_safe_decrement32(&thread_running);
}
void set_server_version(void);
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index 89d9289d166..62842810797 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -47,8 +47,7 @@ rpt_handle_event(rpl_parallel_thread::queued_event *qev,
/* Mutex will be released in apply_event_and_update_pos(). */
err= apply_event_and_update_pos(ev, thd, rgi, rpt);
- thread_safe_increment64(&rli->executed_entries,
- &slave_executed_entries_lock);
+ thread_safe_increment64(&rli->executed_entries);
/* ToDo: error handling. */
return err;
}
@@ -1193,9 +1192,7 @@ rpl_parallel_thread::inuse_relaylog_refcount_update()
inuse_relaylog *ir= accumulated_ir_last;
if (ir)
{
- my_atomic_rwlock_wrlock(&ir->rli->inuse_relaylog_atomic_lock);
my_atomic_add64(&ir->dequeued_count, accumulated_ir_count);
- my_atomic_rwlock_wrunlock(&ir->rli->inuse_relaylog_atomic_lock);
accumulated_ir_count= 0;
accumulated_ir_last= NULL;
}
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 6822388e206..ad33541b5ab 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -108,7 +108,6 @@ Relay_log_info::~Relay_log_info()
{
DBUG_ASSERT(cur->queued_count == cur->dequeued_count);
inuse_relaylog *next= cur->next;
- my_atomic_rwlock_destroy(&cur->inuse_relaylog_atomic_lock);
my_free(cur);
cur= next;
}
@@ -1401,7 +1400,6 @@ Relay_log_info::alloc_inuse_relaylog(const char *name)
last_inuse_relaylog->next= ir;
}
last_inuse_relaylog= ir;
- my_atomic_rwlock_init(&ir->inuse_relaylog_atomic_lock);
return 0;
}
diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h
index ddf6c2ccc71..d8a30e75724 100644
--- a/sql/rpl_rli.h
+++ b/sql/rpl_rli.h
@@ -504,8 +504,6 @@ struct inuse_relaylog {
/* Set when all events have been read from a relaylog. */
bool completed;
char name[FN_REFLEN];
- /* Lock used to protect inuse_relaylog::dequeued_count */
- my_atomic_rwlock_t inuse_relaylog_atomic_lock;
};
diff --git a/sql/slave.cc b/sql/slave.cc
index e59f59f8a22..f193659b170 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3652,8 +3652,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
serial_rgi->trans_retries));
}
}
- thread_safe_increment64(&rli->executed_entries,
- &slave_executed_entries_lock);
+ thread_safe_increment64(&rli->executed_entries);
DBUG_RETURN(exec_res);
}
mysql_mutex_unlock(&rli->data_lock);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index ca6e6f63594..70529b207b1 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1732,7 +1732,7 @@ void close_temporary_table(THD *thd, TABLE *table,
{
/* natural invariant of temporary_tables */
DBUG_ASSERT(slave_open_temp_tables || !thd->temporary_tables);
- thread_safe_decrement32(&slave_open_temp_tables, &thread_running_lock);
+ thread_safe_decrement32(&slave_open_temp_tables);
table->in_use= 0; // No statistics
}
thd->unlock_temporary_tables();
@@ -5721,7 +5721,7 @@ TABLE *open_table_uncached(THD *thd, handlerton *hton,
thd->temporary_tables->prev= 0;
if (thd->rgi_slave)
{
- thread_safe_increment32(&slave_open_temp_tables, &thread_running_lock);
+ thread_safe_increment32(&slave_open_temp_tables);
}
thd->unlock_temporary_tables();
}
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 050e28f98b4..2680019e3e2 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2061,7 +2061,7 @@ public:
thd.security_ctx->user= thd.security_ctx->host=0;
delayed_insert_threads--;
mysql_mutex_unlock(&LOCK_thread_count);
- thread_safe_decrement32(&thread_count, &thread_count_lock);
+ thread_safe_decrement32(&thread_count);
mysql_cond_broadcast(&COND_thread_count); /* Tell main we are ready */
}
@@ -2197,7 +2197,7 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
if (!(di= new Delayed_insert()))
goto end_create;
- thread_safe_increment32(&thread_count, &thread_count_lock);
+ thread_safe_increment32(&thread_count);
/*
Annotating delayed inserts is not supported.
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index e9553993794..e4e5f0adfd5 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -840,7 +840,7 @@ end:
delete thd;
#ifndef EMBEDDED_LIBRARY
- thread_safe_decrement32(&thread_count, &thread_count_lock);
+ thread_safe_decrement32(&thread_count);
in_bootstrap= FALSE;
mysql_mutex_lock(&LOCK_thread_count);
diff --git a/sql/table_cache.cc b/sql/table_cache.cc
index f12c031f91a..9a75cafb30e 100644
--- a/sql/table_cache.cc
+++ b/sql/table_cache.cc
@@ -82,7 +82,6 @@ static int32 tc_count; /**< Number of TABLE objects in table cache. */
*/
static mysql_mutex_t LOCK_unused_shares;
-my_atomic_rwlock_t LOCK_tdc_atomics; /**< Protects tdc_version. */
#ifdef HAVE_PSI_INTERFACE
PSI_mutex_key key_LOCK_unused_shares, key_TABLE_SHARE_LOCK_table_share;
@@ -136,11 +135,7 @@ static int fix_thd_pins(THD *thd)
uint tc_records(void)
{
- uint count;
- my_atomic_rwlock_rdlock(&LOCK_tdc_atomics);
- count= my_atomic_load32_explicit(&tc_count, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_rdunlock(&LOCK_tdc_atomics);
- return count;
+ return my_atomic_load32_explicit(&tc_count, MY_MEMORY_ORDER_RELAXED);
}
@@ -153,9 +148,7 @@ uint tc_records(void)
static void tc_remove_table(TABLE *table)
{
- my_atomic_rwlock_wrlock(&LOCK_tdc_atomics);
my_atomic_add32_explicit(&tc_count, -1, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_wrunlock(&LOCK_tdc_atomics);
table->s->tdc->all_tables.remove(table);
}
@@ -262,10 +255,8 @@ void tc_add_table(THD *thd, TABLE *table)
mysql_mutex_unlock(&table->s->tdc->LOCK_table_share);
/* If we have too many TABLE instances around, try to get rid of them */
- my_atomic_rwlock_wrlock(&LOCK_tdc_atomics);
need_purge= my_atomic_add32_explicit(&tc_count, 1, MY_MEMORY_ORDER_RELAXED) >=
(int32) tc_size;
- my_atomic_rwlock_wrunlock(&LOCK_tdc_atomics);
if (need_purge)
{
@@ -435,7 +426,6 @@ void tdc_init(void)
tdc_inited= true;
mysql_mutex_init(key_LOCK_unused_shares, &LOCK_unused_shares,
MY_MUTEX_INIT_FAST);
- my_atomic_rwlock_init(&LOCK_tdc_atomics);
tdc_version= 1L; /* Increments on each reload */
lf_hash_init(&tdc_hash, sizeof(TDC_element), LF_HASH_UNIQUE, 0, 0,
(my_hash_get_key) TDC_element::key,
@@ -484,7 +474,6 @@ void tdc_deinit(void)
{
tdc_inited= false;
lf_hash_destroy(&tdc_hash);
- my_atomic_rwlock_destroy(&LOCK_tdc_atomics);
mysql_mutex_destroy(&LOCK_unused_shares);
}
DBUG_VOID_RETURN;
@@ -1000,18 +989,13 @@ int tdc_wait_for_old_version(THD *thd, const char *db, const char *table_name,
ulong tdc_refresh_version(void)
{
- my_atomic_rwlock_rdlock(&LOCK_tdc_atomics);
- ulong v= my_atomic_load64_explicit(&tdc_version, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_rdunlock(&LOCK_tdc_atomics);
- return v;
+ return my_atomic_load64_explicit(&tdc_version, MY_MEMORY_ORDER_RELAXED);
}
ulong tdc_increment_refresh_version(void)
{
- my_atomic_rwlock_wrlock(&LOCK_tdc_atomics);
ulong v= my_atomic_add64_explicit(&tdc_version, 1, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_wrunlock(&LOCK_tdc_atomics);
DBUG_PRINT("tcache", ("incremented global refresh_version to: %lu", v));
return v + 1;
}
@@ -1154,9 +1138,7 @@ void tdc_assign_new_table_id(TABLE_SHARE *share)
*/
do
{
- my_atomic_rwlock_wrlock(&LOCK_tdc_atomics);
tid= my_atomic_add64_explicit(&last_table_id, 1, MY_MEMORY_ORDER_RELAXED);
- my_atomic_rwlock_wrunlock(&LOCK_tdc_atomics);
} while (unlikely(tid == ~0UL));
share->table_map_id= tid;