Helper function to handle flush or sync stage errors. If binlog_error_action= ABORT_SERVER, server will be aborted after reporting the error to the client. If binlog_error_action= IGNORE_ERROR, binlog will be closed for the life time of the server. close() call is protected with LOCK_log to avoid any parallel operations on binary log. @param thd Thread object that faced flush/sync err
| 7251 | @return void |
| 7252 | */ |
| 7253 | void MYSQL_BIN_LOG::handle_binlog_flush_or_sync_error(THD *thd, |
| 7254 | bool need_lock_log) |
| 7255 | { |
| 7256 | char errmsg[MYSQL_ERRMSG_SIZE]; |
| 7257 | sprintf(errmsg, "An error occurred during %s stage of the commit. " |
| 7258 | "'binlog_error_action' is set to '%s'.", |
| 7259 | thd->commit_error== THD::CE_FLUSH_ERROR ? "flush" : "sync", |
| 7260 | binlog_error_action == ABORT_SERVER ? "ABORT_SERVER" : "IGNORE_ERROR"); |
| 7261 | if (binlog_error_action == ABORT_SERVER) |
| 7262 | { |
| 7263 | char err_buff[MYSQL_ERRMSG_SIZE]; |
| 7264 | sprintf(err_buff, "%s Hence aborting the server.", errmsg); |
| 7265 | exec_binlog_error_action_abort(err_buff); |
| 7266 | } |
| 7267 | else |
| 7268 | { |
| 7269 | DEBUG_SYNC(thd, "before_binlog_closed_due_to_error"); |
| 7270 | if (need_lock_log) |
| 7271 | mysql_mutex_lock(&LOCK_log); |
| 7272 | else |
| 7273 | mysql_mutex_assert_owner(&LOCK_log); |
| 7274 | /* |
| 7275 | It can happen that other group leader encountered |
| 7276 | error and already closed the binary log. So print |
| 7277 | error only if it is in open state. But we should |
| 7278 | call close() always just in case if the previous |
| 7279 | close did not close index file. |
| 7280 | */ |
| 7281 | if (is_open()) |
| 7282 | { |
| 7283 | sql_print_error("%s Hence turning logging off for the whole duration " |
| 7284 | "of the MySQL server process. To turn it on again: fix " |
| 7285 | "the cause, shutdown the MySQL server and restart it.", |
| 7286 | errmsg); |
| 7287 | } |
| 7288 | close(LOG_CLOSE_INDEX|LOG_CLOSE_STOP_EVENT); |
| 7289 | if (need_lock_log) |
| 7290 | mysql_mutex_unlock(&LOCK_log); |
| 7291 | DEBUG_SYNC(thd, "after_binlog_closed_due_to_error"); |
| 7292 | } |
| 7293 | } |
| 7294 | /** |
| 7295 | Flush and commit the transaction. |
| 7296 |
nothing calls this directly
no outgoing calls
no test coverage detected