diff options
author | unknown <monty@hundin.mysql.fi> | 2001-10-04 02:44:54 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-10-04 02:44:54 +0300 |
commit | aff3b0e4ad4856fd164635e941e7aa349588e5bf (patch) | |
tree | ec42ac21b69541229e7157ba8c4b6cf516903cc4 /sql | |
parent | b39f54aafb57d26b3f971fc2f9fed0365dc0d743 (diff) | |
parent | 83fa1116792e55ddb9dc57276b689a97e6ab8f74 (diff) | |
download | mariadb-git-aff3b0e4ad4856fd164635e941e7aa349588e5bf.tar.gz |
Merge work:/home/bk/mysql-4.0 into hundin.mysql.fi:/my/bk/mysql-4.0
Docs/manual.texi:
Auto merged
Build-tools/Do-compile:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
sql/mysqld.cc:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysqld.cc | 13 | ||||
-rw-r--r-- | sql/slave.cc | 47 | ||||
-rw-r--r-- | sql/slave.h | 2 |
3 files changed, 39 insertions, 23 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b8e8c80d100..a4421bc139c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -286,7 +286,7 @@ uint master_port = MYSQL_PORT, master_connect_retry = 60; uint report_port = MYSQL_PORT; bool master_ssl = 0; -ulong max_tmp_tables,max_heap_table_size; +ulong max_tmp_tables,max_heap_table_size,master_retry_count=0; ulong bytes_sent = 0L, bytes_received = 0L; bool opt_endinfo,using_udf_functions,low_priority_updates, locked_in_memory; @@ -2573,10 +2573,9 @@ enum options { OPT_MASTER_HOST, OPT_MASTER_USER, OPT_MASTER_PASSWORD, OPT_MASTER_PORT, OPT_MASTER_INFO_FILE, OPT_MASTER_CONNECT_RETRY, -#ifdef HAVE_OPENSSL + OPT_MASTER_RETRY_COUNT, OPT_MASTER_SSL, OPT_MASTER_SSL_KEY, OPT_MASTER_SSL_CERT, -#endif /* HAVE_OPESSSL*/ OPT_SQL_BIN_UPDATE_SAME, OPT_REPLICATE_DO_DB, OPT_REPLICATE_IGNORE_DB, OPT_LOG_SLAVE_UPDATES, OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB, @@ -2683,12 +2682,11 @@ static struct option long_options[] = { {"master-password", required_argument, 0, (int) OPT_MASTER_PASSWORD}, {"master-port", required_argument, 0, (int) OPT_MASTER_PORT}, {"master-connect-retry", required_argument, 0, (int) OPT_MASTER_CONNECT_RETRY}, + {"master-retry-count", required_argument, 0, (int) OPT_MASTER_RETRY_COUNT}, {"master-info-file", required_argument, 0, (int) OPT_MASTER_INFO_FILE}, -#ifdef HAVE_OPENSSL {"master-ssl", optional_argument, 0, (int) OPT_MASTER_SSL}, {"master-ssl-key", optional_argument, 0, (int) OPT_MASTER_SSL_KEY}, {"master-ssl-cert", optional_argument, 0, (int) OPT_MASTER_SSL_CERT}, -#endif {"myisam-recover", optional_argument, 0, (int) OPT_MYISAM_RECOVER}, {"memlock", no_argument, 0, (int) OPT_MEMLOCK}, // needs to be available for the test case to pass in non-debugging mode @@ -3972,7 +3970,6 @@ static void get_options(int argc,char **argv) case OPT_MASTER_PORT: master_port= atoi(optarg); break; -#ifdef HAVE_OPENSSL case OPT_MASTER_SSL: master_ssl=atoi(optarg); break; @@ -3982,7 +3979,6 @@ static void get_options(int argc,char **argv) case OPT_MASTER_SSL_CERT: master_ssl_cert=optarg; break; -#endif /* HAVE_OPENSSL */ case OPT_REPORT_HOST: report_host=optarg; break; @@ -3998,6 +3994,9 @@ static void get_options(int argc,char **argv) case OPT_MASTER_CONNECT_RETRY: master_connect_retry= atoi(optarg); break; + case OPT_MASTER_RETRY_COUNT: + master_retry_count= atoi(optarg); + break; case OPT_SAFE_SHOW_DB: opt_safe_show_db=1; break; diff --git a/sql/slave.cc b/sql/slave.cc index 01938a52153..23475f3b1e8 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -522,7 +522,7 @@ int init_master_info(MASTER_INFO* mi) if (master_user) strmake(mi->user, master_user, sizeof(mi->user) - 1); if (master_password) - strmake(mi->password, master_password, sizeof(mi->password) - 1); + strmake(mi->password, master_password, HASH_PASSWORD_LENGTH); mi->port = master_port; mi->connect_retry = master_connect_retry; } @@ -561,7 +561,7 @@ int init_master_info(MASTER_INFO* mi) master_host) || init_strvar_from_file(mi->user, sizeof(mi->user), &mi->file, master_user) || - init_strvar_from_file(mi->password, sizeof(mi->password), &mi->file, + init_strvar_from_file(mi->password, HASH_PASSWORD_LENGTH+1, &mi->file, master_password) || init_intvar_from_file((int*)&mi->port, &mi->file, master_port) || init_intvar_from_file((int*)&mi->connect_retry, &mi->file, @@ -1250,7 +1250,7 @@ static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi) !mc_mysql_connect(mysql, mi->host, mi->user, mi->password, 0, mi->port, 0, 0)) { - sql_print_error("Slave thread: error connecting to master:%s(%d),\ + sql_print_error("Slave thread: error connecting to master: %s (%d),\ retry in %d sec", mc_mysql_error(mysql), errno, mi->connect_retry); safe_sleep(thd, mi->connect_retry); } @@ -1267,38 +1267,55 @@ static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi) return slave_was_killed; } -/* try to connect until successful or slave killed */ +/* + Try to connect until successful or slave killed or we have retried + master_retry_count times +*/ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi) { int slave_was_killed; + int last_errno= -2; // impossible error + ulong err_count=0; char llbuff[22]; - // if we lost connection after reading a state set event - // we will be re-reading it, so pending needs to be cleared + /* + 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 - while(!(slave_was_killed = slave_killed(thd)) && mc_mysql_reconnect(mysql)) + while (!(slave_was_killed = slave_killed(thd)) && mc_mysql_reconnect(mysql)) { - sql_print_error("Slave thread: error re-connecting to master:\ + /* Don't repeat last error */ + if (mc_mysql_errno(mysql) != last_errno) + { + sql_print_error("Slave thread: error re-connecting to master: \ %s, last_errno=%d, retry in %d sec", - mc_mysql_error(mysql), errno, mi->connect_retry); - safe_sleep(thd, mi->connect_retry); + mc_mysql_error(mysql), last_errno=mc_mysql_errno(mysql), + mi->connect_retry); + safe_sleep(thd, mi->connect_retry); + } + if (err_count++ == master_retry_count) + { + slave_was_killed=1; + break; + } } - if(!slave_was_killed) - { - sql_print_error("Slave: reconnected to master '%s@%s:%d',\ + if (!slave_was_killed) + { + sql_print_error("Slave: reconnected to master '%s@%s:%d',\ replication resumed in log '%s' at position %s", glob_mi.user, glob_mi.host, glob_mi.port, RPL_LOG_NAME, llstr(glob_mi.pos,llbuff)); #ifdef SIGNAL_WITH_VIO_CLOSE - thd->set_active_vio(mysql->net.vio); + thd->set_active_vio(mysql->net.vio); #endif - } + } return slave_was_killed; } diff --git a/sql/slave.h b/sql/slave.h index 5850b57d3b3..5c6772147b6 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -4,7 +4,7 @@ #include "mysql.h" #define SLAVE_NET_TIMEOUT 3600 -extern ulong slave_net_timeout; +extern ulong slave_net_timeout, master_retry_count; extern char* slave_load_tmpdir; typedef struct st_master_info |