Skip to content

Commit 7655196

Browse files
committed
Enable basic XA between MyRocks and the binlog
This allows basic master crash-safety - Un-comment and update relevant parts of the code - Make rocksdb_rpl suite work like other MyRocks testsuites (load the MyRocks plugin, don't start if it is not compiled in, etc) - For now, disable all tests in the rocksdb_rpl suite. - MariaDB-fication of rpl_rocksdb_2p_crash_recover test.
1 parent a544225 commit 7655196

14 files changed

+116
-30
lines changed

storage/rocksdb/ha_rocksdb.cc

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ static std::shared_ptr<Rdb_tbl_prop_coll_factory> properties_collector_factory;
170170
Rdb_dict_manager dict_manager;
171171
Rdb_cf_manager cf_manager;
172172
Rdb_ddl_manager ddl_manager;
173-
const char *m_mysql_gtid;
174173
Rdb_binlog_manager binlog_manager;
175174

176175
#ifndef _WIN32
@@ -1668,8 +1667,11 @@ class Rdb_transaction {
16681667
public:
16691668
const char *m_mysql_log_file_name;
16701669
my_off_t m_mysql_log_offset;
1670+
#ifdef MARIAROCKS_NOT_YET
1671+
// TODO: MariaDB probably doesn't need these at all:
16711672
const char *m_mysql_gtid;
16721673
const char *m_mysql_max_gtid;
1674+
#endif
16731675
String m_detailed_error;
16741676
int64_t m_snapshot_timestamp = 0;
16751677
bool m_ddl_transaction;
@@ -1856,13 +1858,10 @@ class Rdb_transaction {
18561858
rollback();
18571859
return true;
18581860
} else {
1859-
#ifdef MARIAROCKS_NOT_YET
1860-
my_core::thd_binlog_pos(m_thd, &m_mysql_log_file_name,
1861-
&m_mysql_log_offset, &m_mysql_gtid,
1862-
&m_mysql_max_gtid);
1861+
mysql_bin_log_commit_pos(m_thd, &m_mysql_log_offset,
1862+
&m_mysql_log_file_name);
18631863
binlog_manager.update(m_mysql_log_file_name, m_mysql_log_offset,
1864-
m_mysql_max_gtid, get_write_batch());
1865-
#endif
1864+
get_write_batch());
18661865
return commit_no_binlog();
18671866
}
18681867
}
@@ -2683,26 +2682,25 @@ static bool rocksdb_flush_wal(handlerton* hton __attribute__((__unused__)))
26832682
*/
26842683
static int rocksdb_prepare(handlerton* hton, THD* thd, bool prepare_tx)
26852684
{
2686-
#ifdef MARIAROCKS_NOT_YET
26872685
// This is "ASYNC_COMMIT" feature which is only in webscalesql
26882686
bool async=false;
2689-
#endif
26902687

26912688
Rdb_transaction *&tx = get_tx_from_thd(thd);
26922689
if (!tx->can_prepare()) {
26932690
return HA_EXIT_FAILURE;
26942691
}
2695-
#ifdef MARIAROCKS_NOT_YET // disable prepare/commit
26962692
if (prepare_tx ||
26972693
(!my_core::thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
26982694
/* We were instructed to prepare the whole transaction, or
26992695
this is an SQL statement end and autocommit is on */
2696+
#ifdef MARIAROCKS_NOT_YET // disable prepare/commit
27002697
std::vector<st_slave_gtid_info> slave_gtid_info;
27012698
my_core::thd_slave_gtid_info(thd, &slave_gtid_info);
27022699
for (const auto &it : slave_gtid_info) {
27032700
rocksdb::WriteBatchBase *const write_batch = tx->get_blind_write_batch();
27042701
binlog_manager.update_slave_gtid_info(it.id, it.db, it.gtid, write_batch);
27052702
}
2703+
#endif
27062704

27072705
if (tx->is_two_phase()) {
27082706
if (thd->durability_property == HA_IGNORE_DURABILITY || async) {
@@ -2713,10 +2711,10 @@ static int rocksdb_prepare(handlerton* hton, THD* thd, bool prepare_tx)
27132711
if (!tx->prepare(rdb_xid_to_string(xid))) {
27142712
return HA_EXIT_FAILURE;
27152713
}
2716-
if (thd->durability_property == HA_IGNORE_DURABILITY
2714+
if (thd->durability_property == HA_IGNORE_DURABILITY )
27172715
#ifdef MARIAROCKS_NOT_YET
27182716
&&
2719-
THDVAR(thd, flush_log_at_trx_commit)) {
2717+
THDVAR(thd, flush_log_at_trx_commit))
27202718
#endif
27212719
{
27222720
#ifdef MARIAROCKS_NOT_YET
@@ -2733,7 +2731,6 @@ static int rocksdb_prepare(handlerton* hton, THD* thd, bool prepare_tx)
27332731

27342732
DEBUG_SYNC(thd, "rocksdb.prepared");
27352733
}
2736-
#endif
27372734
return HA_EXIT_SUCCESS;
27382735
}
27392736

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'rocksdb' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
2+
{
3+
--skip Test requires engine RocksDB.
4+
}
5+
6+
--disable_query_log
7+
# Table statistics can vary depending on when the memtables are flushed, so
8+
# flush them at the beginning of the test to ensure the test runs consistently.
9+
set global rocksdb_force_flush_memtable_now = true;
10+
--enable_query_log
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--loose-enable-rocksdb
2+
--loose-enable-rocksdb_global_info
3+
--loose-enable-rocksdb_ddl
4+
--loose-enable-rocksdb_cf_options
5+
--loose-enable_rocksdb_perf_context
6+
--loose-enable_rocksdb_perf_context_global
7+
--loose-enable-rocksdb_index_file_map
8+
--loose-enable-rocksdb_dbstats
9+
--loose-enable-rocksdb_cfstats
10+
--loose-enable-rocksdb_lock_info
11+
--loose-enable-rocksdb_trx
12+
--loose-enable-rocksdb_locks
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
!include include/default_my.cnf
2+
3+
[server]
4+
skip-innodb
5+
default-storage-engine=rocksdb
6+
7+
8+
sql-mode=NO_ENGINE_SUBSTITUTION
9+
explicit-defaults-for-timestamp=1
10+
loose-rocksdb_lock_wait_timeout=1
11+
loose-rocksdb_strict_collation_check=0
12+
13+
loose-rocksdb-flush-log-at-trx-commit=0
14+
15+
# The following is to get rid of the harmless
16+
# "Deadlock found when trying to get lock" errors, see MDEV-12285.
17+
log-warnings=1

storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_2pc_crash_recover.result

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
DROP TABLE IF EXISTS t1;
22
create table t1 (a int primary key, msg varchar(255)) engine=rocksdb;
33
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
4-
SET SESSION debug="d,crash_commit_after_prepare";
4+
SET SESSION debug_dbug="d,crash_commit_after_prepare";
55
insert into t1 values (1, 'dogz');
66
select * from t1;
77
a msg
88
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
9-
SET SESSION debug="d,crash_commit_after_log";
9+
SET SESSION debug_dbug="d,crash_commit_after_log";
1010
insert into t1 values (2, 'catz'), (3, 'men');
1111
select * from t1;
1212
a msg
1313
2 catz
1414
3 men
1515
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
16-
SET SESSION debug="d,crash_commit_after";
16+
SET SESSION debug_dbug="d,crash_commit_after";
1717
insert into t1 values (4, 'cars'), (5, 'foo');
1818
select * from t1;
1919
a msg
@@ -22,7 +22,7 @@ a msg
2222
4 cars
2323
5 foo
2424
SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
25-
SET SESSION debug="d,crash_commit_after_log";
25+
SET SESSION debug_dbug="d,crash_commit_after_log";
2626
insert into t1 values (6, 'shipz'), (7, 'tankz');
2727
select * from t1;
2828
a msg
@@ -31,7 +31,7 @@ a msg
3131
4 cars
3232
5 foo
3333
SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
34-
SET SESSION debug="d,crash_commit_after";
34+
SET SESSION debug_dbug="d,crash_commit_after";
3535
insert into t1 values (8, 'space'), (9, 'time');
3636
select * from t1;
3737
a msg
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--ignore-db-dirs=.rocksdb --plugin-load=$HA_ROCKSDB_SO --default-storage-engine=rocksdb
2+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package My::Suite::Rocksdb;
2+
3+
#
4+
# Note: ../rocksdb_sys_vars/suite.pm file has a similar
5+
# function. If you modify this file, consider modifying that one, too.
6+
#
7+
@ISA = qw(My::Suite);
8+
use My::Find;
9+
use File::Basename;
10+
use strict;
11+
12+
sub is_default { not $::opt_embedded_server }
13+
14+
my $sst_dump=
15+
::mtr_exe_maybe_exists(
16+
"$::bindir/storage/rocksdb$::opt_vs_config/sst_dump",
17+
"$::path_client_bindir/sst_dump");
18+
return "RocksDB is not compiled, no sst_dump" unless $sst_dump;
19+
$ENV{MARIAROCKS_SST_DUMP}="$sst_dump";
20+
21+
# Temporarily disable testing under valgrind, due to MDEV-12439
22+
return "RocksDB tests disabled under valgrind" if ($::opt_valgrind);
23+
24+
bless { };
25+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
# rpl_rocksdb_2pc_crash_recover
3+
4+
consistent_snapshot_mixed_engines : Didn't try with MariaDB, yet
5+
multiclient_2pc : Didn't try with MariaDB, yet
6+
rpl_crash_safe_wal_corrupt : Didn't try with MariaDB, yet
7+
rpl_gtid_crash_safe : Didn't try with MariaDB, yet
8+
rpl_gtid_crash_safe_wal_corrupt : Didn't try with MariaDB, yet
9+
rpl_gtid_rocksdb_sys_header : Didn't try with MariaDB, yet
10+
rpl_no_unique_check_on_lag : Didn't try with MariaDB, yet
11+
rpl_no_unique_check_on_lag_mts : Didn't try with MariaDB, yet
12+
rpl_rocksdb_snapshot : Didn't try with MariaDB, yet
13+
rpl_rocksdb_snapshot_without_gtid : Didn't try with MariaDB, yet
14+
rpl_rocksdb_stress_crash : Didn't try with MariaDB, yet
15+
rpl_skip_trx_api_binlog_format : Didn't try with MariaDB, yet
16+
singledelete_idempotent_recovery : Didn't try with MariaDB, yet
17+
singledelete_idempotent_table : Didn't try with MariaDB, yet
18+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates --rocksdb_flush_log_at_trx_commit=1 --rocksdb_write_disable_wal=OFF
1+
--log_bin --log_slave_updates --rocksdb_flush_log_at_trx_commit=1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates
1+
--log_bin --log_slave_updates

0 commit comments

Comments
 (0)