Skip to content

Commit bf310b4

Browse files
committed
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) Followup: the test requires debug sync facility (This is a backport to 10.5)
1 parent 5b678d9 commit bf310b4

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

sql/sql_repl.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3966,6 +3966,8 @@ int reset_master(THD* thd, rpl_gtid *init_state, uint32 init_state_len,
39663966
ret= mysql_bin_log.reset_logs(thd, 1, init_state, init_state_len,
39673967
next_log_number);
39683968
repl_semisync_master.after_reset_master();
3969+
DBUG_EXECUTE_IF("crash_after_reset_master", DBUG_SUICIDE(););
3970+
39693971
return ret;
39703972
}
39713973

storage/rocksdb/ha_rocksdb.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4113,7 +4113,7 @@ static int rocksdb_recover(handlerton* hton, XID* xid_list, uint len)
41134113

41144114
static void rocksdb_checkpoint_request(void *cookie)
41154115
{
4116-
const rocksdb::Status s= rdb->SyncWAL();
4116+
const rocksdb::Status s= rdb->FlushWAL(true);
41174117
//TODO: what to do on error?
41184118
if (s.ok())
41194119
{
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# MDEV-25305: MyRocks: Killing server during RESET MASTER can lose last transactions
3+
#
4+
set global rocksdb_flush_log_at_trx_commit=1;
5+
create table t1 (a int, b int, key(a)) engine=rocksdb;
6+
insert into t1 values (1,1),(2,2);
7+
select * from t1;
8+
a b
9+
1 1
10+
2 2
11+
flush tables;
12+
set @@debug_dbug="+d,crash_after_reset_master";
13+
RESET MASTER;
14+
# Must show the inserted rows:
15+
select * from t1;
16+
a b
17+
1 1
18+
2 2
19+
drop table t1;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--source include/have_rocksdb.inc
2+
--source include/have_log_bin.inc
3+
--source include/have_debug_sync.inc
4+
5+
--echo #
6+
--echo # MDEV-25305: MyRocks: Killing server during RESET MASTER can lose last transactions
7+
--echo #
8+
9+
set global rocksdb_flush_log_at_trx_commit=1;
10+
11+
create table t1 (a int, b int, key(a)) engine=rocksdb;
12+
insert into t1 values (1,1),(2,2);
13+
select * from t1;
14+
flush tables;
15+
16+
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
17+
restart
18+
EOF
19+
20+
set @@debug_dbug="+d,crash_after_reset_master";
21+
22+
--disable_reconnect
23+
--error 0,2013
24+
RESET MASTER;
25+
--enable_reconnect
26+
--source include/wait_until_connected_again.inc
27+
--echo # Must show the inserted rows:
28+
select * from t1;
29+
30+
drop table t1;
31+

0 commit comments

Comments
 (0)