diff options
author | unknown <monty@narttu.mysql.fi> | 2003-08-29 13:44:35 +0300 |
---|---|---|
committer | unknown <monty@narttu.mysql.fi> | 2003-08-29 13:44:35 +0300 |
commit | 0fa5279543d20c0d0c9ef6a1835c7f5056f0a997 (patch) | |
tree | aeb2314adbd714c7e2b032209bfd7914e3cfda3d /sql/slave.cc | |
parent | fb3ab3c855fa8f154d1f018bb6eea155614289c9 (diff) | |
parent | f2adc9f3dd62a9f1f7493d8401542bc8a007fe47 (diff) | |
download | mariadb-git-0fa5279543d20c0d0c9ef6a1835c7f5056f0a997.tar.gz |
merge with 4.0.15
BitKeeper/etc/ignore:
auto-union
BitKeeper/etc/logging_ok:
auto-union
BitKeeper/deleted/.del-database.c~af098622e818ce0d:
Auto merged
BitKeeper/deleted/.del-have_openssl_2.inc~8c9f1a45676b698f:
Auto merged
BitKeeper/deleted/.del-have_openssl_2.require~53bbdfc136fb514:
Auto merged
BitKeeper/deleted/.del-mini_client.cc~8677895ec8169183:
Auto merged
BitKeeper/deleted/.del-openssl_2.test~f2dfa927f19d14f8:
Auto merged
Build-tools/Bootstrap:
Auto merged
Build-tools/Do-compile:
Auto merged
SSL/cacert.pem:
Auto merged
acconfig.h:
Auto merged
acinclude.m4:
Auto merged
configure.in:
Auto merged
SSL/client-cert.pem:
Auto merged
SSL/client-key.pem:
Auto merged
SSL/server-cert.pem:
Auto merged
SSL/server-key.pem:
Auto merged
VC++Files/client/mysql.dsp:
Auto merged
VC++Files/client/mysqladmin.dsp:
Auto merged
VC++Files/client/mysqlclient.dsp:
Auto merged
VC++Files/client/mysqldump.dsp:
Auto merged
VC++Files/client/mysqlimport.dsp:
Auto merged
VC++Files/client/mysqlshow.dsp:
Auto merged
VC++Files/comp_err/comp_err.dsp:
Auto merged
VC++Files/innobase/innobase.dsp:
Auto merged
VC++Files/isamchk/isamchk.dsp:
Auto merged
VC++Files/libmysql/libmysql.dsp:
Auto merged
VC++Files/libmysqltest/myTest.dsp:
Auto merged
VC++Files/my_print_defaults/my_print_defaults.dsp:
Auto merged
VC++Files/myisamlog/myisamlog.dsp:
Auto merged
VC++Files/mysql.dsw:
Auto merged
VC++Files/mysqlbinlog/mysqlbinlog.dsp:
Auto merged
VC++Files/mysqlcheck/mysqlcheck.dsp:
Auto merged
VC++Files/mysqlmanager/MySqlManager.dsp:
Auto merged
VC++Files/mysqlserver/mysqlserver.dsp:
Auto merged
VC++Files/mysqlshutdown/mysqlshutdown.dsp:
Auto merged
VC++Files/mysys/mysys.dsp:
Auto merged
VC++Files/pack_isam/pack_isam.dsp:
Auto merged
VC++Files/perror/perror.dsp:
Auto merged
VC++Files/replace/replace.dsp:
Auto merged
VC++Files/test1/test1.dsp:
Auto merged
VC++Files/thr_test/thr_test.dsp:
Auto merged
VC++Files/vio/vio.dsp:
Auto merged
VC++Files/zlib/zlib.dsp:
Auto merged
client/mysqlbinlog.cc:
Auto merged
client/mysqldump.c:
Auto merged
client/mysqlimport.c:
Auto merged
extra/my_print_defaults.c:
Auto merged
extra/resolveip.c:
Auto merged
include/m_string.h:
Auto merged
include/my_sys.h:
Auto merged
include/mysql_com.h:
Auto merged
innobase/dict/dict0dict.c:
Auto merged
innobase/os/os0file.c:
Auto merged
isam/_search.c:
Auto merged
libmysql/Makefile.am:
Auto merged
libmysql/errmsg.c:
Auto merged
libmysql/libmysql.c:
Auto merged
myisam/mi_check.c:
Auto merged
myisam/mi_create.c:
Auto merged
myisam/mi_open.c:
Auto merged
myisam/mi_search.c:
Auto merged
myisam/mi_write.c:
Auto merged
myisam/myisamchk.c:
Auto merged
myisam/myisamlog.c:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
mysql-test/r/group_by.result:
Auto merged
mysql-test/r/isam.result:
Auto merged
mysql-test/r/loaddata.result:
Auto merged
mysql-test/r/lowercase_table.result:
Auto merged
mysql-test/r/multi_update.result:
Auto merged
mysql-test/r/openssl_1.result:
Auto merged
mysql-test/r/packet.result:
Auto merged
mysql-test/r/query_cache.result:
Auto merged
mysql-test/r/range.result:
Auto merged
mysql-test/r/select_safe.result:
Auto merged
mysql-test/r/show_check.result:
Auto merged
mysql-test/t/grant.test:
Auto merged
mysql-test/t/group_by.test:
Auto merged
mysql-test/t/lock_tables_lost_commit-master.opt:
Auto merged
mysql-test/t/lowercase_table.test:
Auto merged
mysql-test/t/multi_update.test:
Auto merged
mysql-test/t/openssl_1.test:
Auto merged
mysql-test/t/range.test:
Auto merged
mysql-test/t/rpl_loaddata.test:
Auto merged
mysql-test/t/rpl_log.test:
Auto merged
mysql-test/t/select_safe.test:
Auto merged
mysql-test/t/show_check.test:
Auto merged
mysql-test/t/symlink.test:
Auto merged
mysys/default.c:
Auto merged
mysys/my_getopt.c:
Auto merged
mysys/my_pthread.c:
Auto merged
scripts/make_binary_distribution.sh:
Auto merged
scripts/make_win_src_distribution.sh:
Auto merged
scripts/mysql_install_db.sh:
Auto merged
scripts/mysqld_safe.sh:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/ha_myisam.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/item_uniq.h:
Auto merged
sql/log_event.h:
Auto merged
sql/net_serv.cc:
Auto merged
sql/repl_failsafe.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_load.cc:
Auto merged
sql/sql_repl.cc:
Auto merged
sql/sql_update.cc:
Auto merged
vio/Makefile.am:
Auto merged
vio/vio.c:
Auto merged
mysql-test/t/myisam.test:
merge with 4.0.15
Extra tests
mysys/mf_keycache.c:
Keep local file
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index d5da8325c93..9e03856e284 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1505,11 +1505,10 @@ static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli) DBUG_ENTER("wait_for_relay_log_space"); pthread_mutex_lock(&rli->log_space_lock); - save_proc_info = thd->proc_info; - thd->proc_info = "Waiting for relay log space to free"; save_proc_info= thd->enter_cond(&rli->log_space_cond, &rli->log_space_lock, - "Waiting for relay log space to free"); + "\ +Waiting for the SQL slave thread to free enough relay log space"); while (rli->log_space_limit < rli->log_space_total && !(slave_killed=io_slave_killed(thd,mi)) && !rli->ignore_log_space_limit) @@ -2058,7 +2057,8 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, DBUG_PRINT("info",("Waiting for master update")); const char* msg = thd->enter_cond(&data_cond, &data_lock, - "Waiting for master update"); + "Waiting for the SQL slave thread to \ +advance position"); /* We are going to pthread_cond_(timed)wait(); if the SQL thread stops it will wake us up. @@ -2125,7 +2125,13 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->master_access= ~0; thd->priv_user = 0; thd->slave_thread = 1; - thd->options = (((opt_log_slave_updates) ? OPTION_BIN_LOG:0) | OPTION_AUTO_IS_NULL) ; + thd->options = ((opt_log_slave_updates) ? OPTION_BIN_LOG:0) | + OPTION_AUTO_IS_NULL; + /* + It's nonsense to constraint the slave threads with max_join_size; if a + query succeeded on master, we HAVE to execute it. + */ + thd->variables.max_join_size= HA_POS_ERROR; thd->client_capabilities = CLIENT_LOCAL_FILES; thd->real_id=pthread_self(); pthread_mutex_lock(&LOCK_thread_count); @@ -2145,11 +2151,8 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); #endif - if (thd->variables.max_join_size == HA_POS_ERROR) - thd->options |= OPTION_BIG_SELECTS; - if (thd_type == SLAVE_THD_SQL) - thd->proc_info= "Waiting for the next event in slave queue"; + thd->proc_info= "Waiting for the next event in relay log"; else thd->proc_info= "Waiting for master update"; thd->version=refresh_version; @@ -2390,7 +2393,6 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) if (!ev->when) ev->when = time(NULL); ev->thd = thd; - thd->log_pos = ev->log_pos; exec_res = ev->exec_event(rli); DBUG_ASSERT(rli->sql_thd==thd); delete ev; @@ -2398,7 +2400,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) } else { - sql_print_error("\ + slave_print_error(rli, 0, "\ Could not parse relay log event entry. The possible reasons are: the master's \ binary log is corrupted (you can check this by running 'mysqlbinlog' on the \ binary log), the slave's relay log is corrupted (you can check this by running \ @@ -2473,7 +2475,7 @@ slave_begin: } - thd->proc_info = "connecting to master"; + thd->proc_info = "Connecting to master"; // we can get killed during safe_connect if (!safe_connect(thd, mysql, mi)) sql_print_error("Slave I/O thread: connected to master '%s@%s:%d',\ @@ -2520,7 +2522,7 @@ dump"); goto err; } - thd->proc_info = "Waiting to reconnect after a failed dump request"; + thd->proc_info= "Waiting to reconnect after a failed binlog dump request"; end_server(mysql); /* First time retry immediately, assuming that we can recover @@ -2541,7 +2543,7 @@ dump"); goto err; } - thd->proc_info = "Reconnecting after a failed dump request"; + thd->proc_info = "Reconnecting after a failed binlog dump request"; if (!suppress_warnings) sql_print_error("Slave I/O thread: failed dump request, \ reconnecting to try again, log '%s' at postion %s", IO_RPL_LOG_NAME, @@ -2560,7 +2562,13 @@ after reconnect"); while (!io_slave_killed(thd,mi)) { bool suppress_warnings= 0; - thd->proc_info = "Reading master update"; + /* + We say "waiting" because read_event() will wait if there's nothing to + read. But if there's something to read, it will not wait. The important + thing is to not confuse users by saying "reading" whereas we're in fact + receiving nothing. + */ + thd->proc_info = "Waiting for master to send event"; ulong event_len = read_event(mysql, mi, &suppress_warnings); if (io_slave_killed(thd,mi)) { @@ -2587,7 +2595,7 @@ max_allowed_packet", mysql_error(mysql)); goto err; } - thd->proc_info = "Waiting to reconnect after a failed read"; + thd->proc_info = "Waiting to reconnect after a failed master event read"; end_server(mysql); if (retry_count++) { @@ -2603,7 +2611,7 @@ max_allowed_packet", reconnect after a failed read"); goto err; } - thd->proc_info = "Reconnecting after a failed read"; + thd->proc_info = "Reconnecting after a failed master event read"; if (!suppress_warnings) sql_print_error("Slave I/O thread: Failed reading log event, \ reconnecting to retry, log '%s' position %s", IO_RPL_LOG_NAME, @@ -2620,7 +2628,7 @@ reconnect done to recover from failed read"); } // if (event_len == packet_error) retry_count=0; // ok event, reset retry counter - thd->proc_info = "Queueing event from master"; + thd->proc_info = "Queueing master event to the relay log"; if (queue_event(mi,(const char*)mysql->net.read_pos + 1, event_len)) { @@ -2802,7 +2810,7 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, while (!sql_slave_killed(thd,rli)) { - thd->proc_info = "Processing master log event"; + thd->proc_info = "Reading event from the relay log"; DBUG_ASSERT(rli->sql_thd == thd); THD_CHECK_SENTRY(thd); if (exec_relay_log_event(thd,rli)) @@ -2834,6 +2842,12 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ DBUG_ASSERT(rli->slave_running == 1); // tracking buffer overrun /* When master_pos_wait() wakes up it will check this and terminate */ rli->slave_running= 0; + /* + Going out of the transaction. Necessary to mark it, in case the user + restarts replication from a non-transactional statement (with CHANGE + MASTER). + */ + rli->inside_transaction= 0; /* Wake up master_pos_wait() */ pthread_mutex_unlock(&rli->data_lock); DBUG_PRINT("info",("Signaling possibly waiting master_pos_wait() functions")); @@ -2909,7 +2923,7 @@ static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev) in the loop */ { - Append_block_log_event aev(thd,0,0,0); + Append_block_log_event aev(thd,0,0,0,0); for (;;) { @@ -2922,7 +2936,7 @@ static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev) if (unlikely(!num_bytes)) /* eof */ { net_write_command(net, 0, "", 0, "", 0);/* 3.23 master wants it */ - Execute_load_log_event xev(thd,0); + Execute_load_log_event xev(thd,0,0); xev.log_pos = mi->master_log_pos; if (unlikely(mi->rli.relay_log.append(&xev))) { @@ -3049,6 +3063,12 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf, tmp_buf[event_len]=0; // Create_file constructor wants null-term buffer buf = (const char*)tmp_buf; } + /* + This will transform LOAD_EVENT into CREATE_FILE_EVENT, ask the master to + send the loaded file, and write it to the relay log in the form of + Append_block/Exec_load (the SQL thread needs the data, as that thread is not + connected to the master). + */ Log_event *ev = Log_event::read_log_event(buf,event_len, &errmsg, 1 /*old format*/ ); if (unlikely(!ev)) @@ -3076,6 +3096,12 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf, inc_pos= 0; break; case CREATE_FILE_EVENT: + /* + Yes it's possible to have CREATE_FILE_EVENT here, even if we're in + queue_old_event() which is for 3.23 events which don't comprise + CREATE_FILE_EVENT. This is because read_log_event() above has just + transformed LOAD_EVENT into CREATE_FILE_EVENT. + */ { /* We come here when and only when tmp_buf != 0 */ DBUG_ASSERT(tmp_buf); @@ -3575,7 +3601,7 @@ Before assert, my_b_tell(cur_log)=%s rli->event_relay_log_pos=%s", pthread_mutex_unlock(&rli->log_space_lock); pthread_cond_broadcast(&rli->log_space_cond); // Note that wait_for_update unlocks lock_log ! - rli->relay_log.wait_for_update(rli->sql_thd); + rli->relay_log.wait_for_update(rli->sql_thd, 1); // re-acquire data lock since we released it earlier pthread_mutex_lock(&rli->data_lock); continue; |