From c863159c320008676aff978a7cdde5732678f975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 24 Jul 2018 14:54:50 +0300 Subject: MDEV-16799: Test wsrep.variables crash at sql_class.cc:639 thd_get_ha_data Problem was that binlog_hton was not initialized fully when needed i.e. when wsrep_on = true. --- sql/wsrep_hton.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'sql/wsrep_hton.cc') diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 0a2264ac03c..734a0686a6d 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -24,6 +24,8 @@ #include #include "debug_sync.h" +extern handlerton *binlog_hton; +extern int binlog_close_connection(handlerton *hton, THD *thd); extern ulonglong thd_to_trx_id(THD *thd); extern "C" int thd_binlog_format(const MYSQL_THD thd); @@ -173,7 +175,10 @@ wsrep_close_connection(handlerton* hton, THD* thd) { DBUG_RETURN(0); } - DBUG_RETURN(wsrep_binlog_close_connection (thd)); + + if (wsrep_emulate_bin_log && thd_get_ha_data(thd, binlog_hton) != NULL) + binlog_hton->close_connection (binlog_hton, thd); + DBUG_RETURN(0); } /* @@ -256,9 +261,9 @@ static int wsrep_rollback(handlerton *hton, THD *thd, bool all) } if ((all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && - thd->wsrep_conflict_state != MUST_REPLAY) + thd->variables.wsrep_on && thd->wsrep_conflict_state != MUST_REPLAY) { - if (WSREP(thd) && wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) + if (wsrep && wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) { DBUG_PRINT("wsrep", ("setting rollback fail")); WSREP_ERROR("settting rollback fail: thd: %llu, schema: %s, SQL: %s", @@ -299,12 +304,14 @@ int wsrep_commit(handlerton *hton, THD *thd, bool all) Transaction didn't go through wsrep->pre_commit() so just roll back possible changes to clean state. */ - if (WSREP(thd) && wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) - { - DBUG_PRINT("wsrep", ("setting rollback fail")); - WSREP_ERROR("settting rollback fail: thd: %llu, schema: %s, SQL: %s", + if (WSREP_PROVIDER_EXISTS) { + if (wsrep && wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) + { + DBUG_PRINT("wsrep", ("setting rollback fail")); + WSREP_ERROR("settting rollback fail: thd: %llu, schema: %s, SQL: %s", (long long)thd->real_id, (thd->db ? thd->db : "(null)"), thd->query()); + } } wsrep_cleanup_transaction(thd); } -- cgit v1.2.1