mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
BUG#55625 RBR breaks on failing 'CREATE TABLE'
A CREATE...SELECT that fails is written to the binary log if a non-transactional statement is updated. If the logging format is ROW, the CREATE statement and the changes are written to the binary log as distinct events and by consequence the created table is not rolled back in the slave. In this patch, we opted to let the slave goes out of sync by not writting to the binary log the CREATE statement. We do this by simply reseting the binary log's cache. mysql-test/suite/rpl/r/rpl_drop.result: Added a test case. mysql-test/suite/rpl/t/rpl_drop.test: Added a test case. sql/log.cc: Introduced a function to clean up the cache. sql/log.h: Introduced a function to clean up the cache. sql/sql_insert.cc: Cleaned up the binary log cache if a CREATE...SELECT fails.
This commit is contained in:
13
sql/log.cc
13
sql/log.cc
@@ -1628,6 +1628,19 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
/**
|
||||
Cleanup the cache.
|
||||
|
||||
@param thd The client thread that wants to clean up the cache.
|
||||
*/
|
||||
void MYSQL_BIN_LOG::reset_gathered_updates(THD *thd)
|
||||
{
|
||||
binlog_trx_data *const trx_data=
|
||||
(binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
|
||||
|
||||
trx_data->reset();
|
||||
}
|
||||
|
||||
void MYSQL_BIN_LOG::set_write_error(THD *thd)
|
||||
{
|
||||
DBUG_ENTER("MYSQL_BIN_LOG::set_write_error");
|
||||
|
||||
@@ -356,10 +356,11 @@ public:
|
||||
/* Use this to start writing a new log file */
|
||||
void new_file();
|
||||
|
||||
void reset_gathered_updates(THD *thd);
|
||||
bool write(Log_event* event_info); // binary log write
|
||||
bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool incident);
|
||||
bool write_incident(THD *thd, bool lock);
|
||||
|
||||
bool write_incident(THD *thd, bool lock);
|
||||
int write_cache(IO_CACHE *cache, bool lock_log, bool flush_and_sync);
|
||||
void set_write_error(THD *thd);
|
||||
bool check_write_error(THD *thd);
|
||||
|
||||
@@ -3873,6 +3873,17 @@ void select_create::abort()
|
||||
|
||||
if (table)
|
||||
{
|
||||
if (thd->lex->sql_command == SQLCOM_CREATE_TABLE &&
|
||||
thd->current_stmt_binlog_row_based &&
|
||||
!(thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) &&
|
||||
mysql_bin_log.is_open())
|
||||
{
|
||||
/*
|
||||
This should be removed after BUG#47899.
|
||||
*/
|
||||
mysql_bin_log.reset_gathered_updates(thd);
|
||||
}
|
||||
|
||||
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
|
||||
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
|
||||
if (!create_info->table_existed)
|
||||
|
||||
Reference in New Issue
Block a user