diff options
author | unknown <guilhem@mysql.com> | 2004-03-11 16:23:35 +0100 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2004-03-11 16:23:35 +0100 |
commit | f808030209e7bd102b6100df04aa7094bc767af2 (patch) | |
tree | 90f46c5c76afb57731f6600678fb72189c05d38a /sql/slave.h | |
parent | c6d91e00bbd103e46d806b1b9aad1963f4cfe18c (diff) | |
download | mariadb-git-f808030209e7bd102b6100df04aa7094bc767af2.tar.gz |
Fix for BUG#2921 "Replication problem on mutex lock in mySQL-4.0.18":
re-using unused LOCK_active_mi to serialize all administrative
commands related to replication:
START SLAVE, STOP SLAVE, RESET SLAVE, CHANGE MASTER, init_slave()
(replication autostart at server startup), end_slave() (replication
autostop at server shutdown), LOAD DATA FROM MASTER.
This protects us against a handful of deadlocks (like BUG#2921
when two START SLAVE, but when two STOP SLAVE too).
Removing unused variables.
sql/item_func.cc:
We don't need LOCK_active_mi just to MASTER_POS_WAIT().
sql/repl_failsafe.cc:
no need for macro
sql/set_var.cc:
no need for macro
sql/slave.cc:
Re-using unused LOCK_active_mi to serialize all administrative
commands related to replication:
START SLAVE, STOP SLAVE, RESET SLAVE, CHANGE MASTER, init_slave()
(replication autostart at server startup), end_slave() (replication
autostop at server shutdown), LOAD DATA FROM MASTER.
This protects us against a handful of deadlocks.
Removing unused variables.
sql/slave.h:
Re-using LOCK_active_mi to serialize administrative replication commands.
Macros unneeded. Removing unneeded variables.
sql/sql_parse.cc:
found unused variable.
Replacing macros.
sql/sql_show.cc:
replacing macros
Diffstat (limited to 'sql/slave.h')
-rw-r--r-- | sql/slave.h | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/sql/slave.h b/sql/slave.h index 9877582d094..4a6389e9f87 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -27,12 +27,19 @@ /* MUTEXES in replication: - LOCK_active_mi: this is meant for multimaster, when we can switch from a - master to another. It protects active_mi. We don't care of it for the moment, - as active_mi never moves (it's created at startup and deleted at shutdown, and - not changed: it always points to the same MASTER_INFO struct), because we - don't have multimaster. So for the moment, mi does not move, and mi->rli does - not either. + LOCK_active_mi: [note: this was originally meant for multimaster, to switch + from a master to another, to protect active_mi] It is used to SERIALIZE ALL + administrative commands of replication: START SLAVE, STOP SLAVE, CHANGE + MASTER, RESET SLAVE, end_slave() (when mysqld stops) [init_slave() does not + need it it's called early]. Any of these commands holds the mutex from the + start till the end. This thus protects us against a handful of deadlocks + (consider start_slave_thread() which, when starting the I/O thread, releases + mi->run_lock, keeps rli->run_lock, and tries to re-acquire mi->run_lock). + + Currently active_mi never moves (it's created at startup and deleted at + shutdown, and not changed: it always points to the same MASTER_INFO struct), + because we don't have multimaster. So for the moment, mi does not move, and + mi->rli does not either. In MASTER_INFO: run_lock, data_lock run_lock protects all information about the run state: slave_running, and the @@ -43,6 +50,9 @@ In RELAY_LOG_INFO: run_lock, data_lock see MASTER_INFO + Order of acquisition: if you want to have LOCK_active_mi and a run_lock, you + must acquire LOCK_active_mi first. + In MYSQL_LOG: LOCK_log, LOCK_index of the binlog and the relay log LOCK_log: when you write to it. LOCK_index: when you create/delete a binlog (so that you have to update the .index file). @@ -65,19 +75,6 @@ enum enum_binlog_formats { BINLOG_FORMAT_323_GEQ_57 }; /* - TODO: this needs to be redone, but for now it does not matter since - we do not have multi-master yet. -*/ - -#define LOCK_ACTIVE_MI { pthread_mutex_lock(&LOCK_active_mi); \ - ++active_mi_in_use; \ - pthread_mutex_unlock(&LOCK_active_mi);} - -#define UNLOCK_ACTIVE_MI { pthread_mutex_lock(&LOCK_active_mi); \ - --active_mi_in_use; \ - pthread_mutex_unlock(&LOCK_active_mi); } - -/* st_relay_log_info contains information on the current relay log and relay log offset, and master log name and log sequence corresponding to the last update. Additionally, misc information specific to the SQL thread is @@ -441,7 +438,6 @@ extern "C" pthread_handler_decl(handle_slave_io,arg); extern "C" pthread_handler_decl(handle_slave_sql,arg); extern bool volatile abort_loop; extern MASTER_INFO main_mi, *active_mi; /* active_mi for multi-master */ -extern volatile int active_mi_in_use; extern LIST master_list; extern HASH replicate_do_table, replicate_ignore_table; extern DYNAMIC_ARRAY replicate_wild_do_table, replicate_wild_ignore_table; |