1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLE_SERVER_SLAVE_H
21
#define DRIZZLE_SERVER_SLAVE_H
1
/* Copyright (C) 2000-2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
24
20
@defgroup Replication Replication
103
101
Order of acquisition: if you want to have LOCK_active_mi and a run_lock, you
104
102
must acquire LOCK_active_mi first.
106
In DRIZZLE_BIN_LOG: LOCK_log, LOCK_index of the binlog and the relay log
104
In MYSQL_BIN_LOG: LOCK_log, LOCK_index of the binlog and the relay log
107
105
LOCK_log: when you write to it. LOCK_index: when you create/delete a binlog
108
106
(so that you have to update the .index file).
111
extern uint32_t master_retry_count;
109
extern ulong master_retry_count;
112
110
extern MY_BITMAP slave_error_mask;
113
111
extern bool use_slave_mask;
114
112
extern char *slave_load_tmpdir;
115
113
extern char *master_info_file, *relay_log_info_file;
116
114
extern char *opt_relay_logname, *opt_relaylog_index_name;
117
extern bool opt_skip_slave_start;
118
extern bool opt_reckless_slave;
119
extern bool opt_log_slave_updates;
120
extern uint64_t relay_log_space_limit;
115
extern my_bool opt_skip_slave_start, opt_reckless_slave;
116
extern my_bool opt_log_slave_updates;
117
extern ulonglong relay_log_space_limit;
123
120
3 possible values for Master_info::slave_running and
130
127
I started with using an enum, but
131
128
enum_variable=1; is not legal so would have required many line changes.
133
#define DRIZZLE_SLAVE_NOT_RUN 0
134
#define DRIZZLE_SLAVE_RUN_NOT_CONNECT 1
135
#define DRIZZLE_SLAVE_RUN_CONNECT 2
130
#define MYSQL_SLAVE_NOT_RUN 0
131
#define MYSQL_SLAVE_RUN_NOT_CONNECT 1
132
#define MYSQL_SLAVE_RUN_CONNECT 2
137
#define RPL_LOG_NAME (rli->group_master_log_name.length() ? rli->group_master_log_name.c_str() : "FIRST")
138
#define IO_RPL_LOG_NAME (mi->getLogName() ? mi->getLogName() : "FIRST")
134
#define RPL_LOG_NAME (rli->group_master_log_name[0] ? rli->group_master_log_name :\
136
#define IO_RPL_LOG_NAME (mi->master_log_name[0] ? mi->master_log_name :\
141
140
If the following is set, if first gives an error, second will be
144
143
#define SLAVE_FORCE_ALL 4
146
int32_t init_slave();
147
146
void init_slave_skip_errors(const char* arg);
148
147
bool flush_relay_log_info(Relay_log_info* rli);
149
int32_t register_slave_on_master(DRIZZLE *drizzle);
150
int32_t terminate_slave_threads(Master_info* mi, int32_t thread_mask,
148
int register_slave_on_master(MYSQL* mysql);
149
int terminate_slave_threads(Master_info* mi, int thread_mask,
151
150
bool skip_lock = 0);
152
int32_t start_slave_threads(bool need_slave_mutex, bool wait_for_start,
151
int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
153
152
Master_info* mi, const char* master_info_fname,
154
const char* slave_info_fname, int32_t thread_mask);
153
const char* slave_info_fname, int thread_mask);
156
155
cond_lock is usually same as start_lock. It is needed for the case when
157
156
start_lock is 0 which happens if start_slave_thread() is called already
158
157
inside the start_lock section, but at the same time we want a
159
158
pthread_cond_wait() on start_cond,start_lock
161
int32_t start_slave_thread(pthread_handler h_func, pthread_mutex_t* start_lock,
160
int start_slave_thread(pthread_handler h_func, pthread_mutex_t* start_lock,
162
161
pthread_mutex_t *cond_lock,
163
162
pthread_cond_t* start_cond,
164
volatile uint32_t *slave_running,
165
volatile uint32_t *slave_run_id,
163
volatile uint *slave_running,
164
volatile ulong *slave_run_id,
167
166
bool high_priority);
169
168
/* If fd is -1, dump to NET */
170
int32_t mysql_table_dump(THD* thd, const char* db,
171
const char* tbl_name, int32_t fd = -1);
169
int mysql_table_dump(THD* thd, const char* db,
170
const char* tbl_name, int fd = -1);
173
172
/* retrieve table from master and copy to slave*/
174
int32_t fetch_master_table(THD* thd, const char* db_name, const char* table_name,
175
Master_info* mi, DRIZZLE *drizzle, bool overwrite);
173
int fetch_master_table(THD* thd, const char* db_name, const char* table_name,
174
Master_info* mi, MYSQL* mysql, bool overwrite);
177
176
bool show_master_info(THD* thd, Master_info* mi);
178
177
bool show_binlog_info(THD* thd);
179
bool rpl_master_has_bug(Relay_log_info *rli, uint32_t bug_id, bool report= true);
178
bool rpl_master_has_bug(Relay_log_info *rli, uint bug_id, bool report= true);
180
179
bool rpl_master_erroneous_autoinc(THD* thd);
182
181
const char *print_slave_db_safe(const char *db);
183
int32_t check_expected_error(THD* thd, Relay_log_info const *rli, int32_t error_code);
182
int check_expected_error(THD* thd, Relay_log_info const *rli, int error_code);
184
183
void skip_load_data_infile(NET* net);
186
185
void end_slave(); /* clean up */
189
188
void end_relay_log_info(Relay_log_info* rli);
190
189
void lock_slave_threads(Master_info* mi);
191
190
void unlock_slave_threads(Master_info* mi);
192
void init_thread_mask(int32_t* mask,Master_info* mi,bool inverse);
193
int32_t init_relay_log_pos(Relay_log_info* rli,const char* log,uint64_t pos,
191
void init_thread_mask(int* mask,Master_info* mi,bool inverse);
192
int init_relay_log_pos(Relay_log_info* rli,const char* log,ulonglong pos,
194
193
bool need_data_lock, const char** errmsg,
195
194
bool look_for_description_event);
197
int32_t purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
196
int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
198
197
const char** errmsg);
199
198
void set_slave_thread_options(THD* thd);
199
void set_slave_thread_default_charset(THD *thd, Relay_log_info const *rli);
200
200
void rotate_relay_log(Master_info* mi);
201
int32_t apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli,
201
int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli,
204
204
pthread_handler_t handle_slave_io(void *arg);
206
206
extern bool volatile abort_loop;
207
207
extern Master_info main_mi, *active_mi; /* active_mi for multi-master */
208
208
extern LIST master_list;
209
extern bool replicate_same_server_id;
209
extern my_bool replicate_same_server_id;
211
extern int32_t disconnect_slave_event_count, abort_slave_event_count ;
211
extern int disconnect_slave_event_count, abort_slave_event_count ;
213
213
/* the master variables are defaults read from my.cnf or command line */
214
extern uint32_t master_port, master_connect_retry, report_port;
214
extern uint master_port, master_connect_retry, report_port;
215
215
extern char * master_user, *master_password, *master_host;
216
216
extern char *master_info_file, *relay_log_info_file, *report_user;
217
217
extern char *report_host, *report_password;
219
extern bool master_ssl;
219
extern my_bool master_ssl;
220
220
extern char *master_ssl_ca, *master_ssl_capath, *master_ssl_cert;
221
221
extern char *master_ssl_cipher, *master_ssl_key;
223
223
extern I_List<THD> threads;
225
#endif /* HAVE_REPLICATION */
225
227
/* masks for start/stop operations on io and sql slave threads */
226
228
#define SLAVE_IO 1
227
229
#define SLAVE_SQL 2