1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-31660 : Assertion `client_state.transaction().active() in wsrep_append_key

At the moment we cannot support
wsrep_forced_binlog_format=[MIXED|STATEMENT]
during CREATE TABLE AS SELECT.
Statement will use ROW instead and give
a warning.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
This commit is contained in:
Jan Lindström
2023-08-04 07:59:37 +03:00
committed by Julius Goryavsky
parent 04b7b3a0ca
commit f57deb314f
13 changed files with 476 additions and 39 deletions

View File

@ -667,6 +667,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
wsrep_ignore_table(false),
wsrep_aborter(0),
wsrep_delayed_BF_abort(false),
wsrep_ctas(false),
/* wsrep-lib */
m_wsrep_next_trx_id(WSREP_UNDEFINED_TRX_ID),
@ -5323,7 +5324,7 @@ extern "C" int thd_binlog_format(const MYSQL_THD thd)
if (WSREP(thd))
{
/* for wsrep binlog format is meaningful also when binlogging is off */
return (int) WSREP_BINLOG_FORMAT(thd->variables.binlog_format);
return (int) thd->wsrep_binlog_format(thd->variables.binlog_format);
}
if (mysql_bin_log.is_open() && (thd->variables.option_bits & OPTION_BIN_LOG))
@ -5997,6 +5998,8 @@ int THD::decide_logging_format(TABLE_LIST *tables)
reset_binlog_local_stmt_filter();
// Used binlog format
ulong binlog_format= wsrep_binlog_format(variables.binlog_format);
/*
We should not decide logging format if the binlog is closed or
binlogging is off, or if the statement is filtered out from the
@ -6017,20 +6020,41 @@ int THD::decide_logging_format(TABLE_LIST *tables)
}
}
/*
If user has configured wsrep_forced_binlog_format to
STMT OR MIXED and used binlog_format would be same
and this is CREATE TABLE AS SELECT we will fall back
to ROW.
*/
if (wsrep_forced_binlog_format < BINLOG_FORMAT_ROW &&
wsrep_ctas)
{
if (!get_stmt_da()->has_sql_condition(ER_UNKNOWN_ERROR))
{
push_warning_printf(this, Sql_condition::WARN_LEVEL_WARN,
ER_UNKNOWN_ERROR,
"Galera does not support wsrep_forced_binlog_format = %s "
"in CREATE TABLE AS SELECT",
wsrep_forced_binlog_format == BINLOG_FORMAT_STMT ?
"STMT" : "MIXED");
}
set_current_stmt_binlog_format_row();
}
if ((WSREP_EMULATE_BINLOG_NNULL(this) ||
(mysql_bin_log.is_open() && (variables.option_bits & OPTION_BIN_LOG))) &&
!(wsrep_binlog_format() == BINLOG_FORMAT_STMT &&
!(binlog_format == BINLOG_FORMAT_STMT &&
!binlog_filter->db_ok(db.str)))
#else
if (mysql_bin_log.is_open() && (variables.option_bits & OPTION_BIN_LOG) &&
!(wsrep_binlog_format() == BINLOG_FORMAT_STMT &&
!(binlog_format == BINLOG_FORMAT_STMT &&
!binlog_filter->db_ok(db.str)))
#endif /* WITH_WSREP */
{
if (is_bulk_op())
{
if (wsrep_binlog_format() == BINLOG_FORMAT_STMT)
if (binlog_format == BINLOG_FORMAT_STMT)
{
my_error(ER_BINLOG_NON_SUPPORTED_BULK, MYF(0));
DBUG_PRINT("info",
@ -6243,7 +6267,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
prev_access_table= table;
}
if (wsrep_binlog_format() != BINLOG_FORMAT_ROW)
if (binlog_format != BINLOG_FORMAT_ROW)
{
/*
DML statements that modify a table with an auto_increment
@ -6327,7 +6351,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
*/
my_error((error= ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE), MYF(0));
}
else if ((wsrep_binlog_format() == BINLOG_FORMAT_ROW || is_bulk_op()) &&
else if ((binlog_format == BINLOG_FORMAT_ROW || is_bulk_op()) &&
sqlcom_can_generate_row_events(this))
{
/*
@ -6357,7 +6381,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
else
{
/* binlog_format = STATEMENT */
if (wsrep_binlog_format() == BINLOG_FORMAT_STMT)
if (binlog_format == BINLOG_FORMAT_STMT)
{
if (lex->is_stmt_row_injection())
{
@ -6497,7 +6521,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
"and binlog_filter->db_ok(db) = %d",
mysql_bin_log.is_open(),
(variables.option_bits & OPTION_BIN_LOG),
(uint) wsrep_binlog_format(),
(uint) binlog_format,
binlog_filter->db_ok(db.str)));
#endif
@ -6533,7 +6557,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
void THD::reconsider_logging_format_for_iodup(TABLE *table)
{
DBUG_ENTER("reconsider_logging_format_for_iodup");
enum_binlog_format bf= (enum_binlog_format) wsrep_binlog_format();
enum_binlog_format bf= (enum_binlog_format) wsrep_binlog_format(variables.binlog_format);
DBUG_ASSERT(lex->duplicates == DUP_UPDATE);