summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2021-03-30 16:17:10 +0300
committerSergei Petrunia <psergey@askmonty.org>2021-03-31 10:26:00 +0300
commitbf310b4cfb5c275f8c555d469ef310bdd1219920 (patch)
tree7ef537077991c2739e1c8d88e5bb1f48560ef04e
parent5b678d9ea4aa3b5ed4c030a9bb5e7d15c3ff8804 (diff)
downloadmariadb-git-bf310b4cfb5c275f8c555d469ef310bdd1219920.tar.gz
MDEV-25305: MyRocks: Killing server during RESET MASTER can lose last transactionsbb-10.5-mdev25305
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)
-rw-r--r--sql/sql_repl.cc2
-rw-r--r--storage/rocksdb/ha_rocksdb.cc2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/binlog_rotate_crash.result19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/binlog_rotate_crash.test31
4 files changed, 53 insertions, 1 deletions
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 0e63ea50809..f89601b1789 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..dd42001b89e
--- /dev/null
+++ b/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;
+