From: Martin Zaun Date: March 27 2012 4:22am Subject: bzr push into mysql-5.5-cluster-7.2 branch (martin.zaun:3866 to 3868) Bug#54854 List-Archive: http://lists.mysql.com/commits/143320 X-Bug: 54854 Message-Id: <201203270422.q2R4MKsZ022268@acsmt356.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3868 Martin Zaun 2012-03-26 [merge] Bug#54854 - merge 3867 Martin Zaun 2012-03-26 [merge] Bug#54854 - merge added: mysql-test/suite/rpl/r/rpl_skip_ddl_errors_cli.result mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli-slave.opt mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.test modified: sql/mysqld.cc sql/slave.cc sql/slave.h 3866 Jonas Oreland 2012-03-24 [merge] ndb - merge 71 to 72 added: storage/ndb/src/ndbjtie/com/mysql/ndbjtie/ndbapi/NDBAPIConst.java modified: sql/ha_ndbcluster.cc storage/ndb/src/ndbjtie/com/mysql/ndbjtie/ndbapi/NDBAPI.java === added file 'mysql-test/suite/rpl/r/rpl_skip_ddl_errors_cli.result' --- a/mysql-test/suite/rpl/r/rpl_skip_ddl_errors_cli.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/rpl/r/rpl_skip_ddl_errors_cli.result 2012-03-26 21:14:41 +0000 @@ -0,0 +1,8 @@ +include/master-slave.inc +[connection master] +Show the effect of the server command line option slave-skip-errors +being passed the alias ignore_ddl_errors and a numeric error code +SHOW VARIABLES LIKE 'slave_skip_errors'; +Variable_name Value +slave_skip_errors 1003,1007,1008,1050,1051,1054,1060,1061,1068,1091,1146 +include/rpl_end.inc === added file 'mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli-slave.opt' --- a/mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli-slave.opt 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli-slave.opt 2012-03-26 21:14:41 +0000 @@ -0,0 +1 @@ +--slave-skip-errors=ddl_exist_errors,1003 === added file 'mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.test' --- a/mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.test 2012-03-26 21:14:41 +0000 @@ -0,0 +1,9 @@ +--source include/master-slave.inc +--source include/have_binlog_format_mixed.inc + +--connection slave +--echo Show the effect of the server command line option slave-skip-errors +--echo being passed the alias ignore_ddl_errors and a numeric error code +SHOW VARIABLES LIKE 'slave_skip_errors'; + +--source include/rpl_end.inc === modified file 'sql/mysqld.cc' --- a/sql/mysqld.cc 2012-02-23 15:41:31 +0000 +++ b/sql/mysqld.cc 2012-03-26 21:14:41 +0000 @@ -4466,6 +4466,12 @@ int mysqld_main(int argc, char **argv) opt_skip_slave_start= 1; binlog_unsafe_map_init(); + +#ifndef MCP_BUG54854 + // Make @@slave_skip_errors show the nice human-readable value. + set_slave_skip_errors(&opt_slave_skip_errors); +#endif // MCP_BUG54854 + /* init_slave() must be called after the thread keys are created. Some parts of the code (e.g. SHOW STATUS LIKE 'slave_running' and other @@ -7286,8 +7292,10 @@ static int get_options(int *argc_ptr, ch flush_time= 0; #ifdef HAVE_REPLICATION +#ifndef MCP_BUG54854 if (opt_slave_skip_errors) - init_slave_skip_errors(opt_slave_skip_errors); + add_slave_skip_errors(opt_slave_skip_errors); +#endif // MCP_BUG54854 #endif if (global_system_variables.max_join_size == HA_POS_ERROR) === modified file 'sql/slave.cc' --- a/sql/slave.cc 2012-02-14 08:00:53 +0000 +++ b/sql/slave.cc 2012-03-26 21:14:41 +0000 @@ -277,15 +277,6 @@ int init_slave() goto err; /* - 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. @@ -397,9 +388,6 @@ static void print_slave_skip_errors(void DBUG_ASSERT(sizeof(slave_skip_error_names) > MIN_ROOM); DBUG_ASSERT(MAX_SLAVE_ERROR <= 999999); // 6 digits - /* Make @@slave_skip_errors show the nice human-readable value. */ - opt_slave_skip_errors= slave_skip_error_names; - if (!use_slave_mask || bitmap_is_clear_all(&slave_error_mask)) { /* purecov: begin tested */ @@ -441,21 +429,29 @@ static void print_slave_skip_errors(void DBUG_VOID_RETURN; } -/* - Init function to set up array for errors that should be skipped for slave - - SYNOPSIS - init_slave_skip_errors() - arg List of errors numbers to skip, separated with ',' - - NOTES - Called from get_options() in mysqld.cc on start-up +#ifndef MCP_BUG54854 +/** + Change arg to the string with the nice, human-readable skip error values. + @param slave_skip_errors_ptr + The pointer to be changed */ +void set_slave_skip_errors(char** slave_skip_errors_ptr) +{ + DBUG_ENTER("set_slave_skip_errors"); + print_slave_skip_errors(); + *slave_skip_errors_ptr= slave_skip_error_names; + DBUG_VOID_RETURN; +} +#endif // MCP_BUG54854 -void init_slave_skip_errors(const char* arg) +#ifndef MCP_BUG54854 +/** + Init function to set up array for errors that should be skipped for slave +*/ +static void init_slave_skip_errors() { - const char *p; DBUG_ENTER("init_slave_skip_errors"); + DBUG_ASSERT(!use_slave_mask); // not already initialized if (bitmap_init(&slave_error_mask,0,MAX_SLAVE_ERROR,0)) { @@ -463,14 +459,90 @@ void init_slave_skip_errors(const char* exit(1); } use_slave_mask = 1; - for (;my_isspace(system_charset_info,*arg);++arg) + DBUG_VOID_RETURN; +} +#endif // MCP_BUG54854 + +#ifndef MCP_BUG54854 +static void add_slave_skip_errors(const uint* errors, uint n_errors) +{ + DBUG_ENTER("add_slave_skip_errors"); + DBUG_ASSERT(errors); + DBUG_ASSERT(use_slave_mask); + + for (uint i = 0; i < n_errors; i++) + { + const uint err_code = errors[i]; + if (err_code < MAX_SLAVE_ERROR) + bitmap_set_bit(&slave_error_mask, err_code); + } + DBUG_VOID_RETURN; +} +#endif // MCP_BUG54854 + +#ifndef MCP_BUG54854 +/* + Add errors that should be skipped for slave + + SYNOPSIS + add_slave_skip_errors() + arg List of errors numbers to be added to skip, separated with ',' + + NOTES + Called from get_options() in mysqld.cc on start-up +*/ + +void add_slave_skip_errors(const char* arg) +{ + const char *p= NULL; + /* + ALL is only valid when nothing else is provided. + */ + const uchar SKIP_ALL[]= "all"; + size_t SIZE_SKIP_ALL= strlen((const char *) SKIP_ALL) + 1; + /* + IGNORE_DDL_ERRORS can be combined with other parameters + but must be the first one provided. + */ + const uchar SKIP_DDL_ERRORS[]= "ddl_exist_errors"; + size_t SIZE_SKIP_DDL_ERRORS= strlen((const char *) SKIP_DDL_ERRORS); + DBUG_ENTER("add_slave_skip_errors"); + + // initialize mask if not done yet + if (!use_slave_mask) + init_slave_skip_errors(); + + for (; my_isspace(system_charset_info,*arg); ++arg) /* empty */; - if (!my_strnncoll(system_charset_info,(uchar*)arg,4,(const uchar*)"all",4)) + if (!my_strnncoll(system_charset_info, (uchar*)arg, SIZE_SKIP_ALL, + SKIP_ALL, SIZE_SKIP_ALL)) { bitmap_set_all(&slave_error_mask); - print_slave_skip_errors(); DBUG_VOID_RETURN; } + if (!my_strnncoll(system_charset_info, (uchar*)arg, SIZE_SKIP_DDL_ERRORS, + SKIP_DDL_ERRORS, SIZE_SKIP_DDL_ERRORS)) + { + // DDL errors to be skipped for relaxed 'exist' handling + const uint ddl_errors[] = { + // error codes with create/add + ER_DB_CREATE_EXISTS, ER_TABLE_EXISTS_ERROR, ER_DUP_KEYNAME, + ER_MULTIPLE_PRI_KEY, + // error codes with change/rename + ER_BAD_FIELD_ERROR, ER_NO_SUCH_TABLE, ER_DUP_FIELDNAME, + // error codes with drop + ER_DB_DROP_EXISTS, ER_BAD_TABLE_ERROR, ER_CANT_DROP_FIELD_OR_KEY + }; + + add_slave_skip_errors(ddl_errors, + sizeof(ddl_errors)/sizeof(ddl_errors[0])); + /* + After processing the SKIP_DDL_ERRORS, the pointer is + increased to the position after the comma. + */ + if (strlen(arg) > SIZE_SKIP_DDL_ERRORS + 1) + arg+= SIZE_SKIP_DDL_ERRORS + 1; + } for (p= arg ; *p; ) { long err_code; @@ -481,10 +553,9 @@ void init_slave_skip_errors(const char* while (!my_isdigit(system_charset_info,*p) && *p) p++; } - /* Convert slave skip errors bitmap into a printable string. */ - print_slave_skip_errors(); DBUG_VOID_RETURN; } +#endif // MCP_BUG54854 static void set_thd_in_use_temporary_tables(Relay_log_info *rli) { === modified file 'sql/slave.h' --- a/sql/slave.h 2011-11-15 13:13:58 +0000 +++ b/sql/slave.h 2012-03-26 21:14:41 +0000 @@ -146,7 +146,10 @@ extern ulonglong relay_log_space_limit; int init_slave(); int init_recovery(Master_info* mi, const char** errmsg); -void init_slave_skip_errors(const char* arg); +#ifndef MCP_BUG54854 +void add_slave_skip_errors(const char* arg); +void set_slave_skip_errors(char** slave_skip_errors_ptr); +#endif // MCP_BUG54854 bool flush_relay_log_info(Relay_log_info* rli); int register_slave_on_master(MYSQL* mysql); int terminate_slave_threads(Master_info* mi, int thread_mask, No bundle (reason: useless for push emails).