summaryrefslogtreecommitdiff
path: root/sql/slave.cc
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-01-28 08:38:28 +0200
committerunknown <monty@mashka.mysql.fi>2003-01-28 08:38:28 +0200
commit8c613c2c9168efa89eefcc82b1271e6731e526a7 (patch)
treeb916d4acfbe4f32ab06b052fd06c072f858bdce1 /sql/slave.cc
parent03d1f3848214a09991f714eb19cfc26512048ed9 (diff)
downloadmariadb-git-8c613c2c9168efa89eefcc82b1271e6731e526a7.tar.gz
Fixes for Netware
Call pthread_mutex_destroy() on not used mutex. Changed comments in .h and .c files from // -> /* */ Added detection of mutex on which one didn't call pthread_mutex_destroy() Fixed bug in create_tmp_field() which causes a memory overrun in queries that uses "ORDER BY constant_expression" Added optimisation for ORDER BY NULL BitKeeper/deleted/.del-ChangeLog~dfc92e15bee6fc75: Delete: sql/ChangeLog BUILD/compile-pentium-valgrind-max: Don't use valgrind with safemalloc as this can hide some bugs Makefile.am: Added platform dirs bdb/os/os_handle.c: Portability fix client/mysql.cc: Fixes for Netware. Fixed duplicate output when using 'tee' Simple optimisations client/mysqldump.c: Portability fix client/mysqltest.c: Portability fix configure.in: Fixes for Netware extra/resolveip.c: Fixes for Netware include/Makefile.am: Fixes for Netware include/config-win.h: Portability fix include/my_global.h: Fixes for Netware include/my_net.h: Fixes for Netware include/my_pthread.h: Fixes for Netware Added detection of mutexes that was not destroyed include/my_sys.h: Fixes for Netware Added 'extern' before external functions include/mysql.h: Fixes for Netware innobase/configure.in: Fixes for Netware innobase/include/os0thread.h: Fixes for Netware innobase/os/os0sync.c: Fixes for Netware innobase/os/os0thread.c: Fixes for Netware innobase/srv/srv0srv.c: Fixes for Netware innobase/srv/srv0start.c: Fixes for Netware innobase/sync/sync0sync.c: Fixes for Netware isam/test3.c: Disable test on Netware libmysql/Makefile.shared: Added my_sleep libmysql/get_password.c: Fixes for Netware libmysql/libmysql.c: Fixes for Netware Made mysql_once_init() global libmysql/manager.c: Fixes for Netware myisam/mi_test3.c: Disable test for netware mysql-test/mysql-test-run.sh: Give warning if output file contains errors mysql-test/r/count_distinct.result: More tests mysql-test/r/group_by.result: Test of ORDER BY NULL mysql-test/t/backup.test: Fixes for Netware mysql-test/t/count_distinct.test: More tests mysql-test/t/func_crypt.test: Fixes for Netware mysql-test/t/grant_cache.test: Fixes for Netware mysql-test/t/group_by.test: Tests of ORDER BY NULL mysql-test/t/rpl000015.test: Fixes for Netware mysql-test/t/rpl000017.test: Fixes for Netware mysql-test/t/rpl_rotate_logs.test: Fixes for Netware mysys/Makefile.am: Added my_sleep.c and my_netware.c mysys/charset.c: Fixes for Netware mysys/default.c: Fixes for Netware mysys/mf_tempfile.c: Fixes for Netware mysys/my_clock.c: Fixes for Netware mysys/my_copy.c: Fixes for Netware mysys/my_getwd.c: Changed function comment from // -> /* */ mysys/my_init.c: Fixes for Netware mysys/my_lock.c: Fixes for Netware mysys/my_messnc.c: Fixes for Netware mysys/my_os2cond.c: Removed comment mysys/my_os2dirsrch.c: Changed function comment from // -> /* */ Fixed indentation mysys/my_os2dirsrch.h: Changed function comment from // -> /* */ Fixed indentation mysys/my_os2file64.c: Changed function comment from // -> /* */ Fixed indentation mysys/my_os2mutex.c: Changed function comment from // -> /* */ Fixed indentation mysys/my_os2thread.c: Changed function comment from // -> /* */ Fixed indentation mysys/my_os2tls.c: Changed function comment from // -> /* */ Fixed indentation mysys/my_pthread.c: Fixes for Netware mysys/my_redel.c: Fixes for Netware mysys/my_tempnam.c: Fixes for Netware mysys/my_thr_init.c: Remove created mutexes when program ends. mysys/mysys_priv.h: Cleanup mysys/safemalloc.c: Prefix error messages with "Error:" mysys/thr_alarm.c: Destroy internal mutex on end_thr_alarm. mysys/thr_mutex.c: Added detection of mutex on which one didn't call pthread_mutex_destroy() scripts/make_binary_distribution.sh: Fixes for Netware sql/des_key_file.cc: Free mutex at end sql/ha_innodb.cc: Free mutex at end sql/ha_myisam.cc: Changed warnings from REPAIR Note: (For mysql-test-run) sql/hostname.cc: Fixes for Netware sql/item.h: Fixed bug in create_tmp_field() which causes a memory overrun sql/item_func.cc: Free used mutexes sql/item_sum.cc: Fixed bug in create_tmp_field() which causes a memory overrun sql/log.cc: Free used mutexes sql/my_lock.c: Fixes for Netware sql/mysql_priv.h: Fixes for Netware sql/mysqld.cc: Fixes for Netware Added Have_crypt Properly free mutexes from MYSQL_LOG by calling cleanup Free mutex before exit sql/repl_failsafe.cc: Fixes for Netware sql/set_var.cc: Added have_crypt sql/share/english/errmsg.txt: Added version socket and port to stderr log sql/slave.cc: Remove global MASTER_INFO variable and use instead an allocated variable. This allows us to correctly free used mutex. sql/slave.h: Move constructors and destuctors to slave.cc (To make it easier to clear all needed variables) sql/sql_base.cc: Safety fix sql/sql_class.h: Portability fixes. Added 'cleanup' to log handling to be able to free mutexes. sql/sql_insert.cc: Fixes for Netware mysys/my_sleep.c: E sql/sql_parse.cc: Fixes for Netware sql/sql_select.cc: Added optimisation for ORDER BY NULL sql/sql_select.h: Fixed bug in create_tmp_field() which causes a memory overrun sql/sql_table.cc: Fixed bug in create_tmp_field() which causes a memory overrun sql/sql_udf.cc: Free mutex on end vio/test-ssl.c: Simple code cleanup vio/test-sslclient.c: Simple code cleanup vio/test-sslserver.c: Simple code cleanup vio/viotest-ssl.c: Simple code cleanup
Diffstat (limited to 'sql/slave.cc')
-rw-r--r--sql/slave.cc108
1 files changed, 81 insertions, 27 deletions
diff --git a/sql/slave.cc b/sql/slave.cc
index 839189956a1..164b8ba458f 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -33,8 +33,7 @@ typedef bool (*CHECK_KILLED_FUNC)(THD*,void*);
volatile bool slave_sql_running = 0, slave_io_running = 0;
char* slave_load_tmpdir = 0;
-MASTER_INFO main_mi;
-MASTER_INFO* active_mi;
+MASTER_INFO *active_mi;
volatile int active_mi_in_use = 0;
HASH replicate_do_table, replicate_ignore_table;
DYNAMIC_ARRAY replicate_wild_do_table, replicate_wild_ignore_table;
@@ -120,18 +119,19 @@ int init_slave()
TODO: re-write this to interate through the list of files
for multi-master
*/
- active_mi = &main_mi;
+ active_mi= new MASTER_INFO;
/*
If master_host is not specified, try to read it from the master_info file.
If master_host is specified, create the master_info file if it doesn't
exists.
*/
- if (init_master_info(active_mi,master_info_file,relay_log_info_file,
+ if (!active_mi ||
+ init_master_info(active_mi,master_info_file,relay_log_info_file,
!master_host))
{
- sql_print_error("Warning: failed to initialized master info");
- DBUG_RETURN(0);
+ sql_print_error("Note: Failed to initialized master info");
+ goto err;
}
/*
@@ -149,9 +149,15 @@ int init_slave()
master_info_file,
relay_log_info_file,
SLAVE_IO | SLAVE_SQL))
+ {
sql_print_error("Warning: Can't create threads to handle slave");
+ goto err;
+ }
}
DBUG_RETURN(0);
+
+err:
+ DBUG_RETURN(1);
}
@@ -755,23 +761,29 @@ static int end_slave_on_walk(MASTER_INFO* mi, gptr /*unused*/)
}
#endif
+
void end_slave()
{
- /*
- TODO: replace the line below with
- list_walk(&master_list, (list_walk_action)end_slave_on_walk,0);
- once multi-master code is ready.
- */
- terminate_slave_threads(active_mi,SLAVE_FORCE_ALL);
- end_master_info(active_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);
+ if (active_mi)
+ {
+ /*
+ TODO: replace the line below with
+ list_walk(&master_list, (list_walk_action)end_slave_on_walk,0);
+ once multi-master code is ready.
+ */
+ terminate_slave_threads(active_mi,SLAVE_FORCE_ALL);
+ end_master_info(active_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);
+ delete active_mi;
+ active_mi= 0;
+ }
}
@@ -1563,6 +1575,42 @@ bool flush_master_info(MASTER_INFO* mi)
DBUG_RETURN(0);
}
+
+st_relay_log_info::st_relay_log_info()
+ :info_fd(-1), cur_log_fd(-1), master_log_pos(0), save_temporary_tables(0),
+ cur_log_old_open_count(0), log_space_total(0),
+ slave_skip_counter(0), abort_pos_wait(0), slave_run_id(0),
+ sql_thd(0), last_slave_errno(0), inited(0), abort_slave(0),
+ slave_running(0), log_pos_current(0), skip_log_purge(0),
+ inside_transaction(0) /* the default is autocommit=1 */
+{
+ relay_log_name[0] = master_log_name[0] = 0;
+ last_slave_error[0]=0;
+
+
+ bzero(&info_file,sizeof(info_file));
+ bzero(&cache_buf, sizeof(cache_buf));
+ pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
+ pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
+ pthread_mutex_init(&log_space_lock, MY_MUTEX_INIT_FAST);
+ pthread_cond_init(&data_cond, NULL);
+ pthread_cond_init(&start_cond, NULL);
+ pthread_cond_init(&stop_cond, NULL);
+ pthread_cond_init(&log_space_cond, NULL);
+}
+
+
+st_relay_log_info::~st_relay_log_info()
+{
+ pthread_mutex_destroy(&run_lock);
+ pthread_mutex_destroy(&data_lock);
+ pthread_mutex_destroy(&log_space_lock);
+ pthread_cond_destroy(&data_cond);
+ pthread_cond_destroy(&start_cond);
+ pthread_cond_destroy(&stop_cond);
+ pthread_cond_destroy(&log_space_cond);
+}
+
/*
Waits until the SQL thread reaches (has executed up to) the
log/position or timed out.
@@ -1755,7 +1803,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
DBUG_RETURN(-1);
}
-#if !defined(__WIN__) && !defined(OS2)
+#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
@@ -2281,14 +2329,16 @@ err:
THD_CHECK_SENTRY(thd);
delete thd;
pthread_mutex_unlock(&LOCK_thread_count);
- my_thread_end(); // clean-up before broadcast
pthread_cond_broadcast(&mi->stop_cond); // tell the world we are done
pthread_mutex_unlock(&mi->run_lock);
#ifndef DBUG_OFF
if (abort_slave_event_count && !events_till_abort)
goto slave_begin;
#endif
+ my_thread_end();
+#ifndef __NETWARE__
pthread_exit(0);
+#endif /* __NETWARE__ */
DBUG_RETURN(0); // Can't return anything here
}
@@ -2420,7 +2470,6 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
THD_CHECK_SENTRY(thd);
delete thd;
pthread_mutex_unlock(&LOCK_thread_count);
- my_thread_end(); // clean-up before broadcasting termination
pthread_cond_broadcast(&rli->stop_cond);
// tell the world we are done
pthread_mutex_unlock(&rli->run_lock);
@@ -2428,10 +2477,14 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
if (abort_slave_event_count && !rli->events_till_abort)
goto slave_begin;
#endif
+ my_thread_end(); // clean-up before broadcasting termination
+#ifndef __NETWARE__
pthread_exit(0);
+#endif /* __NETWARE__ */
DBUG_RETURN(0); // Can't return anything here
}
+
static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev)
{
int error = 1;
@@ -2464,9 +2517,10 @@ static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev)
goto err;
}
- /* this dummy block is so we could instantiate Append_block_log_event
- once and then modify it slightly instead of doing it multiple times
- in the loop
+ /*
+ This dummy block is so we could instantiate Append_block_log_event
+ once and then modify it slightly instead of doing it multiple times
+ in the loop
*/
{
Append_block_log_event aev(thd,0,0,0);