revision-id: ed221980fcd391dd349d80ea5b90b84a62ce043c (mariadb-10.5.2-536-ged221980fcd) parent(s): 75db05c5992e5a13ab0836120f46e241fc6de618 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-03-30 16:17:10 +0300 message: MDEV-25305: MyRocks: Killing server during RESET MASTER can lose last transactions rocksdb_checkpoint_request() should call FlushWAL(sync=true) (which does write-out and sync), not just SyncWAL() (which just syncs without writing out) --- sql/sql_repl.cc | 2 ++ storage/rocksdb/ha_rocksdb.cc | 2 +- .../rocksdb/r/binlog_rotate_crash.result | 19 ++++++++++++++ .../mysql-test/rocksdb/t/binlog_rotate_crash.test | 30 ++++++++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 084259d863d..ce270351dc3 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -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; } diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 289a1ac07b9..43d9e60aa46 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -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()) { diff --git a/storage/rocksdb/mysql-test/rocksdb/r/binlog_rotate_crash.result b/storage/rocksdb/mysql-test/rocksdb/r/binlog_rotate_crash.result new file mode 100644 index 00000000000..1b22141813a --- /dev/null +++ b/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; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/binlog_rotate_crash.test b/storage/rocksdb/mysql-test/rocksdb/t/binlog_rotate_crash.test new file mode 100644 index 00000000000..d2261f508f8 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/binlog_rotate_crash.test @@ -0,0 +1,30 @@ +--source include/have_rocksdb.inc +--source include/have_log_bin.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; +