From e14b682636bc78a20cb7bedf2af696a3f1eb79bc Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 12 Apr 2021 17:49:36 +0300 Subject: [PATCH] Fixed assert in WSREP if one started with --wsrep_provider=.. --wsrep_on=OFF Assert was: mariadbd: /my/maria-10.6/wsrep-lib/src/client_state.cpp:256: int wsrep::client_state::after_statement(): Assertion `state() == s_exec' The reason was because of two faults: - A missing test for WSREP(thd) when checking wsrep_after_statement(() - THD->wsrep_cs().state was set to s_idle instead of s_none --- sql/sql_parse.cc | 5 +++-- sql/wsrep_trans_observer.h | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 23214020486..cd188ab693e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3781,7 +3781,8 @@ mysql_execute_command(THD *thd) thd->transaction.stmt.mark_trans_did_ddl(); #ifdef WITH_WSREP /* Clean up the previous transaction on implicit commit */ - if (wsrep_thd_is_local(thd) && wsrep_after_statement(thd)) + if (WSREP_NNULL(thd) && wsrep_thd_is_local(thd) && + wsrep_after_statement(thd)) { goto error; } @@ -3855,7 +3856,7 @@ mysql_execute_command(THD *thd) Do not start transaction for stored procedures, it will be handled internally in SP processing. */ - if (WSREP(thd) && + if (WSREP_NNULL(thd) && wsrep_thd_is_local(thd) && lex->sql_command != SQLCOM_BEGIN && lex->sql_command != SQLCOM_CALL && diff --git a/sql/wsrep_trans_observer.h b/sql/wsrep_trans_observer.h index 366cbef50d3..0a7cbf52a23 100644 --- a/sql/wsrep_trans_observer.h +++ b/sql/wsrep_trans_observer.h @@ -407,8 +407,10 @@ static inline void wsrep_after_apply(THD* thd) static inline void wsrep_open(THD* thd) { DBUG_ENTER("wsrep_open"); - if (WSREP_PROVIDER_EXISTS) + if (WSREP_ON_) { + /* WSREP_PROVIDER_EXISTS_ cannot be set if WSREP_ON_ is not set */ + DBUG_ASSERT(WSREP_PROVIDER_EXISTS_); thd->wsrep_cs().open(wsrep::client_id(thd->thread_id)); thd->wsrep_cs().debug_log_level(wsrep_debug); if (!thd->wsrep_applier && thd->variables.wsrep_trx_fragment_size)