Skip to content

Commit ae0759a

Browse files
committed
MDEV-13602: rocksdb.index_merge_rocksdb2 failed in buildbot
- Add include/index_merge*. Upstream has different files than MariaDB, use copies theirs, not ours. - There was a prblem with running "DDL-like" commands with binlog=ON: MariaDB sets binlog_format=STATEMENT for the duration of such command to prevent RBR replication from catching (and replicating) updates to system tables. However, MyRocks tries to prevent any writes to MyRocks tables with binlog_format!=ROW. - Added exceptions for DDL-type commands (ANALYZE TABLE, OPTIMIZE TABLE) - Added special handling for "LOCK TABLE(s) myrocks_table WRITE".
1 parent 06b4b99 commit ae0759a

10 files changed

+2122
-27
lines changed

storage/rocksdb/ha_rocksdb.cc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9321,6 +9321,7 @@ const char *ha_rocksdb::thd_rocksdb_tmpdir() {
93219321
return (tmp_dir);
93229322
}
93239323

9324+
93249325
/**
93259326
@return
93269327
HA_EXIT_SUCCESS OK
@@ -9334,9 +9335,27 @@ int ha_rocksdb::external_lock(THD *const thd, int lock_type) {
93349335
int res = HA_EXIT_SUCCESS;
93359336
int binlog_format = my_core::thd_binlog_format(thd);
93369337
bool unsafe_for_binlog = THDVAR(ha_thd(), unsafe_for_binlog);
9338+
9339+
/*
9340+
A note about (*) below: In fb/mysql, LOCK TABLE myrocks_table WRITE
9341+
- produces an error when @@binlog_format='ROW'.
9342+
- does not produce an error with @@binlog_format='STATEMENT'
9343+
9344+
We cannot easily provide this behavior in MariaDB, because LOCK ROWS
9345+
changes @@binlog_format for the duration of the statement.
9346+
9347+
Instead we will make the check in ha_rocksdb::start_stmt and will produce
9348+
an error in the first DML statement done under LOCK TABLE
9349+
9350+
(**) - The same happens for other "DDL-type" commands, so allow them here
9351+
as well.
9352+
*/
93379353
if (lock_type == F_WRLCK && !thd->rgi_slave && !unsafe_for_binlog &&
93389354
binlog_format != BINLOG_FORMAT_ROW &&
93399355
binlog_format != BINLOG_FORMAT_UNSPEC &&
9356+
thd->lex->sql_command != SQLCOM_LOCK_TABLES && // (*)
9357+
thd->lex->sql_command != SQLCOM_ANALYZE && // (**)
9358+
thd->lex->sql_command != SQLCOM_OPTIMIZE && // (**)
93409359
my_core::thd_binlog_filter_ok(thd)) {
93419360
my_error(ER_REQUIRE_ROW_BINLOG_FORMAT, MYF(0));
93429361
DBUG_RETURN(HA_ERR_UNSUPPORTED);
@@ -9434,6 +9453,20 @@ int ha_rocksdb::external_lock(THD *const thd, int lock_type) {
94349453
int ha_rocksdb::start_stmt(THD *const thd, thr_lock_type lock_type) {
94359454
DBUG_ENTER_FUNC();
94369455

9456+
/*
9457+
MariaDB: the following is a copy of the check in ha_rocksdb::external_lock:
9458+
*/
9459+
int binlog_format = my_core::thd_binlog_format(thd);
9460+
bool unsafe_for_binlog = THDVAR(ha_thd(), unsafe_for_binlog);
9461+
if (lock_type >= TL_WRITE_ALLOW_WRITE &&
9462+
!thd->rgi_slave && !unsafe_for_binlog &&
9463+
binlog_format != BINLOG_FORMAT_ROW &&
9464+
binlog_format != BINLOG_FORMAT_UNSPEC &&
9465+
my_core::thd_binlog_filter_ok(thd)) {
9466+
my_error(ER_REQUIRE_ROW_BINLOG_FORMAT, MYF(0));
9467+
DBUG_RETURN(HA_ERR_UNSUPPORTED);
9468+
}
9469+
94379470
DBUG_ASSERT(thd != nullptr);
94389471

94399472
Rdb_transaction *const tx = get_or_create_tx(thd);

0 commit comments

Comments
 (0)