diff options
author | unknown <guilhem@mysql.com> | 2004-12-16 18:12:22 +0100 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2004-12-16 18:12:22 +0100 |
commit | b3d56a7dd0dca045335e1db818a698dd5f7b48ce (patch) | |
tree | 747ea547f2e4eb2f3ee55054dac260feb2f91c5b /sql/slave.h | |
parent | 8ad9752e259d2c9a296dbb20db1977c673ef89cd (diff) | |
download | mariadb-git-b3d56a7dd0dca045335e1db818a698dd5f7b48ce.tar.gz |
A change of behaviour of Seconds_Behind_Master from SHOW SLAVE STATUS. It's going into 4.1
because old behaviour was somewhat nonsensical (kind of bug). Changes are that if repl threads are
down or disconnected the column will be NULL, and if master is idle the column will not grow indefinitely anymore.
sql/slave.cc:
mi->slave_running and rli->slave_running now uints (was needed only for mi but because of start_slave_thread() usage,
had to change both).
So mi->slave_running can now take 3 values: not running, running & not connected, running and connected.
The last value serves for calculation of Seconds_Behind_Master in SHOW SLAVE STATUS.
Changing this column's behaviour: if SQL or I/O thread is not running, or if I/O thread is not connected
(for example if it is reconnecting), it's NULL (to mean "unknown"). And if master is idle, the column will
not grow indefinitely like it used to (that was meaningless); this is fixed by forcing a value of 0
when the slave SQL thread has hit EOF of relay log (which has only a limited number of caveats explained
in comments in code).
sql/slave.h:
slave_running used to be bool but we need to distinguish, for the I/O slave thread, between
"running & connected" and "running & not connected" ("running" means the thread exists).
sql/sql_repl.cc:
we don't need anymore to set rli->last_master_timestamp to 0 (we used that to make Seconds_Behind_Master
be NULL) in RESET SLAVE and CHANGE MASTER, as these commands imply that slave threads are not running
and so Seconds_Behind_Master is already NULL because of that.
Diffstat (limited to 'sql/slave.h')
-rw-r--r-- | sql/slave.h | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/sql/slave.h b/sql/slave.h index 08cf0806717..bcd79dd4a39 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -98,6 +98,21 @@ enum enum_binlog_formats { BINLOG_FORMAT_323_LESS_57, BINLOG_FORMAT_323_GEQ_57 }; +/* + 3 possible values for MASTER_INFO::slave_running and + RELAY_LOG_INFO::slave_running. + The values 0,1,2 are very important: to keep the diff small, I didn't + substitute places where we use 0/1 with the newly defined symbols. So don't change + these values. + The same way, code is assuming that in RELAY_LOG_INFO we use only values + 0/1. + I started with using an enum, but + enum_variable=1; is not legal so would have required many line changes. +*/ +#define MYSQL_SLAVE_NOT_RUN 0 +#define MYSQL_SLAVE_RUN_NOT_CONNECT 1 +#define MYSQL_SLAVE_RUN_CONNECT 2 + /**************************************************************************** Replication SQL Thread @@ -251,7 +266,8 @@ typedef struct st_relay_log_info /* if not set, the value of other members of the structure are undefined */ bool inited; - volatile bool abort_slave, slave_running; + volatile bool abort_slave; + volatile uint slave_running; /* Condition and its parameters from START SLAVE UNTIL clause. @@ -385,7 +401,8 @@ typedef struct st_master_info #endif bool inited; enum enum_binlog_formats old_format; - volatile bool abort_slave, slave_running; + volatile bool abort_slave; + volatile uint slave_running; volatile ulong slave_run_id; /* The difference in seconds between the clock of the master and the clock of @@ -464,7 +481,7 @@ int terminate_slave_threads(MASTER_INFO* mi, int thread_mask, int terminate_slave_thread(THD* thd, pthread_mutex_t* term_mutex, pthread_mutex_t* cond_lock, pthread_cond_t* term_cond, - volatile bool* slave_running); + volatile uint* slave_running); int start_slave_threads(bool need_slave_mutex, bool wait_for_start, MASTER_INFO* mi, const char* master_info_fname, const char* slave_info_fname, int thread_mask); @@ -477,7 +494,7 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start, int start_slave_thread(pthread_handler h_func, pthread_mutex_t* start_lock, pthread_mutex_t *cond_lock, pthread_cond_t* start_cond, - volatile bool *slave_running, + volatile uint *slave_running, volatile ulong *slave_run_id, MASTER_INFO* mi, bool high_priority); @@ -519,7 +536,7 @@ void slave_print_error(RELAY_LOG_INFO* rli, int err_code, const char* msg, ...); void end_slave(); /* clean up */ void init_master_info_with_options(MASTER_INFO* mi); void clear_until_condition(RELAY_LOG_INFO* rli); -void clear_slave_error_timestamp(RELAY_LOG_INFO* rli); +void clear_slave_error(RELAY_LOG_INFO* rli); int init_master_info(MASTER_INFO* mi, const char* master_info_fname, const char* slave_info_fname, bool abort_if_no_master_info_file, |