|
|
|
@ -122,15 +122,17 @@ int tables_ok(THD* thd, TABLE_LIST* tables)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if (wild_do_table_inited && find_wild(&replicate_wild_do_table,
|
|
|
|
|
hash_key, len)) return 1;
|
|
|
|
|
hash_key, len))
|
|
|
|
|
return 1;
|
|
|
|
|
if (wild_ignore_table_inited && find_wild(&replicate_wild_ignore_table,
|
|
|
|
|
hash_key, len)) return 0;
|
|
|
|
|
hash_key, len))
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return !do_table_inited && !wild_do_table_inited;
|
|
|
|
|
// if no explicit rule found
|
|
|
|
|
// and there was a do list, do not replicate. If there was
|
|
|
|
|
// no do list, go ahead
|
|
|
|
|
return !do_table_inited && !wild_do_table_inited;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -138,8 +140,8 @@ int add_table_rule(HASH* h, const char* table_spec)
|
|
|
|
|
{
|
|
|
|
|
const char* dot = strchr(table_spec, '.');
|
|
|
|
|
if(!dot) return 1;
|
|
|
|
|
// len is always > 0 because we know the there exists a '.'
|
|
|
|
|
uint len = (uint)strlen(table_spec);
|
|
|
|
|
if(!len) return 1;
|
|
|
|
|
TABLE_RULE_ENT* e = (TABLE_RULE_ENT*)my_malloc(sizeof(TABLE_RULE_ENT)
|
|
|
|
|
+ len, MYF(MY_WME));
|
|
|
|
|
if(!e) return 1;
|
|
|
|
@ -156,7 +158,6 @@ int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec)
|
|
|
|
|
const char* dot = strchr(table_spec, '.');
|
|
|
|
|
if(!dot) return 1;
|
|
|
|
|
uint len = (uint)strlen(table_spec);
|
|
|
|
|
if(!len) return 1;
|
|
|
|
|
TABLE_RULE_ENT* e = (TABLE_RULE_ENT*)my_malloc(sizeof(TABLE_RULE_ENT)
|
|
|
|
|
+ len, MYF(MY_WME));
|
|
|
|
|
if(!e) return 1;
|
|
|
|
@ -227,9 +228,10 @@ int db_ok(const char* db, I_List<i_string> &do_list,
|
|
|
|
|
if(do_list.is_empty() && ignore_list.is_empty())
|
|
|
|
|
return 1; // ok to replicate if the user puts no constraints
|
|
|
|
|
|
|
|
|
|
if(!db)
|
|
|
|
|
return 0; // if the user has specified restrictions on which databases to replicate
|
|
|
|
|
// if the user has specified restrictions on which databases to replicate
|
|
|
|
|
// and db was not selected, do not replicate
|
|
|
|
|
if(!db)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if(!do_list.is_empty()) // if the do's are not empty
|
|
|
|
|
{
|
|
|
|
@ -255,23 +257,25 @@ int db_ok(const char* db, I_List<i_string> &do_list,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int init_strvar_from_file(char* var, int max_size, IO_CACHE* f,
|
|
|
|
|
char* default_val)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if(my_b_gets(f,var, max_size))
|
|
|
|
|
uint length;
|
|
|
|
|
if ((length=my_b_gets(f,var, max_size)))
|
|
|
|
|
{
|
|
|
|
|
char* last_p = strend(var) - 1;
|
|
|
|
|
int c;
|
|
|
|
|
if(*last_p == '\n') *last_p = 0; // if we stopped on newline, kill it
|
|
|
|
|
char* last_p = var + length -1;
|
|
|
|
|
if (*last_p == '\n')
|
|
|
|
|
*last_p = 0; // if we stopped on newline, kill it
|
|
|
|
|
else
|
|
|
|
|
while( ((c=my_b_get(f)) != '\n' && c != my_b_EOF));
|
|
|
|
|
{
|
|
|
|
|
// if we truncated a line or stopped on last char, remove all chars
|
|
|
|
|
// up to and including newline
|
|
|
|
|
int c;
|
|
|
|
|
while( ((c=my_b_get(f)) != '\n' && c != my_b_EOF));
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if (default_val)
|
|
|
|
@ -279,12 +283,10 @@ static int init_strvar_from_file(char* var, int max_size, IO_CACHE* f,
|
|
|
|
|
strmake(var, default_val, max_size);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int init_intvar_from_file(int* var, IO_CACHE* f,
|
|
|
|
|
int default_val)
|
|
|
|
|
static int init_intvar_from_file(int* var, IO_CACHE* f, int default_val)
|
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
|
@ -334,9 +336,9 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db,
|
|
|
|
|
thd->query_error = 0;
|
|
|
|
|
thd->net.no_send_ok = 1;
|
|
|
|
|
thd->proc_info = "Creating table from master dump";
|
|
|
|
|
// save old db in case we are creating in a different database
|
|
|
|
|
char* save_db = thd->db;
|
|
|
|
|
thd->db = thd->last_nx_db; // in case we are creating in a different
|
|
|
|
|
// database
|
|
|
|
|
thd->db = thd->last_nx_db;
|
|
|
|
|
mysql_parse(thd, thd->query, packet_len); // run create table
|
|
|
|
|
thd->db = save_db; // leave things the way the were before
|
|
|
|
|
|
|
|
|
@ -376,9 +378,10 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db,
|
|
|
|
|
check_opt.quick = 1;
|
|
|
|
|
thd->proc_info = "rebuilding the index on master dump table";
|
|
|
|
|
Vio* save_vio = thd->net.vio;
|
|
|
|
|
thd->net.vio = 0; // we do not want repair() to spam us with messages
|
|
|
|
|
// we do not want repair() to spam us with messages
|
|
|
|
|
// just send them to the error log, and report the failure in case of
|
|
|
|
|
// problems
|
|
|
|
|
thd->net.vio = 0;
|
|
|
|
|
if (file->repair(thd,&check_opt ))
|
|
|
|
|
{
|
|
|
|
|
net_printf(&thd->net, ER_INDEX_REBUILD,tables.table->real_name );
|
|
|
|
@ -423,15 +426,12 @@ int fetch_nx_table(THD* thd, MASTER_INFO* mi)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
|
|
|
|
|
|
err:
|
|
|
|
|
if (mysql)
|
|
|
|
|
{
|
|
|
|
|
mc_mysql_close(mysql);
|
|
|
|
|
mysql = 0;
|
|
|
|
|
}
|
|
|
|
|
if (nx_errno && thd->net.vio)
|
|
|
|
|
send_error(&thd->net, nx_errno, "Error in fetch_nx_table");
|
|
|
|
|
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -450,12 +450,12 @@ int init_master_info(MASTER_INFO* mi)
|
|
|
|
|
{
|
|
|
|
|
if (mi->inited)
|
|
|
|
|
return 0;
|
|
|
|
|
int fd;
|
|
|
|
|
int fd,length,error;
|
|
|
|
|
MY_STAT stat_area;
|
|
|
|
|
char fname[FN_REFLEN+128];
|
|
|
|
|
const char *msg;
|
|
|
|
|
fn_format(fname, master_info_file, mysql_data_home, "", 4+16+32);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// we need a mutex while we are changing master info parameters to
|
|
|
|
|
// keep other threads from reading bogus info
|
|
|
|
|
|
|
|
|
@ -463,12 +463,13 @@ int init_master_info(MASTER_INFO* mi)
|
|
|
|
|
mi->pending = 0;
|
|
|
|
|
fd = mi->fd;
|
|
|
|
|
|
|
|
|
|
if(!my_stat(fname, &stat_area, MYF(0))) // we do not want any messages
|
|
|
|
|
// if the file does not exist
|
|
|
|
|
// we do not want any messages if the file does not exist
|
|
|
|
|
if (!my_stat(fname, &stat_area, MYF(0)))
|
|
|
|
|
{
|
|
|
|
|
// if someone removed the file from underneath our feet, just close
|
|
|
|
|
// the old descriptor and re-create the old file
|
|
|
|
|
if(fd >= 0) my_close(fd, MYF(MY_WME));
|
|
|
|
|
if (fd >= 0)
|
|
|
|
|
my_close(fd, MYF(MY_WME));
|
|
|
|
|
if ((fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0
|
|
|
|
|
|| init_io_cache(&mi->file, fd, IO_SIZE*2, READ_CACHE, 0L,0,
|
|
|
|
|
MYF(MY_WME)))
|
|
|
|
@ -490,7 +491,6 @@ int init_master_info(MASTER_INFO* mi)
|
|
|
|
|
strmake(mi->password, master_password, sizeof(mi->password) - 1);
|
|
|
|
|
mi->port = master_port;
|
|
|
|
|
mi->connect_retry = master_connect_retry;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else // file exists
|
|
|
|
|
{
|
|
|
|
@ -506,24 +506,19 @@ int init_master_info(MASTER_INFO* mi)
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!my_b_gets(&mi->file, mi->log_file_name, sizeof(mi->log_file_name)))
|
|
|
|
|
if (!(length=my_b_gets(&mi->file, mi->log_file_name,
|
|
|
|
|
sizeof(mi->log_file_name))))
|
|
|
|
|
{
|
|
|
|
|
sql_print_error("Error reading log file name from master info file ");
|
|
|
|
|
end_io_cache(&mi->file);
|
|
|
|
|
my_close(fd, MYF(0));
|
|
|
|
|
pthread_mutex_unlock(&mi->lock);
|
|
|
|
|
return 1;
|
|
|
|
|
msg="Error reading log file name from master info file ";
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*(strend(mi->log_file_name) - 1) = 0; // kill \n
|
|
|
|
|
mi->log_file_name[length]= 0; // kill \n
|
|
|
|
|
char buf[FN_REFLEN];
|
|
|
|
|
if(!my_b_gets(&mi->file, buf, sizeof(buf)))
|
|
|
|
|
{
|
|
|
|
|
sql_print_error("Error reading log file position from master info file");
|
|
|
|
|
end_io_cache(&mi->file);
|
|
|
|
|
my_close(fd, MYF(0));
|
|
|
|
|
pthread_mutex_unlock(&mi->lock);
|
|
|
|
|
return 1;
|
|
|
|
|
msg="Error reading log file position from master info file";
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mi->pos = strtoull(buf,(char**) 0, 10);
|
|
|
|
@ -538,11 +533,8 @@ int init_master_info(MASTER_INFO* mi)
|
|
|
|
|
init_intvar_from_file((int*)&mi->connect_retry, &mi->file,
|
|
|
|
|
master_connect_retry))
|
|
|
|
|
{
|
|
|
|
|
sql_print_error("Error reading master configuration");
|
|
|
|
|
end_io_cache(&mi->file);
|
|
|
|
|
my_close(fd, MYF(0));
|
|
|
|
|
pthread_mutex_unlock(&mi->lock);
|
|
|
|
|
return 1;
|
|
|
|
|
msg="Error reading master configuration";
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -550,15 +542,17 @@ int init_master_info(MASTER_INFO* mi)
|
|
|
|
|
// now change the cache from READ to WRITE - must do this
|
|
|
|
|
// before flush_master_info
|
|
|
|
|
reinit_io_cache(&mi->file, WRITE_CACHE, 0L,0,1);
|
|
|
|
|
if(flush_master_info(mi))
|
|
|
|
|
{
|
|
|
|
|
error=test(flush_master_info(mi));
|
|
|
|
|
pthread_mutex_unlock(&mi->lock);
|
|
|
|
|
return error;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
sql_print_error(msg);
|
|
|
|
|
end_io_cache(&mi->file);
|
|
|
|
|
my_close(fd, MYF(0));
|
|
|
|
|
pthread_mutex_unlock(&mi->lock);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
pthread_mutex_unlock(&mi->lock);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int show_master_info(THD* thd)
|
|
|
|
|
{
|
|
|
|
@ -610,8 +604,8 @@ int flush_master_info(MASTER_INFO* mi)
|
|
|
|
|
|
|
|
|
|
my_b_seek(file, 0L);
|
|
|
|
|
my_b_printf(file, "%s\n%s\n%s\n%s\n%s\n%d\n%d\n",
|
|
|
|
|
mi->log_file_name, llstr(mi->pos, lbuf), mi->host, mi->user, mi->password,
|
|
|
|
|
mi->port, mi->connect_retry);
|
|
|
|
|
mi->log_file_name, llstr(mi->pos, lbuf), mi->host, mi->user,
|
|
|
|
|
mi->password, mi->port, mi->connect_retry);
|
|
|
|
|
flush_io_cache(file);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -619,16 +613,18 @@ int flush_master_info(MASTER_INFO* mi)
|
|
|
|
|
int st_master_info::wait_for_pos(THD* thd, String* log_name, ulong log_pos)
|
|
|
|
|
{
|
|
|
|
|
if (!inited) return -1;
|
|
|
|
|
bool pos_reached = 0;
|
|
|
|
|
bool pos_reached;
|
|
|
|
|
int event_count = 0;
|
|
|
|
|
for(;!pos_reached && !thd->killed;)
|
|
|
|
|
pthread_mutex_lock(&lock);
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
int cmp_result;
|
|
|
|
|
char* basename;
|
|
|
|
|
pthread_mutex_lock(&lock);
|
|
|
|
|
if (*log_file_name)
|
|
|
|
|
{
|
|
|
|
|
basename = strrchr(log_file_name, FN_LIBCHAR);
|
|
|
|
|
/*
|
|
|
|
|
We should use dirname_length() here when we have a version of
|
|
|
|
|
this that doesn't modify the argument */
|
|
|
|
|
char *basename = strrchr(log_file_name, FN_LIBCHAR);
|
|
|
|
|
if (basename)
|
|
|
|
|
++basename;
|
|
|
|
|
else
|
|
|
|
@ -640,20 +636,19 @@ int st_master_info::wait_for_pos(THD* thd, String* log_name, ulong log_pos)
|
|
|
|
|
cmp_result = 0;
|
|
|
|
|
|
|
|
|
|
pos_reached = ((!cmp_result && pos >= log_pos) || cmp_result > 0);
|
|
|
|
|
if(!pos_reached && !thd->killed)
|
|
|
|
|
if (pos_reached || thd->killed)
|
|
|
|
|
break;
|
|
|
|
|
{
|
|
|
|
|
const char* msg = thd->enter_cond(&cond, &lock,
|
|
|
|
|
"Waiting for master update");
|
|
|
|
|
pthread_cond_wait(&cond, &lock);
|
|
|
|
|
thd->exit_cond(msg);
|
|
|
|
|
event_count++;
|
|
|
|
|
pos_reached = (pos >= log_pos);
|
|
|
|
|
}
|
|
|
|
|
} while (!pos_reached && !thd->killed);
|
|
|
|
|
pthread_mutex_unlock(&lock);
|
|
|
|
|
if(thd->killed)
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return event_count;
|
|
|
|
|
return thd->killed ? -1 : event_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -715,12 +710,17 @@ static int safe_sleep(THD* thd, int sec)
|
|
|
|
|
while (start_time < end_time)
|
|
|
|
|
{
|
|
|
|
|
int nap_time = (int) (end_time - start_time);
|
|
|
|
|
thr_alarm(&alarmed, 2 * nap_time,&alarm_buff); // the only reason we are asking for alarm is so that
|
|
|
|
|
// we will be woken up in case of murder, so if we do not get killed, set the alarm
|
|
|
|
|
// so it goes off after we wake up naturally
|
|
|
|
|
/*
|
|
|
|
|
the only reason we are asking for alarm is so that
|
|
|
|
|
we will be woken up in case of murder, so if we do not get killed,
|
|
|
|
|
set the alarm so it goes off after we wake up naturally
|
|
|
|
|
*/
|
|
|
|
|
thr_alarm(&alarmed, 2 * nap_time,&alarm_buff);
|
|
|
|
|
sleep(nap_time);
|
|
|
|
|
if (thr_alarm_in_use(&alarmed)) // if we wake up before the alarm goes off, hit the button
|
|
|
|
|
thr_end_alarm(&alarmed); // so it will not wake up the wife and kids :-)
|
|
|
|
|
// if we wake up before the alarm goes off, hit the button
|
|
|
|
|
// so it will not wake up the wife and kids :-)
|
|
|
|
|
if (thr_alarm_in_use(&alarmed))
|
|
|
|
|
thr_end_alarm(&alarmed);
|
|
|
|
|
|
|
|
|
|
if (slave_killed(thd))
|
|
|
|
|
return 1;
|
|
|
|
@ -742,10 +742,10 @@ static int request_dump(MYSQL* mysql, MASTER_INFO* mi)
|
|
|
|
|
len = (uint) strlen(logname);
|
|
|
|
|
memcpy(buf + 10, logname,len);
|
|
|
|
|
if (mc_simple_command(mysql, COM_BINLOG_DUMP, buf, len + 10, 1))
|
|
|
|
|
{
|
|
|
|
|
// something went wrong, so we will just reconnect and retry later
|
|
|
|
|
// in the future, we should do a better error analysis, but for
|
|
|
|
|
// now we just fill up the error log :-)
|
|
|
|
|
{
|
|
|
|
|
sql_print_error("Error on COM_BINLOG_DUMP: %s, will retry in %d secs",
|
|
|
|
|
mc_mysql_error(mysql), master_connect_retry);
|
|
|
|
|
return 1;
|
|
|
|
@ -786,8 +786,10 @@ command");
|
|
|
|
|
static uint read_event(MYSQL* mysql, MASTER_INFO *mi)
|
|
|
|
|
{
|
|
|
|
|
uint len = packet_error;
|
|
|
|
|
int read_errno = EINTR; // for convinience lets think we start by
|
|
|
|
|
// for convinience lets think we start by
|
|
|
|
|
// being in the interrupted state :-)
|
|
|
|
|
int read_errno = EINTR;
|
|
|
|
|
|
|
|
|
|
// my_real_read() will time us out
|
|
|
|
|
// we check if we were told to die, and if not, try reading again
|
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
@ -795,7 +797,8 @@ static uint read_event(MYSQL* mysql, MASTER_INFO *mi)
|
|
|
|
|
return packet_error;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
while (!abort_loop && !abort_slave && len == packet_error && read_errno == EINTR )
|
|
|
|
|
while (!abort_loop && !abort_slave && len == packet_error &&
|
|
|
|
|
read_errno == EINTR )
|
|
|
|
|
{
|
|
|
|
|
len = mc_net_safe_read(mysql);
|
|
|
|
|
read_errno = errno;
|
|
|
|
@ -820,7 +823,6 @@ server_errno=%d)",
|
|
|
|
|
|
|
|
|
|
DBUG_PRINT("info",( "len=%u, net->read_pos[4] = %d\n",
|
|
|
|
|
len, mysql->net.read_pos[4]));
|
|
|
|
|
|
|
|
|
|
return len - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -848,8 +850,7 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
|
|
|
|
|
thd->set_time(); // time the query
|
|
|
|
|
ev->when = time(NULL);
|
|
|
|
|
|
|
|
|
|
switch(type_code)
|
|
|
|
|
{
|
|
|
|
|
switch(type_code) {
|
|
|
|
|
case QUERY_EVENT:
|
|
|
|
|
{
|
|
|
|
|
Query_log_event* qev = (Query_log_event*)ev;
|
|
|
|
@ -886,8 +887,8 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
|
|
|
|
|
}
|
|
|
|
|
thd->db = 0; // prevent db from being freed
|
|
|
|
|
thd->query = 0; // just to be sure
|
|
|
|
|
thd->convert_set = 0; // assume no convert for next query
|
|
|
|
|
// unless set explictly
|
|
|
|
|
// assume no convert for next query unless set explictly
|
|
|
|
|
thd->convert_set = 0;
|
|
|
|
|
close_thread_tables(thd);
|
|
|
|
|
|
|
|
|
|
if (thd->query_error || thd->fatal_error)
|
|
|
|
@ -989,9 +990,10 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
|
|
|
|
|
net->pkt_nr = thd->net.pkt_nr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // we will just ask the master to send us /dev/null if we do not want to
|
|
|
|
|
// load the data :-)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// we will just ask the master to send us /dev/null if we do not
|
|
|
|
|
// want to load the data :-)
|
|
|
|
|
skip_load_data_infile(net);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1077,7 +1079,6 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -1125,8 +1126,8 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused)))
|
|
|
|
|
bool retried_once = 0;
|
|
|
|
|
ulonglong last_failed_pos = 0;
|
|
|
|
|
|
|
|
|
|
my_thread_init(); // needs to be up here, otherwise we get a coredump
|
|
|
|
|
// trying to use DBUG_ stuff
|
|
|
|
|
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
|
|
|
|
|
my_thread_init();
|
|
|
|
|
thd = new THD; // note that contructor of THD uses DBUG_ !
|
|
|
|
|
thd->set_time();
|
|
|
|
|
DBUG_ENTER("handle_slave");
|
|
|
|
@ -1141,8 +1142,8 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused)))
|
|
|
|
|
DBUG_PRINT("info",("master info: log_file_name=%s, position=%d",
|
|
|
|
|
glob_mi.log_file_name, glob_mi.pos));
|
|
|
|
|
|
|
|
|
|
mysql = mc_mysql_init(NULL);
|
|
|
|
|
if(!mysql)
|
|
|
|
|
|
|
|
|
|
if (!(mysql = mc_mysql_init(NULL)))
|
|
|
|
|
{
|
|
|
|
|
sql_print_error("Slave thread: error in mc_mysql_init()");
|
|
|
|
|
goto err;
|
|
|
|
@ -1255,12 +1256,11 @@ reconnecting to retry, log '%s' position %ld", RPL_LOG_NAME,
|
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stuck_count++;
|
|
|
|
|
// show a little mercy, allow slave to read one more event
|
|
|
|
|
// before cutting him off - otherwise he gets stuck
|
|
|
|
|
// on Invar events, since they do not advance the offset
|
|
|
|
|
// immediately
|
|
|
|
|
if(stuck_count > 2)
|
|
|
|
|
if (++stuck_count > 2)
|
|
|
|
|
events_till_disconnect++;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
@ -1276,10 +1276,7 @@ position %ld",
|
|
|
|
|
RPL_LOG_NAME, glob_mi.pos);
|
|
|
|
|
thd->query = thd->db = 0; // extra safety
|
|
|
|
|
if(mysql)
|
|
|
|
|
{
|
|
|
|
|
mc_mysql_close(mysql);
|
|
|
|
|
mysql = 0;
|
|
|
|
|
}
|
|
|
|
|
thd->proc_info = "waiting for slave mutex on exit";
|
|
|
|
|
pthread_mutex_lock(&LOCK_slave);
|
|
|
|
|
slave_running = 0;
|
|
|
|
@ -1299,8 +1296,10 @@ position %ld",
|
|
|
|
|
DBUG_RETURN(0); // Can't return anything here
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* try to connect until successful or slave killed */
|
|
|
|
|
|
|
|
|
|
static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi)
|
|
|
|
|
// will try to connect until successful or slave killed
|
|
|
|
|
{
|
|
|
|
|
int slave_was_killed;
|
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
@ -1322,13 +1321,14 @@ static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi)
|
|
|
|
|
return slave_was_killed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// will try to connect until successful or slave killed
|
|
|
|
|
/* try to connect until successful or slave killed */
|
|
|
|
|
|
|
|
|
|
static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi)
|
|
|
|
|
{
|
|
|
|
|
int slave_was_killed;
|
|
|
|
|
mi->pending = 0; // if we lost connection after reading a state set event
|
|
|
|
|
// if we lost connection after reading a state set event
|
|
|
|
|
// we will be re-reading it, so pending needs to be cleared
|
|
|
|
|
mi->pending = 0;
|
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
|
events_till_disconnect = disconnect_slave_event_count;
|
|
|
|
|
#endif
|
|
|
|
@ -1354,4 +1354,3 @@ replication resumed in log '%s' at position %ld", glob_mi.user,
|
|
|
|
|
template class I_List_iterator<i_string>;
|
|
|
|
|
template class I_List_iterator<i_string_pair>;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|