Commit 86770ada authored by Monty's avatar Monty

MDEV-34240 galera.MDEV-27862 fails binlog assert in close_thread_tables()

Affects:
MDEV-34150 Assertion failure in Diagnostics_area::set_error_status upon binary
           logging hitting tmp space limit
MDEV-9101 Limit size of created disk temporary files and tables

This bug was caused by moving flushing of the in-memory-row-events from
close_thread_tables() to binlog_commit() in MDEV-34150.
This was needed to be able to handle the case where binlog writes could
fail.

Galera have two case where the change caused problems:

- Row events in commit_one_phase_2() was not done in the case the standard
  binary log was not enabled but Galera was using the binary log
  internally.
- Galera disabled the call to binlog_commit_flush_stmt_cache() for not
  ending transactions.

Fixed by adding code that flushes the in-memory-row-events to the binary
log (write, but now sync) in the two above cases if Galera is enabled.
parent f385837d
......@@ -10,7 +10,6 @@
#
##############################################################################
MDEV-27862 : MDEV-34240
galera_as_slave_ctas : MDEV-28378 timeout
galera_pc_recovery : MDEV-25199 cluster fails to start up
galera_bf_kill_debug : timeout after 900 seconds
......
......@@ -2159,13 +2159,24 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans)
{
int err;
if (has_binlog_hton(ha_info) &&
(err= binlog_commit(thd, all,
is_ro_1pc_trans(thd, ha_info, all, is_real_trans))))
if (has_binlog_hton(ha_info))
{
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
error= 1;
if ((err= binlog_commit(thd, all,
is_ro_1pc_trans(thd, ha_info, all,
is_real_trans))))
{
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
error= 1;
}
}
#ifdef WITH_WSREP
else
{
if (wsrep_on(thd))
error= thd->binlog_flush_pending_rows_event(TRUE);
}
#endif
for (; ha_info; ha_info= ha_info_next)
{
handlerton *ht= ha_info->ht();
......
......@@ -2161,17 +2161,22 @@ int binlog_commit(THD *thd, bool all, bool ro_1pc)
thd->backup_stage(&org_stage);
THD_STAGE_INFO(thd, stage_binlog_write);
#ifdef WITH_WSREP
// DON'T clear stmt cache in case we are in transaction
if (!cache_mngr->stmt_cache.empty() &&
(!wsrep_on(thd) || ending_trans(thd, all)))
#else
if (!cache_mngr->stmt_cache.empty())
#endif
{
error= binlog_commit_flush_stmt_cache(thd, all, cache_mngr);
#ifdef WITH_WSREP
if (wsrep_on(thd) && !ending_trans(thd, all))
{
/*
We should not clear stmt cache in case we are in transaction.
However we should write all pending row events to disk to
ensure we did not run out of disk quota.
*/
error= thd->binlog_flush_pending_rows_event(TRUE, FALSE);
}
else
#endif /* WITH_WSREP */
error= binlog_commit_flush_stmt_cache(thd, all, cache_mngr);
}
if (cache_mngr->trx_cache.empty() &&
(thd->transaction->xid_state.get_state_code() != XA_PREPARED ||
!(thd->ha_data[binlog_hton->slot].ha_info[1].is_started() &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment