Skip to content

Commit

Permalink
MDEV-25305: MyRocks: Killing server during RESET MASTER can lose last…
Browse files Browse the repository at this point in the history
… transactions

rocksdb_checkpoint_request() should call FlushWAL(sync=true) (which does
write-out and sync), not just SyncWAL()  (which just syncs without writing
out)
Followup: the test requires debug sync facility

(This is a backport to 10.5)
  • Loading branch information
spetrunia committed Mar 31, 2021
1 parent 5b678d9 commit bf310b4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sql/sql_repl.cc
Expand Up @@ -3966,6 +3966,8 @@ int reset_master(THD* thd, rpl_gtid *init_state, uint32 init_state_len,
ret= mysql_bin_log.reset_logs(thd, 1, init_state, init_state_len,
next_log_number);
repl_semisync_master.after_reset_master();
DBUG_EXECUTE_IF("crash_after_reset_master", DBUG_SUICIDE(););

return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/ha_rocksdb.cc
Expand Up @@ -4113,7 +4113,7 @@ static int rocksdb_recover(handlerton* hton, XID* xid_list, uint len)

static void rocksdb_checkpoint_request(void *cookie)
{
const rocksdb::Status s= rdb->SyncWAL();
const rocksdb::Status s= rdb->FlushWAL(true);
//TODO: what to do on error?
if (s.ok())
{
Expand Down
19 changes: 19 additions & 0 deletions storage/rocksdb/mysql-test/rocksdb/r/binlog_rotate_crash.result
@@ -0,0 +1,19 @@
#
# MDEV-25305: MyRocks: Killing server during RESET MASTER can lose last transactions
#
set global rocksdb_flush_log_at_trx_commit=1;
create table t1 (a int, b int, key(a)) engine=rocksdb;
insert into t1 values (1,1),(2,2);
select * from t1;
a b
1 1
2 2
flush tables;
set @@debug_dbug="+d,crash_after_reset_master";
RESET MASTER;
# Must show the inserted rows:
select * from t1;
a b
1 1
2 2
drop table t1;
31 changes: 31 additions & 0 deletions storage/rocksdb/mysql-test/rocksdb/t/binlog_rotate_crash.test
@@ -0,0 +1,31 @@
--source include/have_rocksdb.inc
--source include/have_log_bin.inc
--source include/have_debug_sync.inc

--echo #
--echo # MDEV-25305: MyRocks: Killing server during RESET MASTER can lose last transactions
--echo #

set global rocksdb_flush_log_at_trx_commit=1;

create table t1 (a int, b int, key(a)) engine=rocksdb;
insert into t1 values (1,1),(2,2);
select * from t1;
flush tables;

--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF

set @@debug_dbug="+d,crash_after_reset_master";

--disable_reconnect
--error 0,2013
RESET MASTER;
--enable_reconnect
--source include/wait_until_connected_again.inc
--echo # Must show the inserted rows:
select * from t1;

drop table t1;

0 comments on commit bf310b4

Please sign in to comment.