MDEV-9609 : wsrep_debug only logs DDL information on originating node
Added DDL logging to applier and replaying also so that DDL is logged on other than originating node. wsrep.h Removed wsrep_thd_is_local conditions and cleaned up the macros. Removed WSREP_TO_ISOLATION_END. Event_job_data::execute change_password acl_set_default_role mysql_execute_command Replaced macro by function call wsrep_to_isolation_begin wsrep_to_isolation_end If execution is not local log DDL-information when wsrep_debug is enabled No new tests required as current regression setting is already testing these code paths.
This commit is contained in:
parent
1c5ae99194
commit
bee1bb056d
@ -25,41 +25,40 @@
|
|||||||
#define DBUG_ASSERT_IF_WSREP(A) DBUG_ASSERT(A)
|
#define DBUG_ASSERT_IF_WSREP(A) DBUG_ASSERT(A)
|
||||||
|
|
||||||
#define WSREP_MYSQL_DB (char *)"mysql"
|
#define WSREP_MYSQL_DB (char *)"mysql"
|
||||||
#define WSREP_TO_ISOLATION_BEGIN_IF(db_, table_, table_list_) \
|
|
||||||
if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_))
|
#define WSREP_TO_ISOLATION_BEGIN_IF(db_, table_, table_list_) \
|
||||||
|
if (WSREP_ON && WSREP(thd) && \
|
||||||
|
wsrep_to_isolation_begin(thd, db_, table_, table_list_))
|
||||||
|
|
||||||
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \
|
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \
|
||||||
if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \
|
if (WSREP_ON && WSREP(thd) && \
|
||||||
|
wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \
|
||||||
goto wsrep_error_label;
|
goto wsrep_error_label;
|
||||||
|
|
||||||
#define WSREP_TO_ISOLATION_BEGIN_CREATE(db_, table_, table_list_, create_info_) \
|
#define WSREP_TO_ISOLATION_BEGIN_CREATE(db_, table_, table_list_, create_info_) \
|
||||||
if (WSREP_ON && WSREP(thd) && \
|
if (WSREP_ON && WSREP(thd) && \
|
||||||
wsrep_to_isolation_begin(thd, db_, table_, \
|
wsrep_to_isolation_begin(thd, db_, table_, \
|
||||||
table_list_, nullptr, nullptr, create_info_))\
|
table_list_, nullptr, nullptr, create_info_)) \
|
||||||
goto wsrep_error_label;
|
goto wsrep_error_label;
|
||||||
|
|
||||||
#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_, create_info_) \
|
#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_, create_info_) \
|
||||||
if (WSREP(thd) && wsrep_thd_is_local(thd) && \
|
if (WSREP(thd) && \
|
||||||
wsrep_to_isolation_begin(thd, db_, table_, \
|
wsrep_to_isolation_begin(thd, db_, table_, \
|
||||||
table_list_, alter_info_, \
|
table_list_, alter_info_, \
|
||||||
fk_tables_, create_info_)) \
|
fk_tables_, create_info_)) \
|
||||||
goto wsrep_error_label;
|
goto wsrep_error_label;
|
||||||
|
|
||||||
#define WSREP_TO_ISOLATION_END \
|
|
||||||
if ((WSREP(thd) && wsrep_thd_is_local_toi(thd)) || \
|
|
||||||
wsrep_thd_is_in_rsu(thd)) \
|
|
||||||
wsrep_to_isolation_end(thd);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Checks if lex->no_write_to_binlog is set for statements that use LOCAL or
|
Checks if lex->no_write_to_binlog is set for statements that use LOCAL or
|
||||||
NO_WRITE_TO_BINLOG.
|
NO_WRITE_TO_BINLOG.
|
||||||
*/
|
*/
|
||||||
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \
|
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \
|
||||||
if (WSREP(thd) && !thd->lex->no_write_to_binlog \
|
if (WSREP(thd) && !thd->lex->no_write_to_binlog && \
|
||||||
&& wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto wsrep_error_label;
|
wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \
|
||||||
|
goto wsrep_error_label;
|
||||||
|
|
||||||
#define WSREP_TO_ISOLATION_BEGIN_FK_TABLES(db_, table_, table_list_, fk_tables) \
|
#define WSREP_TO_ISOLATION_BEGIN_FK_TABLES(db_, table_, table_list_, fk_tables) \
|
||||||
if (WSREP(thd) && !thd->lex->no_write_to_binlog \
|
if (WSREP(thd) && !thd->lex->no_write_to_binlog \
|
||||||
&& wsrep_to_isolation_begin(thd, db_, table_, table_list_, NULL, fk_tables))
|
&& wsrep_to_isolation_begin(thd, db_, table_, table_list_, NULL, fk_tables))
|
||||||
|
|
||||||
#define WSREP_SYNC_WAIT(thd_, before_) \
|
#define WSREP_SYNC_WAIT(thd_, before_) \
|
||||||
@ -77,7 +76,6 @@
|
|||||||
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) do { } while(0)
|
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) do { } while(0)
|
||||||
#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_, create_info_)
|
#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_, create_info_)
|
||||||
#define WSREP_TO_ISOLATION_BEGIN_FK_TABLES(db_, table_, table_list_, fk_tables_)
|
#define WSREP_TO_ISOLATION_BEGIN_FK_TABLES(db_, table_, table_list_, fk_tables_)
|
||||||
#define WSREP_TO_ISOLATION_END
|
|
||||||
#define WSREP_TO_ISOLATION_BEGIN_CREATE(db_, table_, table_list_, create_info_)
|
#define WSREP_TO_ISOLATION_BEGIN_CREATE(db_, table_, table_list_, create_info_)
|
||||||
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)
|
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)
|
||||||
#define WSREP_SYNC_WAIT(thd_, before_)
|
#define WSREP_SYNC_WAIT(thd_, before_)
|
||||||
|
@ -1545,7 +1545,9 @@ end:
|
|||||||
|
|
||||||
if (sql_command_set)
|
if (sql_command_set)
|
||||||
{
|
{
|
||||||
WSREP_TO_ISOLATION_END;
|
#ifdef WITH_WSREP
|
||||||
|
wsrep_to_isolation_end(thd);
|
||||||
|
#endif
|
||||||
thd->lex->sql_command = sql_command_save;
|
thd->lex->sql_command = sql_command_save;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4028,10 +4028,9 @@ end:
|
|||||||
|
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
wsrep_error_label:
|
wsrep_error_label:
|
||||||
if (WSREP(thd) && !thd->wsrep_applier)
|
if (WSREP(thd))
|
||||||
{
|
{
|
||||||
WSREP_TO_ISOLATION_END;
|
wsrep_to_isolation_end(thd);
|
||||||
|
|
||||||
thd->set_query(query_save);
|
thd->set_query(query_save);
|
||||||
}
|
}
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
@ -4172,10 +4171,9 @@ int acl_set_default_role(THD *thd, const char *host, const char *user,
|
|||||||
|
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
wsrep_error_label:
|
wsrep_error_label:
|
||||||
if (WSREP(thd) && !thd->wsrep_applier)
|
if (WSREP(thd))
|
||||||
{
|
{
|
||||||
WSREP_TO_ISOLATION_END;
|
wsrep_to_isolation_end(thd);
|
||||||
|
|
||||||
thd->set_query(query_save);
|
thd->set_query(query_save);
|
||||||
}
|
}
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
|
@ -6114,7 +6114,8 @@ finish:
|
|||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
thd->wsrep_consistency_check= NO_CONSISTENCY_CHECK;
|
thd->wsrep_consistency_check= NO_CONSISTENCY_CHECK;
|
||||||
|
|
||||||
WSREP_TO_ISOLATION_END;
|
if (wsrep_thd_is_toi(thd) || wsrep_thd_is_in_rsu(thd))
|
||||||
|
wsrep_to_isolation_end(thd);
|
||||||
/*
|
/*
|
||||||
Force release of transactional locks if not in active MST and wsrep is on.
|
Force release of transactional locks if not in active MST and wsrep is on.
|
||||||
*/
|
*/
|
||||||
|
@ -2697,6 +2697,17 @@ static void wsrep_RSU_end(THD *thd)
|
|||||||
thd->variables.wsrep_on= 1;
|
thd->variables.wsrep_on= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool is_replaying_connection(THD *thd)
|
||||||
|
{
|
||||||
|
bool ret;
|
||||||
|
|
||||||
|
mysql_mutex_lock(&thd->LOCK_thd_data);
|
||||||
|
ret= (thd->wsrep_trx().state() == wsrep::transaction::s_replaying) ? true : false;
|
||||||
|
mysql_mutex_unlock(&thd->LOCK_thd_data);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
|
int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
|
||||||
const TABLE_LIST* table_list,
|
const TABLE_LIST* table_list,
|
||||||
const Alter_info *alter_info,
|
const Alter_info *alter_info,
|
||||||
@ -2706,9 +2717,18 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
|
|||||||
/*
|
/*
|
||||||
No isolation for applier or replaying threads.
|
No isolation for applier or replaying threads.
|
||||||
*/
|
*/
|
||||||
if (!wsrep_thd_is_local(thd)) return 0;
|
if (!wsrep_thd_is_local(thd))
|
||||||
|
{
|
||||||
|
if (wsrep_OSU_method_get(thd) == WSREP_OSU_TOI)
|
||||||
|
WSREP_DEBUG("%s TOI Begin: %s",
|
||||||
|
is_replaying_connection(thd) ? "Replay" : "Apply",
|
||||||
|
wsrep_thd_query(thd));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int ret= 0;
|
int ret= 0;
|
||||||
|
|
||||||
mysql_mutex_lock(&thd->LOCK_thd_data);
|
mysql_mutex_lock(&thd->LOCK_thd_data);
|
||||||
|
|
||||||
if (thd->wsrep_trx().state() == wsrep::transaction::s_must_abort)
|
if (thd->wsrep_trx().state() == wsrep::transaction::s_must_abort)
|
||||||
@ -2791,25 +2811,32 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
|
|||||||
|
|
||||||
void wsrep_to_isolation_end(THD *thd)
|
void wsrep_to_isolation_end(THD *thd)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(wsrep_thd_is_local_toi(thd) ||
|
|
||||||
wsrep_thd_is_in_rsu(thd));
|
|
||||||
|
|
||||||
thd->variables.lock_wait_timeout= thd->variables.saved_lock_wait_timeout;
|
|
||||||
|
|
||||||
if (wsrep_thd_is_local_toi(thd))
|
if (wsrep_thd_is_local_toi(thd))
|
||||||
{
|
{
|
||||||
|
thd->variables.lock_wait_timeout= thd->variables.saved_lock_wait_timeout;
|
||||||
DBUG_ASSERT(wsrep_OSU_method_get(thd) == WSREP_OSU_TOI);
|
DBUG_ASSERT(wsrep_OSU_method_get(thd) == WSREP_OSU_TOI);
|
||||||
wsrep_TOI_end(thd);
|
wsrep_TOI_end(thd);
|
||||||
}
|
}
|
||||||
else if (wsrep_thd_is_in_rsu(thd))
|
else if (wsrep_thd_is_in_rsu(thd))
|
||||||
{
|
{
|
||||||
|
thd->variables.lock_wait_timeout= thd->variables.saved_lock_wait_timeout;
|
||||||
DBUG_ASSERT(wsrep_OSU_method_get(thd) == WSREP_OSU_RSU);
|
DBUG_ASSERT(wsrep_OSU_method_get(thd) == WSREP_OSU_RSU);
|
||||||
wsrep_RSU_end(thd);
|
wsrep_RSU_end(thd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(0);
|
/* Applier or replaying threads just output TO END */
|
||||||
|
if (wsrep_debug)
|
||||||
|
{
|
||||||
|
wsrep::client_state& client_state(thd->wsrep_cs());
|
||||||
|
WSREP_DEBUG("%s TO END: %lld: %s",
|
||||||
|
is_replaying_connection(thd) ? "Replay" : "Apply",
|
||||||
|
client_state.toi_meta().seqno().get(),
|
||||||
|
wsrep_thd_query(thd));
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wsrep_emulate_bin_log) wsrep_thd_binlog_trx_reset(thd);
|
if (wsrep_emulate_bin_log) wsrep_thd_binlog_trx_reset(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2957,17 +2984,6 @@ static inline bool is_client_connection(THD *thd)
|
|||||||
return (thd->wsrep_client_thread && thd->variables.wsrep_on);
|
return (thd->wsrep_client_thread && thd->variables.wsrep_on);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool is_replaying_connection(THD *thd)
|
|
||||||
{
|
|
||||||
bool ret;
|
|
||||||
|
|
||||||
mysql_mutex_lock(&thd->LOCK_thd_data);
|
|
||||||
ret= (thd->wsrep_trx().state() == wsrep::transaction::s_replaying) ? true : false;
|
|
||||||
mysql_mutex_unlock(&thd->LOCK_thd_data);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool is_committing_connection(THD *thd)
|
static inline bool is_committing_connection(THD *thd)
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user