2004-09-09 03:26:19 +02:00
|
|
|
/* Copyright (C) 2000-2003 MySQL AB
|
2005-02-01 15:36:48 +01:00
|
|
|
|
2004-09-09 03:26:19 +02:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2005-02-01 15:36:48 +01:00
|
|
|
|
2004-09-09 03:26:19 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2005-02-01 15:36:48 +01:00
|
|
|
|
2004-09-09 03:26:19 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
2000-11-11 22:50:39 +01:00
|
|
|
#ifndef SLAVE_H
|
|
|
|
#define SLAVE_H
|
|
|
|
|
2005-12-22 06:39:02 +01:00
|
|
|
#ifdef HAVE_REPLICATION
|
|
|
|
|
|
|
|
#include "log.h"
|
2002-01-20 03:16:52 +01:00
|
|
|
#include "my_list.h"
|
2005-03-21 22:09:42 +01:00
|
|
|
#include "rpl_filter.h"
|
2005-12-22 06:39:02 +01:00
|
|
|
#include "rpl_tblmap.h"
|
|
|
|
#include "rpl_rli.h"
|
2005-03-10 14:36:48 +01:00
|
|
|
|
2001-07-17 22:22:52 +02:00
|
|
|
#define SLAVE_NET_TIMEOUT 3600
|
2005-12-22 06:39:02 +01:00
|
|
|
|
2002-01-22 23:05:11 +01:00
|
|
|
#define MAX_SLAVE_ERROR 2000
|
2002-01-20 03:16:52 +01:00
|
|
|
|
2002-10-29 23:12:47 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
MySQL Replication
|
|
|
|
|
|
|
|
Replication is implemented via two types of threads:
|
|
|
|
|
|
|
|
I/O Thread - One of these threads is started for each master server.
|
|
|
|
They maintain a connection to their master server, read log
|
|
|
|
events from the master as they arrive, and queues them into
|
|
|
|
a single, shared relay log file. A MASTER_INFO struct
|
|
|
|
represents each of these threads.
|
|
|
|
|
|
|
|
SQL Thread - One of these threads is started and reads from the relay log
|
|
|
|
file, executing each event. A RELAY_LOG_INFO struct
|
|
|
|
represents this thread.
|
|
|
|
|
|
|
|
Buffering in the relay log file makes it unnecessary to reread events from
|
|
|
|
a master server across a slave restart. It also decouples the slave from
|
|
|
|
the master where long-running updates and event logging are concerned--ie
|
|
|
|
it can continue to log new events while a slow query executes on the slave.
|
|
|
|
|
|
|
|
*****************************************************************************/
|
2001-07-17 22:22:52 +02:00
|
|
|
|
2003-08-25 16:20:21 +02:00
|
|
|
/*
|
|
|
|
MUTEXES in replication:
|
|
|
|
|
2004-03-11 16:23:35 +01:00
|
|
|
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.
|
2003-08-25 16:20:21 +02:00
|
|
|
|
|
|
|
In MASTER_INFO: run_lock, data_lock
|
|
|
|
run_lock protects all information about the run state: slave_running, and the
|
|
|
|
existence of the I/O thread (to stop/start it, you need this mutex).
|
|
|
|
data_lock protects some moving members of the struct: counters (log name,
|
|
|
|
position) and relay log (MYSQL_LOG object).
|
|
|
|
|
|
|
|
In RELAY_LOG_INFO: run_lock, data_lock
|
|
|
|
see MASTER_INFO
|
|
|
|
|
2004-03-11 16:23:35 +01:00
|
|
|
Order of acquisition: if you want to have LOCK_active_mi and a run_lock, you
|
|
|
|
must acquire LOCK_active_mi first.
|
|
|
|
|
2003-08-25 16:20:21 +02:00
|
|
|
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).
|
|
|
|
*/
|
|
|
|
|
2003-06-04 07:57:42 +02:00
|
|
|
extern ulong master_retry_count;
|
2002-01-22 23:05:11 +01:00
|
|
|
extern MY_BITMAP slave_error_mask;
|
|
|
|
extern bool use_slave_mask;
|
2001-08-03 23:57:53 +02:00
|
|
|
extern char* slave_load_tmpdir;
|
2002-01-20 03:16:52 +01:00
|
|
|
extern my_string master_info_file,relay_log_info_file;
|
|
|
|
extern my_string opt_relay_logname, opt_relaylog_index_name;
|
2002-08-22 15:50:58 +02:00
|
|
|
extern my_bool opt_skip_slave_start, opt_reckless_slave;
|
|
|
|
extern my_bool opt_log_slave_updates;
|
2002-08-23 14:14:01 +02:00
|
|
|
extern ulonglong relay_log_space_limit;
|
2002-01-20 03:16:52 +01:00
|
|
|
struct st_master_info;
|
|
|
|
|
2004-12-16 18:12:22 +01:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
|
2005-12-22 06:39:02 +01:00
|
|
|
static Log_event* next_event(RELAY_LOG_INFO* rli);
|
2002-01-20 03:16:52 +01:00
|
|
|
|
2002-10-29 23:12:47 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
Replication IO Thread
|
|
|
|
|
|
|
|
st_master_info contains:
|
|
|
|
- information about how to connect to a master
|
|
|
|
- current master log name
|
|
|
|
- current master log offset
|
|
|
|
- misc control variables
|
2002-01-20 03:16:52 +01:00
|
|
|
|
2002-06-05 22:04:38 +02:00
|
|
|
st_master_info is initialized once from the master.info file if such
|
|
|
|
exists. Otherwise, data members corresponding to master.info fields
|
|
|
|
are initialized with defaults specified by master-* options. The
|
|
|
|
initialization is done through init_master_info() call.
|
2002-01-20 03:16:52 +01:00
|
|
|
|
2002-06-05 22:04:38 +02:00
|
|
|
The format of master.info file:
|
2002-01-20 03:16:52 +01:00
|
|
|
|
2002-06-05 22:04:38 +02:00
|
|
|
log_name
|
|
|
|
log_pos
|
|
|
|
master_host
|
|
|
|
master_user
|
|
|
|
master_pass
|
|
|
|
master_port
|
|
|
|
master_connect_retry
|
2002-01-20 03:16:52 +01:00
|
|
|
|
2002-06-05 22:04:38 +02:00
|
|
|
To write out the contents of master.info file to disk ( needed every
|
|
|
|
time we read and queue data from the master ), a call to
|
|
|
|
flush_master_info() is required.
|
2002-01-20 03:16:52 +01:00
|
|
|
|
2002-06-05 22:04:38 +02:00
|
|
|
To clean up, call end_master_info()
|
2002-01-29 17:32:16 +01:00
|
|
|
|
2002-10-29 23:12:47 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2000-11-11 22:50:39 +01:00
|
|
|
typedef struct st_master_info
|
|
|
|
{
|
2002-07-17 14:17:20 +02:00
|
|
|
/* the variables below are needed because we can change masters on the fly */
|
2002-01-20 03:16:52 +01:00
|
|
|
char master_log_name[FN_REFLEN];
|
2003-07-04 02:18:15 +02:00
|
|
|
char host[HOSTNAME_LENGTH+1];
|
|
|
|
char user[USERNAME_LENGTH+1];
|
|
|
|
char password[MAX_PASSWORD_LENGTH+1];
|
2003-09-01 13:16:20 +02:00
|
|
|
my_bool ssl; // enables use of SSL connection if true
|
|
|
|
char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN];
|
|
|
|
char ssl_cipher[FN_REFLEN], ssl_key[FN_REFLEN];
|
2005-02-01 15:36:48 +01:00
|
|
|
|
2002-01-29 17:32:16 +01:00
|
|
|
my_off_t master_log_pos;
|
2002-08-08 02:12:02 +02:00
|
|
|
File fd; // we keep the file open, so we need to remember the file pointer
|
2000-11-25 03:49:13 +01:00
|
|
|
IO_CACHE file;
|
2005-02-01 15:36:48 +01:00
|
|
|
|
2002-01-20 03:16:52 +01:00
|
|
|
pthread_mutex_t data_lock,run_lock;
|
|
|
|
pthread_cond_t data_cond,start_cond,stop_cond;
|
2002-01-29 17:32:16 +01:00
|
|
|
THD *io_thd;
|
2002-02-07 23:29:46 +01:00
|
|
|
MYSQL* mysql;
|
2003-07-04 02:18:15 +02:00
|
|
|
uint32 file_id; /* for 3.23 load data infile */
|
2002-01-20 03:16:52 +01:00
|
|
|
RELAY_LOG_INFO rli;
|
2002-01-29 17:32:16 +01:00
|
|
|
uint port;
|
|
|
|
uint connect_retry;
|
2002-01-20 03:16:52 +01:00
|
|
|
#ifndef DBUG_OFF
|
2005-12-22 06:39:02 +01:00
|
|
|
int events_till_disconnect;
|
2002-01-20 03:16:52 +01:00
|
|
|
#endif
|
2002-01-29 17:32:16 +01:00
|
|
|
bool inited;
|
2004-12-16 18:12:22 +01:00
|
|
|
volatile bool abort_slave;
|
|
|
|
volatile uint slave_running;
|
2002-08-24 04:44:16 +02:00
|
|
|
volatile ulong slave_run_id;
|
2005-02-01 15:36:48 +01:00
|
|
|
/*
|
2003-10-09 00:06:21 +02:00
|
|
|
The difference in seconds between the clock of the master and the clock of
|
|
|
|
the slave (second - first). It must be signed as it may be <0 or >0.
|
|
|
|
clock_diff_with_master is computed when the I/O thread starts; for this the
|
|
|
|
I/O thread does a SELECT UNIX_TIMESTAMP() on the master.
|
|
|
|
"how late the slave is compared to the master" is computed like this:
|
|
|
|
clock_of_slave - last_timestamp_executed_by_SQL_thread - clock_diff_with_master
|
|
|
|
|
|
|
|
*/
|
2005-02-01 15:36:48 +01:00
|
|
|
long clock_diff_with_master;
|
|
|
|
|
2002-08-24 04:44:16 +02:00
|
|
|
st_master_info()
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
2003-12-18 01:09:05 +01:00
|
|
|
:ssl(0), fd(-1), io_thd(0), inited(0),
|
2003-06-06 16:41:28 +02:00
|
|
|
abort_slave(0),slave_running(0), slave_run_id(0)
|
2000-11-11 22:50:39 +01:00
|
|
|
{
|
|
|
|
host[0] = 0; user[0] = 0; password[0] = 0;
|
2003-09-01 13:16:20 +02:00
|
|
|
ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0;
|
|
|
|
ssl_cipher[0]= 0; ssl_key[0]= 0;
|
2005-02-01 15:36:48 +01:00
|
|
|
|
2003-08-11 21:44:43 +02:00
|
|
|
bzero((char*) &file, sizeof(file));
|
2002-01-20 03:16:52 +01:00
|
|
|
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
|
|
|
|
pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
|
|
|
|
pthread_cond_init(&data_cond, NULL);
|
|
|
|
pthread_cond_init(&start_cond, NULL);
|
|
|
|
pthread_cond_init(&stop_cond, NULL);
|
2000-11-11 22:50:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
~st_master_info()
|
|
|
|
{
|
2002-01-20 03:16:52 +01:00
|
|
|
pthread_mutex_destroy(&run_lock);
|
|
|
|
pthread_mutex_destroy(&data_lock);
|
|
|
|
pthread_cond_destroy(&data_cond);
|
|
|
|
pthread_cond_destroy(&start_cond);
|
|
|
|
pthread_cond_destroy(&stop_cond);
|
2000-11-11 22:50:39 +01:00
|
|
|
}
|
2001-01-17 13:47:33 +01:00
|
|
|
|
2000-11-11 22:50:39 +01:00
|
|
|
} MASTER_INFO;
|
|
|
|
|
2002-09-11 05:40:08 +02:00
|
|
|
|
2002-01-29 17:32:16 +01:00
|
|
|
int queue_event(MASTER_INFO* mi,const char* buf,ulong event_len);
|
2002-01-20 03:16:52 +01:00
|
|
|
|
2003-04-24 15:29:25 +02:00
|
|
|
#define RPL_LOG_NAME (rli->group_master_log_name[0] ? rli->group_master_log_name :\
|
2002-01-20 03:16:52 +01:00
|
|
|
"FIRST")
|
|
|
|
#define IO_RPL_LOG_NAME (mi->master_log_name[0] ? mi->master_log_name :\
|
2001-08-03 23:57:53 +02:00
|
|
|
"FIRST")
|
|
|
|
|
2002-01-29 17:32:16 +01:00
|
|
|
/*
|
|
|
|
If the following is set, if first gives an error, second will be
|
|
|
|
tried. Otherwise, if first fails, we fail.
|
|
|
|
*/
|
|
|
|
#define SLAVE_FORCE_ALL 4
|
2000-11-11 22:50:39 +01:00
|
|
|
|
2002-01-20 03:16:52 +01:00
|
|
|
int init_slave();
|
2002-04-30 15:40:46 +02:00
|
|
|
void init_slave_skip_errors(const char* arg);
|
2003-11-23 17:02:59 +01:00
|
|
|
bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache);
|
2002-08-08 02:12:02 +02:00
|
|
|
bool flush_relay_log_info(RELAY_LOG_INFO* rli);
|
2001-05-31 02:50:56 +02:00
|
|
|
int register_slave_on_master(MYSQL* mysql);
|
2002-01-20 03:16:52 +01:00
|
|
|
int terminate_slave_threads(MASTER_INFO* mi, int thread_mask,
|
|
|
|
bool skip_lock = 0);
|
|
|
|
int terminate_slave_thread(THD* thd, pthread_mutex_t* term_mutex,
|
|
|
|
pthread_mutex_t* cond_lock,
|
|
|
|
pthread_cond_t* term_cond,
|
2004-12-16 18:12:22 +01:00
|
|
|
volatile uint* slave_running);
|
2002-01-20 03:16:52 +01:00
|
|
|
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);
|
2002-01-29 17:32:16 +01:00
|
|
|
/*
|
|
|
|
cond_lock is usually same as start_lock. It is needed for the case when
|
|
|
|
start_lock is 0 which happens if start_slave_thread() is called already
|
|
|
|
inside the start_lock section, but at the same time we want a
|
|
|
|
pthread_cond_wait() on start_cond,start_lock
|
2002-01-20 03:16:52 +01:00
|
|
|
*/
|
|
|
|
int start_slave_thread(pthread_handler h_func, pthread_mutex_t* start_lock,
|
|
|
|
pthread_mutex_t *cond_lock,
|
|
|
|
pthread_cond_t* start_cond,
|
2004-12-16 18:12:22 +01:00
|
|
|
volatile uint *slave_running,
|
2002-08-24 04:44:16 +02:00
|
|
|
volatile ulong *slave_run_id,
|
2003-03-01 23:59:27 +01:00
|
|
|
MASTER_INFO* mi,
|
|
|
|
bool high_priority);
|
2000-11-11 22:50:39 +01:00
|
|
|
|
2002-07-17 14:17:20 +02:00
|
|
|
/* If fd is -1, dump to NET */
|
2001-05-29 03:18:23 +02:00
|
|
|
int mysql_table_dump(THD* thd, const char* db,
|
|
|
|
const char* tbl_name, int fd = -1);
|
|
|
|
|
2003-09-11 23:17:28 +02:00
|
|
|
/* retrieve table from master and copy to slave*/
|
2002-01-29 17:32:16 +01:00
|
|
|
int fetch_master_table(THD* thd, const char* db_name, const char* table_name,
|
2003-09-11 23:17:28 +02:00
|
|
|
MASTER_INFO* mi, MYSQL* mysql, bool overwrite);
|
2001-05-29 03:18:23 +02:00
|
|
|
|
2004-10-20 03:04:37 +02:00
|
|
|
bool show_master_info(THD* thd, MASTER_INFO* mi);
|
|
|
|
bool show_binlog_info(THD* thd);
|
2000-11-11 22:50:39 +01:00
|
|
|
|
2004-10-19 22:27:19 +02:00
|
|
|
const char *print_slave_db_safe(const char *db);
|
2002-01-20 03:16:52 +01:00
|
|
|
int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int error_code);
|
2001-08-03 23:57:53 +02:00
|
|
|
void skip_load_data_infile(NET* net);
|
2005-12-22 06:39:02 +01:00
|
|
|
void slave_print_msg(enum loglevel level, RELAY_LOG_INFO* rli,
|
|
|
|
int err_code, const char* msg, ...);
|
2000-11-11 22:50:39 +01:00
|
|
|
|
2002-07-17 14:17:20 +02:00
|
|
|
void end_slave(); /* clean up */
|
2003-08-04 10:59:44 +02:00
|
|
|
void init_master_info_with_options(MASTER_INFO* mi);
|
2003-09-13 22:13:41 +02:00
|
|
|
void clear_until_condition(RELAY_LOG_INFO* rli);
|
2004-12-16 18:12:22 +01:00
|
|
|
void clear_slave_error(RELAY_LOG_INFO* rli);
|
2002-01-20 03:16:52 +01:00
|
|
|
int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
|
2002-08-08 02:12:02 +02:00
|
|
|
const char* slave_info_fname,
|
2004-11-25 09:26:45 +01:00
|
|
|
bool abort_if_no_master_info_file,
|
|
|
|
int thread_mask);
|
2000-12-09 22:28:51 +01:00
|
|
|
void end_master_info(MASTER_INFO* mi);
|
2002-01-20 03:16:52 +01:00
|
|
|
void end_relay_log_info(RELAY_LOG_INFO* rli);
|
|
|
|
void lock_slave_threads(MASTER_INFO* mi);
|
|
|
|
void unlock_slave_threads(MASTER_INFO* mi);
|
|
|
|
void init_thread_mask(int* mask,MASTER_INFO* mi,bool inverse);
|
|
|
|
int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,ulonglong pos,
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
2003-12-18 01:09:05 +01:00
|
|
|
bool need_data_lock, const char** errmsg,
|
|
|
|
bool look_for_description_event);
|
2001-01-24 17:15:34 +01:00
|
|
|
|
2002-08-08 02:12:02 +02:00
|
|
|
int purge_relay_logs(RELAY_LOG_INFO* rli, THD *thd, bool just_reset,
|
|
|
|
const char** errmsg);
|
This will be pushed only after I fix the testsuite.
This is the main commit for Worklog tasks:
* A more dynamic binlog format which allows small changes (1064)
* Log session variables in Query_log_event (1063)
Below 5.0 means 5.0.0.
MySQL 5.0 is able to replicate FOREIGN_KEY_CHECKS, UNIQUE_KEY_CHECKS (for speed),
SQL_AUTO_IS_NULL, SQL_MODE. Not charsets (WL#1062), not some vars (I can only think
of SQL_SELECT_LIMIT, which deserves a special treatment). Note that this
works for queries, except LOAD DATA INFILE (for this it would have to wait
for Dmitri's push of WL#874, which in turns waits for the present push, so...
the deadlock must be broken!). Note that when Dmitri pushes WL#874 in 5.0.1,
5.0.0 won't be able to replicate a LOAD DATA INFILE from 5.0.1.
Apart from that, the new binlog format is designed so that it can tolerate
a little variation in the events (so that a 5.0.0 slave could replicate a
5.0.1 master, except for LOAD DATA INFILE unfortunately); that is, when I
later add replication of charsets it should break nothing. And when I later
add a UID to every event, it should break nothing.
The main change brought by this patch is a new type of event, Format_description_log_event,
which describes some lengthes in other event types. This event is needed for
the master/slave/mysqlbinlog to understand a 5.0 log. Thanks to this event,
we can later add more bytes to the header of every event without breaking compatibility.
Inside Query_log_event, we have some additional dynamic format, as every Query_log_event
can have a different number of status variables, stored as pairs (code, value); that's
how SQL_MODE and session variables and catalog are stored. Like this, we can later
add count of affected rows, charsets... and we can have options --don't-log-count-affected-rows
if we want.
MySQL 5.0 is able to run on 4.x relay logs, 4.x binlogs.
Upgrading a 4.x master to 5.0 is ok (no need to delete binlogs),
upgrading a 4.x slave to 5.0 is ok (no need to delete relay logs);
so both can be "hot" upgrades.
Upgrading a 3.23 master to 5.0 requires as much as upgrading it to 4.0.
3.23 and 4.x can't be slaves of 5.0.
So downgrading from 5.0 to 4.x may be complicated.
Log_event::log_pos is now the position of the end of the event, which is
more useful than the position of the beginning. We take care about compatibility
with <5.0 (in which log_pos is the beginning).
I added a short test for replication of SQL_MODE and some other variables.
TODO:
- after committing this, merge the latest 5.0 into it
- fix all tests
- update the manual with upgrade notes.
2003-12-18 01:09:05 +01:00
|
|
|
void set_slave_thread_options(THD* thd);
|
2005-03-22 00:26:12 +01:00
|
|
|
void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO *rli);
|
2003-07-06 17:59:54 +02:00
|
|
|
void rotate_relay_log(MASTER_INFO* mi);
|
2002-01-20 03:16:52 +01:00
|
|
|
|
2005-10-08 16:39:55 +02:00
|
|
|
pthread_handler_t handle_slave_io(void *arg);
|
|
|
|
pthread_handler_t handle_slave_sql(void *arg);
|
2002-01-20 03:16:52 +01:00
|
|
|
extern bool volatile abort_loop;
|
2002-07-17 14:17:20 +02:00
|
|
|
extern MASTER_INFO main_mi, *active_mi; /* active_mi for multi-master */
|
2002-01-20 03:16:52 +01:00
|
|
|
extern LIST master_list;
|
2005-10-04 18:52:12 +02:00
|
|
|
extern my_bool replicate_same_server_id;
|
2000-11-11 22:50:39 +01:00
|
|
|
|
2000-12-02 18:11:50 +01:00
|
|
|
extern int disconnect_slave_event_count, abort_slave_event_count ;
|
2000-11-22 08:23:31 +01:00
|
|
|
|
2002-07-17 14:17:20 +02:00
|
|
|
/* the master variables are defaults read from my.cnf or command line */
|
2001-05-31 02:50:56 +02:00
|
|
|
extern uint master_port, master_connect_retry, report_port;
|
2000-11-11 22:50:39 +01:00
|
|
|
extern my_string master_user, master_password, master_host,
|
2002-01-29 17:32:16 +01:00
|
|
|
master_info_file, relay_log_info_file, report_user, report_host,
|
|
|
|
report_password;
|
2000-11-11 22:50:39 +01:00
|
|
|
|
2003-09-01 13:16:20 +02:00
|
|
|
extern my_bool master_ssl;
|
|
|
|
extern my_string master_ssl_ca, master_ssl_capath, master_ssl_cert,
|
|
|
|
master_ssl_cipher, master_ssl_key;
|
|
|
|
|
2000-11-11 22:50:39 +01:00
|
|
|
extern I_List<THD> threads;
|
|
|
|
|
2005-12-22 06:39:02 +01:00
|
|
|
#endif /* HAVE_REPLICATION */
|
|
|
|
|
|
|
|
/* masks for start/stop operations on io and sql slave threads */
|
2002-12-16 14:33:29 +01:00
|
|
|
#define SLAVE_IO 1
|
|
|
|
#define SLAVE_SQL 2
|
2005-12-22 06:39:02 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|