1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-25477 Auto-create breaks replication when triggering event was not replicated

If UPDATE/DELETE does not change data it is skipped from
replication. We now force replication of such events when they trigger
partition auto-creation.

For ROLLBACK it is as simple as set OPTION_KEEP_LOG
flag. trans_cannot_safely_rollback() does the rest.

For UPDATE/DELETE .. LIMIT 0 we make additional binlog_query() calls
at the early points of return.

As a safety measure we also convert row format into statement if it is
needed. The condition is decided by
binlog_need_stmt_format(). Basically if there are some row events in
cache we don't need that: table open of row event will trigger
auto-creation anyway.

Multi-update/delete works via mysql_select(). There is no early points
of return, so binlogging is always checked by
send_eof()/abort_resultset(). But we must comply with the above
measure of converting into statement.
This commit is contained in:
Aleksey Midenkov
2022-05-06 10:45:18 +03:00
parent 92bfc0e8c4
commit 706a8232da
9 changed files with 438 additions and 44 deletions

View File

@ -1207,6 +1207,7 @@ values_loop_end:
if (error <= 0 ||
thd->transaction->stmt.modified_non_trans_table ||
thd->log_current_statement() ||
was_insert_delayed)
{
if(WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open())
@ -1229,8 +1230,8 @@ values_loop_end:
else
errcode= query_error_code(thd, thd->killed == NOT_KILLED);
ScopedStatementReplication scoped_stmt_rpl(
table->versioned(VERS_TRX_ID) ? thd : NULL);
StatementBinlog stmt_binlog(thd, table->versioned(VERS_TRX_ID) ||
thd->binlog_need_stmt_format(transactional_table));
/* bug#22725:
A query which per-row-loop can not be interrupted with
@ -4223,7 +4224,8 @@ bool select_insert::prepare_eof()
ha_autocommit_or_rollback() is issued below.
*/
if ((WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) &&
(likely(!error) || thd->transaction->stmt.modified_non_trans_table))
(likely(!error) || thd->transaction->stmt.modified_non_trans_table ||
thd->log_current_statement()))
{
int errcode= 0;
int res;
@ -4231,6 +4233,8 @@ bool select_insert::prepare_eof()
thd->clear_error();
else
errcode= query_error_code(thd, killed_status == NOT_KILLED);
StatementBinlog stmt_binlog(thd, !can_rollback_data() &&
thd->binlog_need_stmt_format(trans_table));
res= thd->binlog_query(THD::ROW_QUERY_TYPE,
thd->query(), thd->query_length(),
trans_table, FALSE, FALSE, errcode);
@ -4351,6 +4355,8 @@ void select_insert::abort_result_set()
if(WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open())
{
StatementBinlog stmt_binlog(thd, !can_rollback_data() &&
thd->binlog_need_stmt_format(transactional_table));
int errcode= query_error_code(thd, thd->killed == NOT_KILLED);
int res;
/* error of writing binary log is ignored */