diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-12-12 18:55:33 -0700 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-12-12 18:55:33 -0700 |
commit | 623eedda2601f083c45a6f4af794e5b4b2703901 (patch) | |
tree | 7eaf5681e41349d3135b099f195338bc5e4b85c9 /sql | |
parent | b9562004e9d8e062790f6346bd8a0439fd5e8822 (diff) | |
download | mariadb-git-623eedda2601f083c45a6f4af794e5b4b2703901.tar.gz |
slave-skip-errors
added extra/mysql_install.c - will work on it in 4.0, but it does not hurt
to have it sit in 3.23 tree for now since it will eventually be backported
to 3.23 anyway
Docs/manual.texi:
documented slave-skip-errors
updated change history
extra/resolve_stack_dump.c:
fixed wrong help message
include/my_bitmap.h:
bitmap code updates
mysql-test/r/rpl_get_lock.result:
test for a possible bug in release_lock() replication
mysql-test/t/rpl_get_lock.test:
test for possible bug in release_lock replication
mysys/my_bitmap.c:
bitmap code updates/clean-up
sql/mysqld.cc:
slave-skip-errors
sql/slave.cc:
slave-skip-errors
sql/slave.h:
slave skip errors
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysqld.cc | 12 | ||||
-rw-r--r-- | sql/slave.cc | 60 | ||||
-rw-r--r-- | sql/slave.h | 4 |
3 files changed, 71 insertions, 5 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 82fc5556bd8..bb6c3c70a27 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -707,6 +707,8 @@ void clean_up(bool print_message) DBUG_PRINT("exit",("clean_up")); if (cleanup_done++) return; /* purecov: inspected */ + if (use_slave_mask) + bitmap_free(&slave_error_mask); acl_free(1); grant_free(); sql_cache_free(); @@ -1757,7 +1759,7 @@ int main(int argc, char **argv) #endif select_thread=pthread_self(); select_thread_in_use=1; - if (use_temp_pool && bitmap_init(&temp_pool,1024)) + if (use_temp_pool && bitmap_init(&temp_pool,1024,1)) unireg_abort(1); /* @@ -2600,7 +2602,8 @@ enum options { OPT_GEMINI_UNBUFFERED_IO, OPT_SKIP_SAFEMALLOC, OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS, OPT_MAX_BINLOG_DUMP_EVENTS, OPT_SPORADIC_BINLOG_DUMP_FAIL, - OPT_SAFE_USER_CREATE, OPT_SQL_MODE + OPT_SAFE_USER_CREATE, OPT_SQL_MODE, + OPT_SLAVE_SKIP_ERRORS }; static struct option long_options[] = { @@ -2735,6 +2738,8 @@ static struct option long_options[] = { {"skip-stack-trace", no_argument, 0, (int) OPT_SKIP_STACK_TRACE}, {"skip-symlink", no_argument, 0, (int) OPT_SKIP_SYMLINKS}, {"skip-thread-priority", no_argument, 0, (int) OPT_SKIP_PRIOR}, + {"slave-skip-errors", required_argument,0, + (int) OPT_SLAVE_SKIP_ERRORS}, {"socket", required_argument, 0, (int) OPT_SOCKET}, {"sql-bin-update-same", no_argument, 0, (int) OPT_SQL_BIN_UPDATE_SAME}, {"sql-mode", required_argument, 0, (int) OPT_SQL_MODE}, @@ -3396,6 +3401,9 @@ static void get_options(int argc,char **argv) case 'P': mysql_port= (unsigned int) atoi(optarg); break; + case OPT_SLAVE_SKIP_ERRORS: + init_slave_skip_errors(optarg); + break; case OPT_SAFEMALLOC_MEM_LIMIT: #if !defined(DBUG_OFF) && defined(SAFEMALLOC) safemalloc_mem_limit = atoi(optarg); diff --git a/sql/slave.cc b/sql/slave.cc index 5fdbab7c7c6..33097bb7df1 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -29,6 +29,8 @@ volatile bool slave_running = 0; pthread_t slave_real_id; MASTER_INFO glob_mi; +MY_BITMAP slave_error_mask; +bool use_slave_mask = 0; 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; @@ -73,6 +75,50 @@ static byte* get_table_key(TABLE_RULE_ENT* e, uint* len, return (byte*)e->db; } +/* called from get_options() in mysqld.cc on start-up */ +void init_slave_skip_errors(char* arg) +{ + char* p,*end; + int err_code = 0; + my_bool last_was_digit = 0; + if (bitmap_init(&slave_error_mask,MAX_SLAVE_ERROR,0)) + { + fprintf(stderr, "Badly out of memory, please check your system status\n"); + exit(1); + } + use_slave_mask = 1; + for (;isspace(*arg);++arg) + /* empty */; + /* force first three chars to lower case */ + for (p = arg, end = arg + 3; *p && p < end; ++p) + *p = tolower(*p); + if (!memcmp(arg,"all",3)) + { + bitmap_set_all(&slave_error_mask); + return; + } + for (p = arg, end = strend(arg); p < end; ++p) + { + int digit = *p - '0'; + if (digit >= 0 && digit < 10) /* found real digit */ + { + err_code = err_code * 10 + digit; + last_was_digit = 1; + } + else /* delimiter */ + { + if (last_was_digit) + { + if (err_code < MAX_SLAVE_ERROR) + { + bitmap_set_bit(&slave_error_mask,err_code); + } + err_code = 0; + last_was_digit = 0; + } + } + } +} void init_table_rule_hash(HASH* h, bool* h_inited) { @@ -869,6 +915,11 @@ point. If you are sure that your master is ok, run this query manually on the\ } } +inline int ignored_error_code(int err_code) +{ + return use_slave_mask && bitmap_is_set(&slave_error_mask, err_code); +} + static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) { Log_event * ev = Log_event::read_log_event((const char*)net->read_pos + 1, @@ -925,11 +976,13 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) // sanity check to make sure the master did not get a really bad // error on the query - if (!check_expected_error(thd, (expected_error = qev->error_code))) + if (ignored_error_code((expected_error=qev->error_code)) || + !check_expected_error(thd, expected_error)) { mysql_parse(thd, thd->query, q_len); if (expected_error != - (actual_error = thd->net.last_errno) && expected_error) + (actual_error = thd->net.last_errno) && expected_error && + !ignored_error_code(actual_error)) { const char* errmsg = "Slave: did not get the expected error\ running query from master - expected: '%s' (%d), got '%s' (%d)"; @@ -939,7 +992,8 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) actual_error); thd->query_error = 1; } - else if (expected_error == actual_error) + else if (expected_error == actual_error || + ignored_error_code(actual_error)) { thd->query_error = 0; *last_slave_error = 0; diff --git a/sql/slave.h b/sql/slave.h index 09887ecd82c..2934e675d56 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -2,8 +2,11 @@ #define SLAVE_H #define SLAVE_NET_TIMEOUT 3600 +#define MAX_SLAVE_ERROR 2000 extern ulong slave_net_timeout, master_retry_count; +extern MY_BITMAP slave_error_mask; +extern bool use_slave_mask; typedef struct st_master_info { @@ -89,6 +92,7 @@ int add_table_rule(HASH* h, const char* table_spec); int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec); void init_table_rule_hash(HASH* h, bool* h_inited); void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited); +void init_slave_skip_errors(char* arg); void end_slave(); // clean up int init_master_info(MASTER_INFO* mi); |