From: Andrei Elkin Date: March 28 2011 1:19pm Subject: bzr commit into mysql-trunk branch (andrei.elkin:3312) Bug#11748510 List-Archive: http://lists.mysql.com/commits/134051 X-Bug: 11748510 Message-Id: <201103281319.p2SDJHi3005539@mysql1000.dsl.inet.fi> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2014970244==" --===============2014970244== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/andrei/MySQL/BZR/2a-23May/FIXES/bug11748510_36524_less_drama/ based on revid:andrei.elkin@stripped 3312 Andrei Elkin 2011-03-28 bug#11748510 post-review cleanup patch to relocate has_temporary_error() into Slave_reporting_capability class. @ sql/rpl_reporting.cc the func is moved from rpl_slave.cc to be converted into a method. @ sql/rpl_reporting.h a new member is arrived. #if !defined(EMBEDDED_LIBRARY) is a work-around of a wrong choice for rpl_reporting to be compiled in embedded built in the first place. A memo to reshape dependencies for embedded is left. @ sql/rpl_slave.cc moved into rpl_reporting. @ sql/rpl_slave.h has_temporary_error() is turned into Slave_reporting_capability::has_temporary_error modified: sql/rpl_reporting.cc sql/rpl_reporting.h sql/rpl_slave.cc sql/rpl_slave.h === modified file 'sql/rpl_reporting.cc' --- a/sql/rpl_reporting.cc 2011-03-27 18:16:32 +0000 +++ b/sql/rpl_reporting.cc 2011-03-28 13:19:08 +0000 @@ -26,6 +26,79 @@ Slave_reporting_capability::Slave_report &err_lock, MY_MUTEX_INIT_FAST); } +#if !defined(EMBEDDED_LIBRARY) +/** + Check if the current error is of temporary nature or not. + Some errors are temporary in nature, such as + ER_LOCK_DEADLOCK and ER_LOCK_WAIT_TIMEOUT. Ndb also signals + that the error is temporary by pushing a warning with the error code + ER_GET_TEMPORARY_ERRMSG, if the originating error is temporary. + + @param thd a THD instance, typically of the slave SQL thread's. + @error_arg the error code for assessment. + defaults to zero which makes the function check the top + of the reported errors stack. + + @return 1 as the positive and 0 as the negative verdict +*/ +int Slave_reporting_capability::has_temporary_error(THD *thd, uint error_arg) const +{ + uint error; + DBUG_ENTER("has_temporary_error"); + + DBUG_EXECUTE_IF("all_errors_are_temporary_errors", + if (thd->stmt_da->is_error()) + { + thd->clear_error(); + my_error(ER_LOCK_DEADLOCK, MYF(0)); + }); + + /* + The state of the slave thread can't be regarded as + experiencing a temporary failure in cases of @c is_slave_error was set TRUE, + or if there is no message in THD, we can't say if it's a temporary + error or not. This is currently the case for Incident_log_event, + which sets no message. + */ + if (thd->is_fatal_error || !thd->is_error()) + DBUG_RETURN(0); + + error= (error_arg == 0)? thd->stmt_da->sql_errno() : error_arg; + + /* + Temporary error codes: + currently, InnoDB deadlock detected by InnoDB or lock + wait timeout (innodb_lock_wait_timeout exceeded). + Notice, the temporary error requires slave_trans_retries != 0) + */ + if (slave_trans_retries && + (error == ER_LOCK_DEADLOCK || error == ER_LOCK_WAIT_TIMEOUT)) + DBUG_RETURN(1); + +#ifdef HAVE_NDB_BINLOG + /* + currently temporary error set in ndbcluster + */ + List_iterator_fast it(thd->warning_info->warn_list()); + MYSQL_ERROR *err; + while ((err= it++)) + { + DBUG_PRINT("info", ("has condition %d %s", err->get_sql_errno(), + err->get_message_text())); + switch (err->get_sql_errno()) + { + case ER_GET_TEMPORARY_ERRMSG: + DBUG_RETURN(1); + default: + break; + } + } +#endif + DBUG_RETURN(0); +} +#endif // EMBEDDED_LIBRARY + + void Slave_reporting_capability::report(loglevel level, int err_code, const char *msg, ...) const === modified file 'sql/rpl_reporting.h' --- a/sql/rpl_reporting.h 2010-08-05 17:45:25 +0000 +++ b/sql/rpl_reporting.h 2011-03-28 13:19:08 +0000 @@ -23,6 +23,11 @@ */ #define MAX_SLAVE_ERRMSG 1024 +// todo: consider to remove rpl_reporting.cc,h from building embedded +#if !defined(EMBEDDED_LIBRARY) +class THD; +#endif + /** Mix-in to handle the message logging and reporting for relay log info and master log info structures. @@ -65,6 +70,13 @@ public: mysql_mutex_unlock(&err_lock); } +#if !defined(EMBEDDED_LIBRARY) + /** + Check if the current error is of temporary nature or not. + */ + int has_temporary_error(THD *thd, uint error_arg= 0) const; +#endif // EMBEDDED_LIBRARY + /** Error information structure. */ === modified file 'sql/rpl_slave.cc' --- a/sql/rpl_slave.cc 2011-03-27 18:16:32 +0000 +++ b/sql/rpl_slave.cc 2011-03-28 13:19:08 +0000 @@ -2514,76 +2514,6 @@ static ulong read_event(MYSQL* mysql, Ma DBUG_RETURN(len - 1); } -/** - Check if the current error is of temporary nature or not. - Some errors are temporary in nature, such as - ER_LOCK_DEADLOCK and ER_LOCK_WAIT_TIMEOUT. Ndb also signals - that the error is temporary by pushing a warning with the error code - ER_GET_TEMPORARY_ERRMSG, if the originating error is temporary. - - @param thd a THD instance, typically of the slave SQL thread's. - @error_arg the error code for assessment. - defaults to zero which makes the function check the top - of the reported errors stack. - - @return 1 as the positive and 0 as the negative verdict -*/ -int has_temporary_error(THD *thd, uint error_arg) -{ - uint error; - DBUG_ENTER("has_temporary_error"); - - DBUG_EXECUTE_IF("all_errors_are_temporary_errors", - if (thd->stmt_da->is_error()) - { - thd->clear_error(); - my_error(ER_LOCK_DEADLOCK, MYF(0)); - }); - - /* - The state of the slave thread can't be regarded as - experiencing a temporary failure in cases of @c is_slave_error was set TRUE, - or if there is no message in THD, we can't say if it's a temporary - error or not. This is currently the case for Incident_log_event, - which sets no message. - */ - if (thd->is_fatal_error || !thd->is_error()) - DBUG_RETURN(0); - - error= (error_arg == 0)? thd->stmt_da->sql_errno() : error_arg; - - /* - Temporary error codes: - currently, InnoDB deadlock detected by InnoDB or lock - wait timeout (innodb_lock_wait_timeout exceeded). - Notice, the temporary error requires slave_trans_retries != 0) - */ - if (slave_trans_retries && - (error == ER_LOCK_DEADLOCK || error == ER_LOCK_WAIT_TIMEOUT)) - DBUG_RETURN(1); - -#ifdef HAVE_NDB_BINLOG - /* - currently temporary error set in ndbcluster - */ - List_iterator_fast it(thd->warning_info->warn_list()); - MYSQL_ERROR *err; - while ((err= it++)) - { - DBUG_PRINT("info", ("has condition %d %s", err->get_sql_errno(), - err->get_message_text())); - switch (err->get_sql_errno()) - { - case ER_GET_TEMPORARY_ERRMSG: - DBUG_RETURN(1); - default: - break; - } - } -#endif - DBUG_RETURN(0); -} - /** If this is a lagging slave (specified with CHANGE MASTER TO MASTER_DELAY = X), delays accordingly. Also unlocks rli->data_lock. @@ -2974,7 +2904,7 @@ static int exec_relay_log_event(THD* thd if (slave_trans_retries) { int UNINIT_VAR(temp_err); - if (exec_res && (temp_err= has_temporary_error(thd))) + if (exec_res && (temp_err= rli->has_temporary_error(thd))) { const char *errmsg; /* === modified file 'sql/rpl_slave.h' --- a/sql/rpl_slave.h 2011-03-27 18:16:32 +0000 +++ b/sql/rpl_slave.h 2011-03-28 13:19:08 +0000 @@ -213,7 +213,6 @@ void set_slave_thread_options(THD* thd); void set_slave_thread_default_charset(THD *thd, Relay_log_info const *rli); int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli); int rotate_relay_log(Master_info* mi); -int has_temporary_error(THD *thd, uint err= 0); pthread_handler_t handle_slave_io(void *arg); pthread_handler_t handle_slave_sql(void *arg); --===============2014970244== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/andrei.elkin@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: andrei.elkin@stripped # target_branch: file:///home/andrei/MySQL/BZR/2a-23May/FIXES\ # /bug11748510_36524_less_drama/ # testament_sha1: 948bab4e7d4577086f289d8f4857e417dff763ab # timestamp: 2011-03-28 16:19:17 +0300 # base_revision_id: andrei.elkin@stripped\ # zcv44cu2cawtepw5 # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWZU6SWgABUH/gHARRAB7//// /+//4L////5gDAfffO89d1doOvbT1k++7qq+2KF2FB93jhVL2orqueGSaTTSm01NoTU/JPQJgiMn qGA0AEaGAT1MT0mElAIaNBTZBNCm9FNA9Q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