fixed up leaks found by --exit-info=256
better error diagnostic in SLAVE START
This commit is contained in:
parent
b36c387f4f
commit
3cf810222a
@ -386,7 +386,10 @@ my_bool STDCALL mc_mysql_reconnect(MYSQL *mysql)
|
|||||||
if (!mc_mysql_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
|
if (!mc_mysql_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
|
||||||
mysql->db, mysql->port, mysql->unix_socket,
|
mysql->db, mysql->port, mysql->unix_socket,
|
||||||
mysql->client_flag))
|
mysql->client_flag))
|
||||||
DBUG_RETURN(1);
|
{
|
||||||
|
mc_mysql_close(&tmp_mysql);
|
||||||
|
DBUG_RETURN(1);
|
||||||
|
}
|
||||||
tmp_mysql.free_me=mysql->free_me;
|
tmp_mysql.free_me=mysql->free_me;
|
||||||
mysql->free_me=0;
|
mysql->free_me=0;
|
||||||
bzero((char*) &mysql->options,sizeof(&mysql->options));
|
bzero((char*) &mysql->options,sizeof(&mysql->options));
|
||||||
|
@ -614,6 +614,7 @@ void clean_up(void)
|
|||||||
#ifndef __WIN__
|
#ifndef __WIN__
|
||||||
(void) my_delete(pidfile_name,MYF(0)); // This may not always exist
|
(void) my_delete(pidfile_name,MYF(0)); // This may not always exist
|
||||||
#endif
|
#endif
|
||||||
|
end_slave();
|
||||||
my_thread_end();
|
my_thread_end();
|
||||||
|
|
||||||
/* Tell main we are ready */
|
/* Tell main we are ready */
|
||||||
|
45
sql/slave.cc
45
sql/slave.cc
@ -167,6 +167,30 @@ int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_string_array(DYNAMIC_ARRAY *a)
|
||||||
|
{
|
||||||
|
uint i;
|
||||||
|
for(i = 0; i < a->elements; i++)
|
||||||
|
{
|
||||||
|
char* p;
|
||||||
|
get_dynamic(a, (gptr)&p, i);
|
||||||
|
my_free(p, MYF(MY_WME));
|
||||||
|
}
|
||||||
|
delete_dynamic(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void end_slave()
|
||||||
|
{
|
||||||
|
end_master_info(&glob_mi);
|
||||||
|
if(do_table_inited)
|
||||||
|
hash_free(&replicate_do_table);
|
||||||
|
if(ignore_table_inited)
|
||||||
|
hash_free(&replicate_ignore_table);
|
||||||
|
if(wild_do_table_inited)
|
||||||
|
free_string_array(&replicate_wild_do_table);
|
||||||
|
if(wild_ignore_table_inited)
|
||||||
|
free_string_array(&replicate_wild_ignore_table);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool slave_killed(THD* thd)
|
static inline bool slave_killed(THD* thd)
|
||||||
{
|
{
|
||||||
@ -398,8 +422,21 @@ int fetch_nx_table(THD* thd, MASTER_INFO* mi)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void end_master_info(MASTER_INFO* mi)
|
||||||
|
{
|
||||||
|
if(mi->fd >= 0)
|
||||||
|
{
|
||||||
|
end_io_cache(&mi->file);
|
||||||
|
(void)my_close(mi->fd, MYF(MY_WME));
|
||||||
|
mi->fd = -1;
|
||||||
|
}
|
||||||
|
mi->inited = 0;
|
||||||
|
}
|
||||||
|
|
||||||
int init_master_info(MASTER_INFO* mi)
|
int init_master_info(MASTER_INFO* mi)
|
||||||
{
|
{
|
||||||
|
if(mi->inited)
|
||||||
|
return 0;
|
||||||
int fd;
|
int fd;
|
||||||
MY_STAT stat_area;
|
MY_STAT stat_area;
|
||||||
char fname[FN_REFLEN+128];
|
char fname[FN_REFLEN+128];
|
||||||
@ -440,7 +477,7 @@ int init_master_info(MASTER_INFO* mi)
|
|||||||
mi->connect_retry = master_connect_retry;
|
mi->connect_retry = master_connect_retry;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else // file exists
|
||||||
{
|
{
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
reinit_io_cache(&mi->file, READ_CACHE, 0L,0,0);
|
reinit_io_cache(&mi->file, READ_CACHE, 0L,0,0);
|
||||||
@ -897,8 +934,11 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
|
|||||||
sql_print_error("Slave: error '%s' running load data infile ",
|
sql_print_error("Slave: error '%s' running load data infile ",
|
||||||
ER(sql_error));
|
ER(sql_error));
|
||||||
delete ev;
|
delete ev;
|
||||||
|
free_root(&thd->mem_root,0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_root(&thd->mem_root,0);
|
||||||
delete ev;
|
delete ev;
|
||||||
|
|
||||||
if(thd->fatal_error)
|
if(thd->fatal_error)
|
||||||
@ -932,6 +972,7 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
|
|||||||
mi->log_file_name[ident_len] = 0;
|
mi->log_file_name[ident_len] = 0;
|
||||||
mi->pos = 4; // skip magic number
|
mi->pos = 4; // skip magic number
|
||||||
flush_master_info(mi);
|
flush_master_info(mi);
|
||||||
|
delete ev;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -950,6 +991,7 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
|
|||||||
|
|
||||||
}
|
}
|
||||||
mi->inc_pending(event_len);
|
mi->inc_pending(event_len);
|
||||||
|
delete ev;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1157,6 +1199,7 @@ position %ld",
|
|||||||
thd->temporary_tables = 0; // remove tempation from destructor to close them
|
thd->temporary_tables = 0; // remove tempation from destructor to close them
|
||||||
pthread_cond_broadcast(&COND_slave_stopped); // tell the world we are done
|
pthread_cond_broadcast(&COND_slave_stopped); // tell the world we are done
|
||||||
pthread_mutex_unlock(&LOCK_slave);
|
pthread_mutex_unlock(&LOCK_slave);
|
||||||
|
net_end(&thd->net); // destructor will not free it, because we are weird
|
||||||
delete thd;
|
delete thd;
|
||||||
my_thread_end();
|
my_thread_end();
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
|
@ -26,7 +26,6 @@ typedef struct st_master_info
|
|||||||
{
|
{
|
||||||
pthread_mutex_destroy(&lock);
|
pthread_mutex_destroy(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void inc_pending(ulonglong val)
|
inline void inc_pending(ulonglong val)
|
||||||
{
|
{
|
||||||
pending += val;
|
pending += val;
|
||||||
@ -81,7 +80,9 @@ int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec);
|
|||||||
void init_table_rule_hash(HASH* h, bool* h_inited);
|
void init_table_rule_hash(HASH* h, bool* h_inited);
|
||||||
void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited);
|
void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited);
|
||||||
|
|
||||||
|
void end_slave(); // clean up
|
||||||
int init_master_info(MASTER_INFO* mi);
|
int init_master_info(MASTER_INFO* mi);
|
||||||
|
void end_master_info(MASTER_INFO* mi);
|
||||||
extern bool opt_log_slave_updates ;
|
extern bool opt_log_slave_updates ;
|
||||||
pthread_handler_decl(handle_slave,arg);
|
pthread_handler_decl(handle_slave,arg);
|
||||||
extern bool volatile abort_loop, abort_slave;
|
extern bool volatile abort_loop, abort_slave;
|
||||||
|
@ -139,7 +139,7 @@ THD::~THD()
|
|||||||
if (net.vio)
|
if (net.vio)
|
||||||
{
|
{
|
||||||
vio_delete(net.vio);
|
vio_delete(net.vio);
|
||||||
net_end(&net);
|
net_end(&net);
|
||||||
}
|
}
|
||||||
ha_rollback(this);
|
ha_rollback(this);
|
||||||
if (locked_tables)
|
if (locked_tables)
|
||||||
|
@ -503,17 +503,20 @@ int start_slave(THD* thd , bool net_report)
|
|||||||
return 1;
|
return 1;
|
||||||
pthread_mutex_lock(&LOCK_slave);
|
pthread_mutex_lock(&LOCK_slave);
|
||||||
if(!slave_running)
|
if(!slave_running)
|
||||||
if(glob_mi.inited && glob_mi.host && server_id_supplied)
|
{
|
||||||
{
|
if(init_master_info(&glob_mi))
|
||||||
pthread_t hThread;
|
err = "Could not initialize master info";
|
||||||
if(pthread_create(&hThread, &connection_attrib, handle_slave, 0))
|
else if(server_id_supplied && *glob_mi.host)
|
||||||
{
|
{
|
||||||
err = "cannot create slave thread";
|
pthread_t hThread;
|
||||||
}
|
if(pthread_create(&hThread, &connection_attrib, handle_slave, 0))
|
||||||
}
|
{
|
||||||
else
|
err = "cannot create slave thread";
|
||||||
err = "Master host not set, master info not initialized, or server id \
|
}
|
||||||
not configured";
|
}
|
||||||
|
else
|
||||||
|
err = "Master host not set, or server id not configured";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
err = "Slave already running";
|
err = "Slave already running";
|
||||||
|
|
||||||
@ -578,7 +581,7 @@ void reset_slave()
|
|||||||
if(my_stat(fname, &stat_area, MYF(0)))
|
if(my_stat(fname, &stat_area, MYF(0)))
|
||||||
if(my_delete(fname, MYF(MY_WME)))
|
if(my_delete(fname, MYF(MY_WME)))
|
||||||
return;
|
return;
|
||||||
|
end_master_info(&glob_mi);
|
||||||
if(slave_was_running)
|
if(slave_was_running)
|
||||||
start_slave(0,0);
|
start_slave(0,0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user