| 7743 | } |
| 7744 | |
| 7745 | static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, |
| 7746 | Parser_state *parser_state) |
| 7747 | { |
| 7748 | bool is_autocommit= |
| 7749 | !thd->in_multi_stmt_transaction_mode() && |
| 7750 | !thd->wsrep_applier; |
| 7751 | bool retry_autocommit; |
| 7752 | do |
| 7753 | { |
| 7754 | retry_autocommit= false; |
| 7755 | mysql_parse(thd, rawbuf, length, parser_state); |
| 7756 | |
| 7757 | /* |
| 7758 | Convert all ER_QUERY_INTERRUPTED errors to ER_LOCK_DEADLOCK |
| 7759 | if the transaction was BF aborted. This can happen when the |
| 7760 | transaction is being BF aborted via thd->awake() while it is |
| 7761 | still executing. |
| 7762 | |
| 7763 | Note that this must be done before wsrep_after_statement() call |
| 7764 | since it clears the transaction for autocommit queries. |
| 7765 | */ |
| 7766 | if (((thd->get_stmt_da()->is_error() && |
| 7767 | thd->get_stmt_da()->sql_errno() == ER_QUERY_INTERRUPTED) || |
| 7768 | !thd->get_stmt_da()->is_set()) && |
| 7769 | thd->wsrep_trx().bf_aborted()) |
| 7770 | { |
| 7771 | WSREP_DEBUG("overriding error: %d with DEADLOCK", |
| 7772 | (thd->get_stmt_da()->is_error()) ? |
| 7773 | thd->get_stmt_da()->sql_errno() : 0); |
| 7774 | |
| 7775 | thd->reset_kill_query(); |
| 7776 | wsrep_override_error(thd, ER_LOCK_DEADLOCK); |
| 7777 | } |
| 7778 | |
| 7779 | #ifdef ENABLED_DEBUG_SYNC |
| 7780 | /* we need the test otherwise we get stuck in the "SET DEBUG_SYNC" itself */ |
| 7781 | if (thd->lex->sql_command != SQLCOM_SET_OPTION) |
| 7782 | DEBUG_SYNC(thd, "wsrep_after_statement_enter"); |
| 7783 | #endif |
| 7784 | |
| 7785 | if (wsrep_after_statement(thd) && |
| 7786 | is_autocommit && |
| 7787 | thd_is_connection_alive(thd)) |
| 7788 | { |
| 7789 | thd->reset_for_next_command(); |
| 7790 | thd->reset_kill_query(); |
| 7791 | if (is_autocommit && |
| 7792 | thd->lex->sql_command != SQLCOM_SELECT && |
| 7793 | thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit) |
| 7794 | { |
| 7795 | #ifdef ENABLED_DEBUG_SYNC |
| 7796 | DBUG_EXECUTE_IF("sync.wsrep_retry_autocommit", |
| 7797 | { |
| 7798 | const char act[]= |
| 7799 | "now " |
| 7800 | "SIGNAL wsrep_retry_autocommit_reached " |
| 7801 | "WAIT_FOR wsrep_retry_autocommit_continue"; |
| 7802 | DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); |
no test coverage detected