diff options
author | unknown <guilhem@mysql.com> | 2004-04-28 18:31:31 +0200 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2004-04-28 18:31:31 +0200 |
commit | b1f590203e45402716cdbdd714ead422f0edcf32 (patch) | |
tree | 1ba76e3faac6e013d2fe70c496a4a10143143004 /sql | |
parent | 7afbb734b7077c1fb9bbb137050c755391b2e79e (diff) | |
parent | 87a93a3195c40e9964da45ae3f1b159640b3b0e3 (diff) | |
download | mariadb-git-b1f590203e45402716cdbdd714ead422f0edcf32.tar.gz |
Merge gbichot@bk-internal.mysql.com:/home/bk/mysql-4.0
into mysql.com:/home/mysql_src/mysql-4.0
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysqld.cc | 18 | ||||
-rw-r--r-- | sql/slave.cc | 35 | ||||
-rw-r--r-- | sql/slave.h | 2 |
3 files changed, 45 insertions, 10 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 671a78f6bfd..1bb76363d38 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2379,6 +2379,15 @@ Warning: you need to use --log-bin to make --log-slave-updates work. \ Now disabling --log-slave-updates."); } + if (opt_log_slave_updates && replicate_same_server_id) + { + sql_print_error("\ +Error: using --replicate-same-server-id in conjunction with \ +--log-slave-updates is impossible, it would lead to infinite loops in this \ +server."); + unireg_abort(1); + } + if (opt_bootstrap) { int error=bootstrap(stdin); @@ -3203,7 +3212,7 @@ enum options_mysqld { OPT_SKIP_SLAVE_START, OPT_SKIP_INNOBASE, OPT_SAFEMALLOC_MEM_LIMIT, OPT_REPLICATE_DO_TABLE, OPT_REPLICATE_IGNORE_TABLE, OPT_REPLICATE_WILD_DO_TABLE, - OPT_REPLICATE_WILD_IGNORE_TABLE, + OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID, OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_ABORT_SLAVE_EVENT_COUNT, OPT_INNODB_DATA_HOME_DIR, @@ -3613,6 +3622,13 @@ Does nothing yet.", {"replicate-rewrite-db", OPT_REPLICATE_REWRITE_DB, "Updates to a database with a different name than the original. Example: replicate-rewrite-db=master_db_name->slave_db_name", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"replicate-same-server-id", OPT_REPLICATE_SAME_SERVER_ID, + "In replication, if set to 1, do not skip events having our server id. \ +Default value is 0 (to break infinite loops in circular replication). \ +Can't be set to 1 if --log-slave-updates is used.", + (gptr*) &replicate_same_server_id, + (gptr*) &replicate_same_server_id, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, // In replication, we may need to tell the other servers how to connect {"report-host", OPT_REPORT_HOST, "Hostname or IP of the slave to be reported to to the master during slave registration. Will appear in the output of SHOW SLAVE HOSTS. Leave unset if you do not want the slave to register itself with the master. Note that it is not sufficient for the master to simply read the IP of the slave off the socket once the slave connects. Due to NAT and other routing issues, that IP may not be valid for connecting to the slave from the master or other hosts.", diff --git a/sql/slave.cc b/sql/slave.cc index 01359265279..1facdd818db 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -38,7 +38,7 @@ HASH replicate_do_table, replicate_ignore_table; DYNAMIC_ARRAY replicate_wild_do_table, replicate_wild_ignore_table; bool do_table_inited = 0, ignore_table_inited = 0; bool wild_do_table_inited = 0, wild_ignore_table_inited = 0; -bool table_rules_on = 0; +bool table_rules_on= 0, replicate_same_server_id; ulonglong relay_log_space_limit = 0; /* @@ -1999,6 +1999,8 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, error= -2; //means improper arguments goto err; } + // Convert 0-3 to 4 + log_pos= max(log_pos, BIN_LOG_HEADER_SIZE); /* p points to '.' */ log_name_extension= strtoul(++p, &p_end, 10); /* @@ -2019,7 +2021,18 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, { bool pos_reached; int cmp_result= 0; - DBUG_ASSERT(*master_log_name || master_log_pos == 0); + /* + master_log_name can be "", if we are just after a fresh replication start + or after a CHANGE MASTER TO MASTER_HOST/PORT (before we have executed one + Rotate event from the master) or (rare) if the user is doing a weird + slave setup (see next paragraph). + If master_log_name is "", we assume we don't have enough info to do the + comparison yet, so we just wait until more data. In this case + master_log_pos is always 0 except if somebody (wrongly) sets this slave + to be a slave of itself without using --replicate-same-server-id (an + unsupported configuration which does nothing), then master_log_pos will + grow and master_log_name will stay "". + */ if (*master_log_name) { char *basename= master_log_name + dirname_length(master_log_name); @@ -2039,14 +2052,15 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, char *q_end; ulong master_log_name_extension= strtoul(q, &q_end, 10); if (master_log_name_extension < log_name_extension) - cmp_result = -1 ; + cmp_result= -1 ; else cmp_result= (master_log_name_extension > log_name_extension) ? 1 : 0 ; + + pos_reached= ((!cmp_result && master_log_pos >= (ulonglong)log_pos) || + cmp_result > 0); + if (pos_reached || thd->killed) + break; } - pos_reached = ((!cmp_result && master_log_pos >= (ulonglong)log_pos) || - cmp_result > 0); - if (pos_reached || thd->killed) - break; //wait for master update, with optional timeout. @@ -2351,7 +2365,12 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) log files themselves. */ - if (ev->server_id == (uint32) ::server_id || + /* + TODO: when this is merged into 4.1, one needs to update queue_event() to + add a similar test for replicate_same_server_id, because in 4.1 the I/O + thread is also filtering events based on the server id. + */ + if ((ev->server_id == (uint32) ::server_id && !replicate_same_server_id) || (rli->slave_skip_counter && type_code != ROTATE_EVENT)) { /* TODO: I/O thread should not even log events with the same server id */ diff --git a/sql/slave.h b/sql/slave.h index 979c63af201..0cd8545338d 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -418,7 +418,7 @@ extern HASH replicate_do_table, replicate_ignore_table; extern DYNAMIC_ARRAY replicate_wild_do_table, replicate_wild_ignore_table; extern bool do_table_inited, ignore_table_inited, wild_do_table_inited, wild_ignore_table_inited; -extern bool table_rules_on; +extern bool table_rules_on, replicate_same_server_id; extern int disconnect_slave_event_count, abort_slave_event_count ; |