Server IP : 104.21.38.3 / Your IP : 172.70.189.31 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/server/mysql/src/sql/ |
Upload File : |
/* Copyright (c) 2007, 2023, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the Free Software Foundation. This program is also distributed with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in included license documentation. The authors of MySQL hereby grant you an additional permission to link the program and your derivative works with the separately licensed software that they have included with MySQL. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ #include "rpl_reporting.h" #include "log.h" // sql_print_warning #include "mysqld.h" // current_thd #include "sql_class.h" // THD #include "sql_error.h" // Diagnostics_area Slave_reporting_capability::Slave_reporting_capability(char const *thread_name) : m_thread_name(thread_name) { mysql_mutex_init(key_mutex_slave_reporting_capability_err_lock, &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. @silent bool indicating whether the error should be silently handled. @return 1 as the positive and 0 as the negative verdict */ int Slave_reporting_capability::has_temporary_error(THD *thd, uint error_arg, bool* silent) const { uint error; DBUG_ENTER("has_temporary_error"); DBUG_EXECUTE_IF("all_errors_are_temporary_errors", if (thd->get_stmt_da()->is_error()) { thd->clear_error(); my_error(ER_LOCK_DEADLOCK, MYF(0)); }); /* The slave can't be regarded as experiencing a temporary failure in cases of is_fatal_error is TRUE, or if no error is in THD and error_arg is not set. */ if (thd->is_fatal_error || (!thd->is_error() && error_arg == 0)) DBUG_RETURN(0); error= (error_arg == 0)? thd->get_stmt_da()->mysql_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); /* currently temporary error set in ndbcluster */ Diagnostics_area::Sql_condition_iterator it= thd->get_stmt_da()->sql_conditions(); const Sql_condition *err; while ((err= it++)) { DBUG_PRINT("info", ("has condition %d %s", err->mysql_errno(), err->message_text())); switch (err->mysql_errno()) { case ER_GET_TEMPORARY_ERRMSG: DBUG_RETURN(1); case ER_SLAVE_SILENT_RETRY_TRANSACTION: { if (silent != NULL) *silent= true; DBUG_RETURN(1); } default: break; } } DBUG_RETURN(0); } #endif // EMBEDDED_LIBRARY void Slave_reporting_capability::report(loglevel level, int err_code, const char *msg, ...) const { va_list args; va_start(args, msg); do_report(level, err_code, msg, args); va_end(args); } void Slave_reporting_capability::va_report(loglevel level, int err_code, const char *prefix_msg, const char *msg, va_list args) const { #if !defined(EMBEDDED_LIBRARY) THD *thd= current_thd; void (*report_function)(const char *, ...); char buff[MAX_SLAVE_ERRMSG]; char *pbuff= buff; char *curr_buff; uint pbuffsize= sizeof(buff); if (thd && level == ERROR_LEVEL && has_temporary_error(thd, err_code) && !thd->get_transaction()->cannot_safely_rollback( Transaction_ctx::SESSION)) level= WARNING_LEVEL; mysql_mutex_lock(&err_lock); switch (level) { case ERROR_LEVEL: /* It's an error, it must be reported in Last_error and Last_errno in SHOW SLAVE STATUS. */ pbuff= m_last_error.message; pbuffsize= sizeof(m_last_error.message); m_last_error.number = err_code; m_last_error.update_timestamp(); report_function= sql_print_error; break; case WARNING_LEVEL: report_function= sql_print_warning; break; case INFORMATION_LEVEL: report_function= sql_print_information; break; default: assert(0); // should not come here return; // don't crash production builds, just do nothing } curr_buff= pbuff; if (prefix_msg) curr_buff += my_snprintf(curr_buff, pbuffsize, "%s; ", prefix_msg); my_vsnprintf(curr_buff, pbuffsize - (curr_buff - pbuff), msg, args); mysql_mutex_unlock(&err_lock); /* If the msg string ends with '.', do not add a ',' it would be ugly */ report_function("Slave %s%s: %s%s Error_code: %d", m_thread_name, get_for_channel_str(false), pbuff, (curr_buff[0] && *(strend(curr_buff)-1) == '.') ? "" : ",", err_code); #endif } Slave_reporting_capability::~Slave_reporting_capability() { mysql_mutex_destroy(&err_lock); }