diff options
author | Joerg Bruehe <joerg@mysql.com> | 2009-05-08 21:04:07 +0200 |
---|---|---|
committer | Joerg Bruehe <joerg@mysql.com> | 2009-05-08 21:04:07 +0200 |
commit | b2125f3102f506fba9e15acdc30d142be8e22656 (patch) | |
tree | bc4bd9206c7d8ee035e07b31775ceb949164ba93 /sql/slave.cc | |
parent | 2df914157673d19097c9e19979a8ea7d95ec66ef (diff) | |
parent | e3f308a5fe6af267f4eb326fd4e18a2b798c11b5 (diff) | |
download | mariadb-git-b2125f3102f506fba9e15acdc30d142be8e22656.tar.gz |
Merge main 5.1 into 5.1-build
165 changesets with 23 conflicts:
Text conflict in mysql-test/r/lock_multi.result
Text conflict in mysql-test/t/lock_multi.test
Text conflict in mysql-test/t/mysqldump.test
Text conflict in sql/item_strfunc.cc
Text conflict in sql/log.cc
Text conflict in sql/log_event.cc
Text conflict in sql/parse_file.cc
Text conflict in sql/slave.cc
Text conflict in sql/sp.cc
Text conflict in sql/sp_head.cc
Text conflict in sql/sql_acl.cc
Text conflict in sql/sql_base.cc
Text conflict in sql/sql_class.cc
Text conflict in sql/sql_crypt.cc
Text conflict in sql/sql_db.cc
Text conflict in sql/sql_lex.cc
Text conflict in sql/sql_parse.cc
Text conflict in sql/sql_select.cc
Text conflict in sql/sql_table.cc
Text conflict in sql/sql_view.cc
Text conflict in storage/innobase/handler/ha_innodb.cc
Text conflict in storage/myisam/mi_packrec.c
Text conflict in tests/mysql_client_test.c
Updates to Innobase, taken from main 5.1:
bzr: ERROR: Some change isn't sane:
File mysql-test/r/innodb-semi-consistent.result is owned by Innobase and should not be updated.
File mysql-test/t/innodb-semi-consistent.test is owned by Innobase and should not be updated.
File storage/innobase/handler/ha_innodb.cc is owned by Innobase and should not be updated.
File storage/innobase/ibuf/ibuf0ibuf.c is owned by Innobase and should not be updated.
File storage/innobase/include/row0mysql.h is owned by Innobase and should not be updated.
File storage/innobase/include/srv0srv.h is owned by Innobase and should not be updated.
File storage/innobase/include/trx0trx.h is owned by Innobase and should not be updated.
File storage/innobase/include/trx0trx.ic is owned by Innobase and should not be updated.
File storage/innobase/lock/lock0lock.c is owned by Innobase and should not be updated.
File storage/innobase/page/page0cur.c is owned by Innobase and should not be updated.
File storage/innobase/row/row0mysql.c is owned by Innobase and should not be updated.
File storage/innobase/row/row0sel.c is owned by Innobase and should not be updated.
File storage/innobase/srv/srv0srv.c is owned by Innobase and should not be updated.
File storage/innobase/trx/trx0trx.c is owned by Innobase and should not be updated.
(Set env var 'ALLOW_UPDATE_INNOBASE_OWNED' to override.)
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 91 |
1 files changed, 67 insertions, 24 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index 8c29cb8a72f..81c18c5e04b 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -128,6 +128,7 @@ static bool wait_for_relay_log_space(Relay_log_info* rli); static inline bool io_slave_killed(THD* thd,Master_info* mi); static inline bool sql_slave_killed(THD* thd,Relay_log_info* rli); static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type); +static void print_slave_skip_errors(void); static int safe_connect(THD* thd, MYSQL* mysql, Master_info* mi); static int safe_reconnect(THD* thd, MYSQL* mysql, Master_info* mi, bool suppress_warnings); @@ -142,8 +143,8 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi); static Log_event* next_event(Relay_log_info* rli); static int queue_event(Master_info* mi,const char* buf,ulong event_len); static int terminate_slave_thread(THD *thd, - pthread_mutex_t* term_lock, - pthread_cond_t* term_cond, + pthread_mutex_t *term_lock, + pthread_cond_t *term_cond, volatile uint *slave_running, bool skip_lock); static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info); @@ -232,6 +233,15 @@ int init_slave() active_mi= new Master_info; /* + If --slave-skip-errors=... was not used, the string value for the + system variable has not been set up yet. Do it now. + */ + if (!use_slave_mask) + { + print_slave_skip_errors(); + } + + /* 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. @@ -311,7 +321,7 @@ static void print_slave_skip_errors(void) char *bend= buff + sizeof(slave_skip_error_names); int errnum; - for (errnum= 1; errnum < MAX_SLAVE_ERROR; errnum++) + for (errnum= 0; errnum < MAX_SLAVE_ERROR; errnum++) { if (bitmap_is_set(&slave_error_mask, errnum)) { @@ -361,6 +371,7 @@ void init_slave_skip_errors(const char* arg) if (!my_strnncoll(system_charset_info,(uchar*)arg,4,(const uchar*)"all",4)) { bitmap_set_all(&slave_error_mask); + print_slave_skip_errors(); DBUG_VOID_RETURN; } for (p= arg ; *p; ) @@ -388,22 +399,22 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock) int error,force_all = (thread_mask & SLAVE_FORCE_ALL); pthread_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock; - if ((thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL))) + if (thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL)) { DBUG_PRINT("info",("Terminating IO thread")); mi->abort_slave=1; - if ((error=terminate_slave_thread(mi->io_thd,io_lock, + if ((error=terminate_slave_thread(mi->io_thd, io_lock, &mi->stop_cond, &mi->slave_running, skip_lock)) && !force_all) DBUG_RETURN(error); } - if ((thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL))) + if (thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL)) { DBUG_PRINT("info",("Terminating SQL thread")); mi->rli.abort_slave=1; - if ((error=terminate_slave_thread(mi->rli.sql_thd,sql_lock, + if ((error=terminate_slave_thread(mi->rli.sql_thd, sql_lock, &mi->rli.stop_cond, &mi->rli.slave_running, skip_lock)) && @@ -441,29 +452,44 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock) the condition. In this case, it is assumed that the calling function acquires the lock before calling this function. - @retval 0 All OK + @retval 0 All OK ER_SLAVE_NOT_RUNNING otherwise. + + @note If the executing thread has to acquire term_lock (skip_lock + is false), the negative running status does not represent + any issue therefore no error is reported. + */ static int terminate_slave_thread(THD *thd, - pthread_mutex_t* term_lock, - pthread_cond_t* term_cond, + pthread_mutex_t *term_lock, + pthread_cond_t *term_cond, volatile uint *slave_running, bool skip_lock) { - int error; - DBUG_ENTER("terminate_slave_thread"); - if (!skip_lock) + { pthread_mutex_lock(term_lock); - - safe_mutex_assert_owner(term_lock); - + } + else + { + safe_mutex_assert_owner(term_lock); + } if (!*slave_running) { if (!skip_lock) + { + /* + if run_lock (term_lock) is acquired locally then either + slave_running status is fine + */ pthread_mutex_unlock(term_lock); - DBUG_RETURN(ER_SLAVE_NOT_RUNNING); + DBUG_RETURN(0); + } + else + { + DBUG_RETURN(ER_SLAVE_NOT_RUNNING); + } } DBUG_ASSERT(thd != 0); THD_CHECK_SENTRY(thd); @@ -475,6 +501,7 @@ terminate_slave_thread(THD *thd, while (*slave_running) // Should always be true { + int error; DBUG_PRINT("loop", ("killing slave thread")); pthread_mutex_lock(&thd->LOCK_delete); @@ -616,7 +643,7 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start, &mi->rli.slave_running, &mi->rli.slave_run_id, mi, 0); if (error) - terminate_slave_threads(mi, thread_mask & SLAVE_IO, 0); + terminate_slave_threads(mi, thread_mask & SLAVE_IO, !need_slave_mutex); } DBUG_RETURN(error); } @@ -687,6 +714,9 @@ static bool sql_slave_killed(THD* thd, Relay_log_info* rli) DBUG_ASSERT(rli->slave_running == 1);// tracking buffer overrun if (abort_loop || thd->killed || rli->abort_slave) { + if (rli->abort_slave && rli->is_in_group() && + thd->transaction.all.modified_non_trans_table) + DBUG_RETURN(0); /* If we are in an unsafe situation (stopping could corrupt replication), we give one minute to the slave SQL thread of grace before really @@ -2626,6 +2656,7 @@ err: delete the mi structure leading to a crash! (see BUG#25306 for details) */ pthread_cond_broadcast(&mi->stop_cond); // tell the world we are done + DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5);); pthread_mutex_unlock(&mi->run_lock); my_thread_end(); pthread_exit(0); @@ -2713,7 +2744,8 @@ pthread_handler_t handle_slave_sql(void *arg) */ pthread_cond_broadcast(&rli->start_cond); pthread_mutex_unlock(&rli->run_lock); - sql_print_error("Failed during slave thread initialization"); + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + "Failed during slave thread initialization"); goto err; } thd->init_for_queries(); @@ -2757,9 +2789,9 @@ pthread_handler_t handle_slave_sql(void *arg) rli->group_relay_log_pos, 1 /*need data lock*/, &errmsg, 1 /*look for a description_event*/)) - { - sql_print_error("Error initializing relay log position: %s", - errmsg); + { + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + "Error initializing relay log position: %s", errmsg); goto err; } THD_CHECK_SENTRY(thd); @@ -2812,8 +2844,8 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, execute_init_command(thd, &sys_init_slave, &LOCK_sys_init_slave); if (thd->is_slave_error) { - sql_print_error("\ -Slave SQL thread aborted. Can't execute init_slave query"); + rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), + "Slave SQL thread aborted. Can't execute init_slave query"); goto err; } } @@ -2863,10 +2895,20 @@ Slave SQL thread aborted. Can't execute init_slave query"); thd->main_da.sql_errno(), last_errno)); if (last_errno == 0) { + /* + This function is reporting an error which was not reported + while executing exec_relay_log_event(). + */ rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), errmsg); } else if (last_errno != thd->main_da.sql_errno()) { + /* + * An error was reported while executing exec_relay_log_event() + * however the error code differs from what is in the thread. + * This function prints out more information to help finding + * what caused the problem. + */ sql_print_error("Slave (additional info): %s Error_code: %d", errmsg, thd->main_da.sql_errno()); } @@ -2964,6 +3006,7 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ delete the mi structure leading to a crash! (see BUG#25306 for details) */ pthread_cond_broadcast(&rli->stop_cond); + DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5);); pthread_mutex_unlock(&rli->run_lock); // tell the world we are done my_thread_end(); |