diff options
author | Lixun Peng <lixun@mariadb.org> | 2016-12-29 15:31:12 +0800 |
---|---|---|
committer | Lixun Peng <lixun@mariadb.org> | 2016-12-29 15:31:12 +0800 |
commit | a87900843c41fceeeb8d65db21cd161bcaa8929b (patch) | |
tree | c5945781f064bd4ef5935ef1b2fa21ade127fe1c | |
parent | 37f294fec20e5b27532c156cd6956d65d804a5df (diff) | |
download | mariadb-git-bb-10.0-MDEV-10644.tar.gz |
MDEV-10644 One of parallel replication threads remains activebb-10.0-MDEV-10644
after STOP SLAVE SQL_THREAD completes
Using mysql_mutex_trylock() instead of mysql_mutex_lock() for LOCK_active_mi in
function show_slave_received_heartbeats() and show_heartbeat_period().
If can't aquire LOCK_active_mi lock after 1 seconds, then give up and just show
SHOW_UNDEF.
This is a temporary fix. If want to solve related problems completely, should
change the LOCK_active_mi to mysql_rwlock_t.
-rw-r--r-- | sql/mysqld.cc | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index fda4fab9d26..0fbf1be942c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7329,11 +7329,29 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff) Master_info *mi= NULL; longlong tmp; LINT_INIT(tmp); + int count; var->type= SHOW_LONGLONG; var->value= buff; - mysql_mutex_lock(&LOCK_active_mi); - if (master_info_index) + + count= 0; + while (count < 10) + { + if (mysql_mutex_trylock(&LOCK_active_mi) == EBUSY) + /* If can't get LOCK_active_mi, sleep 0.1 second and try again. */ + my_sleep(100000); + else + break; + + count++; + } + /* It means we can't get the lock, then just show SHOW_UNDEF */ + if (count >= 10) + { + var->type= SHOW_UNDEF; + return 0; + } + if (master_info_index) { mi= master_info_index-> get_master_info(&thd->variables.default_master_connection, @@ -7355,11 +7373,29 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff) Master_info *mi= NULL; float tmp; LINT_INIT(tmp); + int count; var->type= SHOW_CHAR; var->value= buff; - mysql_mutex_lock(&LOCK_active_mi); - if (master_info_index) + + count= 0; + while (count < 10) + { + if (mysql_mutex_trylock(&LOCK_active_mi) == EBUSY) + /* If can't get LOCK_active_mi, sleep 0.1 second and try again. */ + my_sleep(100000); + else + break; + + count++; + } + /* It means we can't get the lock, then just show SHOW_UNDEF */ + if (count >= 10) + { + var->type= SHOW_UNDEF; + return 0; + } + if (master_info_index) { mi= master_info_index-> get_master_info(&thd->variables.default_master_connection, |