Commit c2e16b3a authored by Nikita Malyavin's avatar Nikita Malyavin

MDEV-32803 Assertion `total == 0' failed in Event_log::write_cache_raw

A second DML in a transaction for a table of non-rollbackable engine
leads to a cache corruption, because the cache wasn't reset after a
statement end, but also wasn't destroyed.

This patch resets the cache for a reuse by subsequent statements in
current transaction.
parent 985e3dfc
......@@ -1785,6 +1785,28 @@ a d
0 qwe
0 qwe
drop table t;
#
# MDEV-32803 Assertion `total == 0' failed in Event_log::write_cache_raw
#
create or replace table t1 (a int) engine=aria;
insert t1 values (5);
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
alter table t1 add b int NULL, algorithm= copy, lock= none;
connection con2;
set debug_sync= 'now WAIT_FOR ended';
begin;
insert into t1 values (123);
insert into t1 values (456), (789);
commit;
set debug_sync= 'now SIGNAL end';
connection default;
select * from t1;
a b
5 NULL
123 NULL
456 NULL
789 NULL
drop table t1;
set global default_storage_engine= MyISAM;
disconnect con1;
disconnect con2;
......
......@@ -2041,6 +2041,31 @@ select * from t;
drop table t;
--echo #
--echo # MDEV-32803 Assertion `total == 0' failed in Event_log::write_cache_raw
--echo #
create or replace table t1 (a int) engine=aria;
insert t1 values (5);
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
send alter table t1 add b int NULL, algorithm= copy, lock= none;
--connection con2
set debug_sync= 'now WAIT_FOR ended';
begin;
insert into t1 values (123);
insert into t1 values (456), (789);
commit;
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
drop table t1;
eval set global default_storage_engine= $default_storage_engine;
--disconnect con1
......
......@@ -152,6 +152,7 @@ int online_alter_log_row(TABLE* table, const uchar *before_record,
if (!table->online_alter_cache)
{
table->online_alter_cache= get_cache_data(thd, table);
DBUG_ASSERT(table->online_alter_cache->cache_log.type == WRITE_CACHE);
trans_register_ha(thd, false, online_alter_hton, 0);
if (thd->in_multi_stmt_transaction_mode())
trans_register_ha(thd, true, online_alter_hton, 0);
......@@ -237,6 +238,8 @@ int online_alter_end_trans(Online_alter_cache_list &cache_list, THD *thd,
mysql_mutex_lock(binlog->get_log_lock());
error= binlog->write_cache_raw(thd, &cache.cache_log);
mysql_mutex_unlock(binlog->get_log_lock());
if (!is_ending_transaction)
cache.reset();
}
}
else if (!commit) // rollback
......
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