Commit 5173e396 authored by Sergei Petrunia's avatar Sergei Petrunia

Copy of

commit dcd9379eb5707bc7514a2ff4d9127790356505cb
Author: Manuel Ung <mung@fb.com>
Date:   Fri Jun 14 10:38:17 2019 -0700

    Skip valgrind for rocksdb.force_shutdown

    Summary:
    This test does unclean shutdown, and leaks memory.

    Squash with: D15749084

    Reviewed By: hermanlee

    Differential Revision: D15828957

    fbshipit-source-id: 30541455d74
parent faa4d8f8
--- # Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# This is the output of clang-format-5.0 --style=google --dump-config,
# except for changes mentioned below. We lock the style so that any newer
# version of clang-format will give the same result; as time goes, we may
# update this list, requiring newer versions of clang-format.
Language: Cpp Language: Cpp
# BasedOnStyle: LLVM # BasedOnStyle: Google
AccessModifierOffset: -2 AccessModifierOffset: -1
AlignAfterOpenBracket: Align AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false AlignEscapedNewlines: Left
AlignOperands: true AlignOperands: true
AlignTrailingComments: true AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: false AlwaysBreakTemplateDeclarations: true
BinPackArguments: true BinPackArguments: true
BinPackParameters: true BinPackParameters: true
BraceWrapping: BraceWrapping:
...@@ -32,62 +58,80 @@ BraceWrapping: ...@@ -32,62 +58,80 @@ BraceWrapping:
BeforeCatch: false BeforeCatch: false
BeforeElse: false BeforeElse: false
IndentBraces: false IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true BreakStringLiterals: true
ColumnLimit: 80 ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:' CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4 ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4 ContinuationIndentWidth: 4
Cpp11BracedListStyle: true Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false DisableFormat: false
ExperimentalAutoDetectBinPacking: false ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories: IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2 Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*' - Regex: '.*'
Priority: 1 Priority: 3
IncludeIsMainRegex: '$' IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: false IndentCaseLabels: true
IndentWidth: 2 IndentWidth: 2
IndentWrappedFunctionNames: false IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: '' MacroBlockBegin: ''
MacroBlockEnd: '' MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1 MaxEmptyLinesToKeep: 1
NamespaceIndentation: None NamespaceIndentation: None
ObjCBlockIndentWidth: 2 ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300 PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120 PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000 PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000 PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60 PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
ReflowComments: true ReflowComments: true
SortIncludes: true SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1 SpacesBeforeTrailingComments: 2
SpacesInAngles: false SpacesInAngles: false
SpacesInContainerLiterals: true SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false SpacesInCStyleCastParentheses: false
SpacesInParentheses: false SpacesInParentheses: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8 TabWidth: 8
UseTab: Never UseTab: Never
JavaScriptQuotes: Leave
... # We declare one specific pointer style since right alignment is dominant in
# the MySQL code base (default --style=google has DerivePointerAlignment true).
DerivePointerAlignment: false
PointerAlignment: Right
# MySQL source code is allowed to use C++11 features.
Standard: Cpp11
...@@ -60,6 +60,7 @@ SET(ROCKSDB_SOURCES ...@@ -60,6 +60,7 @@ SET(ROCKSDB_SOURCES
rdb_datadic.cc rdb_datadic.h rdb_datadic.cc rdb_datadic.h
rdb_cf_options.cc rdb_cf_options.h rdb_cf_options.cc rdb_cf_options.h
rdb_cf_manager.cc rdb_cf_manager.h rdb_cf_manager.cc rdb_cf_manager.h
rdb_converter.cc rdb_converter.h
properties_collector.cc properties_collector.h properties_collector.cc properties_collector.h
event_listener.cc event_listener.h event_listener.cc event_listener.h
rdb_i_s.cc rdb_i_s.h rdb_i_s.cc rdb_i_s.h
...@@ -71,6 +72,7 @@ SET(ROCKSDB_SOURCES ...@@ -71,6 +72,7 @@ SET(ROCKSDB_SOURCES
rdb_sst_info.cc rdb_sst_info.h rdb_sst_info.cc rdb_sst_info.h
rdb_utils.cc rdb_utils.h rdb_buff.h rdb_utils.cc rdb_utils.h rdb_buff.h
rdb_threads.cc rdb_threads.h rdb_threads.cc rdb_threads.h
nosql_access.cc nosql_access.h
${ROCKSDB_LIB_SOURCES} ${ROCKSDB_LIB_SOURCES}
) )
...@@ -81,6 +83,25 @@ ELSE() ...@@ -81,6 +83,25 @@ ELSE()
ENDIF() ENDIF()
SET(rocksdb_static_libs ) SET(rocksdb_static_libs )
IF (WITH_JEMALLOC)
FIND_LIBRARY(JEMALLOC_LIBRARY
NAMES libjemalloc${PIC_EXT}.a jemalloc
HINTS ${WITH_JEMALLOC}/lib)
SET(rocksdb_static_libs ${rocksdb_static_libs}
${JEMALLOC_LIBRARY})
ADD_DEFINITIONS(-DROCKSDB_JEMALLOC)
ADD_DEFINITIONS(-DROCKSDB_MALLOC_USABLE_SIZE)
ENDIF()
IF (WITH_UNWIND)
FIND_LIBRARY(UNWIND_LIBRARY
NAMES libunwind${PIC_EXT}.a unwind
HINTS ${WITH_UNWIND}/lib)
SET(rocksdb_static_libs ${rocksdb_static_libs}
${UNWIND_LIBRARY})
ENDIF()
IF (WITH_SNAPPY) IF (WITH_SNAPPY)
FIND_LIBRARY(SNAPPY_LIBRARY FIND_LIBRARY(SNAPPY_LIBRARY
NAMES libsnappy${PIC_EXT}.a snappy NAMES libsnappy${PIC_EXT}.a snappy
...@@ -111,6 +132,7 @@ ENDIF() ...@@ -111,6 +132,7 @@ ENDIF()
IF (WITH_ZSTD) IF (WITH_ZSTD)
SET(rocksdb_static_libs ${rocksdb_static_libs} ${ZSTD_LIBRARY}) SET(rocksdb_static_libs ${rocksdb_static_libs} ${ZSTD_LIBRARY})
ADD_DEFINITIONS(-DZSTD) ADD_DEFINITIONS(-DZSTD)
ADD_DEFINITIONS(-DZSTD_STATIC_LINKING_ONLY)
ENDIF() ENDIF()
IF (WITH_TBB) IF (WITH_TBB)
...@@ -129,7 +151,7 @@ IF (HAVE_ZLIB_H) ...@@ -129,7 +151,7 @@ IF (HAVE_ZLIB_H)
SET(rocksdb_static_libs ${rocksdb_static_libs} ${ZLIB_LIBRARY}) SET(rocksdb_static_libs ${rocksdb_static_libs} ${ZLIB_LIBRARY})
ENDIF() ENDIF()
SET(rocksdb_static_libs ${rocksdb_static_libs} "-lrt") SET(rocksdb_static_libs ${rocksdb_static_libs} "-lrt" "-ldl" "-lpthread")
MYSQL_ADD_PLUGIN(rocksdb_se ${ROCKSDB_SOURCES} STORAGE_ENGINE DEFAULT STATIC_ONLY MYSQL_ADD_PLUGIN(rocksdb_se ${ROCKSDB_SOURCES} STORAGE_ENGINE DEFAULT STATIC_ONLY
LINK_LIBRARIES ${rocksdb_static_libs} LINK_LIBRARIES ${rocksdb_static_libs}
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
namespace myrocks { namespace myrocks {
static std::vector<Rdb_index_stats> static std::vector<Rdb_index_stats> extract_index_stats(
extract_index_stats(const std::vector<std::string> &files, const std::vector<std::string> &files,
const rocksdb::TablePropertiesCollection &props) { const rocksdb::TablePropertiesCollection &props) {
std::vector<Rdb_index_stats> ret; std::vector<Rdb_index_stats> ret;
for (auto fn : files) { for (auto fn : files) {
...@@ -85,6 +85,7 @@ void Rdb_event_listener::OnExternalFileIngested( ...@@ -85,6 +85,7 @@ void Rdb_event_listener::OnExternalFileIngested(
void Rdb_event_listener::OnBackgroundError( void Rdb_event_listener::OnBackgroundError(
rocksdb::BackgroundErrorReason reason, rocksdb::Status *status) { rocksdb::BackgroundErrorReason reason, rocksdb::Status *status) {
rdb_log_status_error(*status, "Error detected in background"); rdb_log_status_error(*status, "Error detected in background");
// NO_LINT_DEBUG
sql_print_error("RocksDB: BackgroundErrorReason: %d", (int)reason); sql_print_error("RocksDB: BackgroundErrorReason: %d", (int)reason);
if (status->IsCorruption()) { if (status->IsCorruption()) {
rdb_persist_corruption_marker(); rdb_persist_corruption_marker();
......
...@@ -22,7 +22,7 @@ namespace myrocks { ...@@ -22,7 +22,7 @@ namespace myrocks {
class Rdb_ddl_manager; class Rdb_ddl_manager;
class Rdb_event_listener : public rocksdb::EventListener { class Rdb_event_listener : public rocksdb::EventListener {
public: public:
Rdb_event_listener(const Rdb_event_listener &) = delete; Rdb_event_listener(const Rdb_event_listener &) = delete;
Rdb_event_listener &operator=(const Rdb_event_listener &) = delete; Rdb_event_listener &operator=(const Rdb_event_listener &) = delete;
...@@ -40,7 +40,7 @@ class Rdb_event_listener : public rocksdb::EventListener { ...@@ -40,7 +40,7 @@ class Rdb_event_listener : public rocksdb::EventListener {
void OnBackgroundError(rocksdb::BackgroundErrorReason reason, void OnBackgroundError(rocksdb::BackgroundErrorReason reason,
rocksdb::Status *status) override; rocksdb::Status *status) override;
private: private:
Rdb_ddl_manager *m_ddl_manager; Rdb_ddl_manager *m_ddl_manager;
void update_index_stats(const rocksdb::TableProperties &props); void update_index_stats(const rocksdb::TableProperties &props);
......
This diff is collapsed.
This diff is collapsed.
...@@ -77,7 +77,7 @@ Rdb_cf_manager &rdb_get_cf_manager(); ...@@ -77,7 +77,7 @@ Rdb_cf_manager &rdb_get_cf_manager();
const rocksdb::BlockBasedTableOptions &rdb_get_table_options(); const rocksdb::BlockBasedTableOptions &rdb_get_table_options();
bool rdb_is_ttl_enabled(); bool rdb_is_ttl_enabled();
bool rdb_is_ttl_read_filtering_enabled(); bool rdb_is_ttl_read_filtering_enabled();
#ifndef NDEBUG #ifndef DBUG_OFF
int rdb_dbug_set_ttl_rec_ts(); int rdb_dbug_set_ttl_rec_ts();
int rdb_dbug_set_ttl_snapshot_ts(); int rdb_dbug_set_ttl_snapshot_ts();
int rdb_dbug_set_ttl_read_filter_ts(); int rdb_dbug_set_ttl_read_filter_ts();
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
namespace myrocks { namespace myrocks {
class Rdb_logger : public rocksdb::Logger { class Rdb_logger : public rocksdb::Logger {
public: public:
explicit Rdb_logger(const rocksdb::InfoLogLevel log_level = explicit Rdb_logger(const rocksdb::InfoLogLevel log_level =
rocksdb::InfoLogLevel::ERROR_LEVEL) rocksdb::InfoLogLevel::ERROR_LEVEL)
: m_mysql_log_level(log_level) {} : m_mysql_log_level(log_level) {}
...@@ -77,7 +77,7 @@ class Rdb_logger : public rocksdb::Logger { ...@@ -77,7 +77,7 @@ class Rdb_logger : public rocksdb::Logger {
m_mysql_log_level = log_level; m_mysql_log_level = log_level;
} }
private: private:
std::shared_ptr<rocksdb::Logger> m_logger; std::shared_ptr<rocksdb::Logger> m_logger;
rocksdb::InfoLogLevel m_mysql_log_level; rocksdb::InfoLogLevel m_mysql_log_level;
}; };
......
...@@ -45,12 +45,14 @@ class Writer(object): ...@@ -45,12 +45,14 @@ class Writer(object):
class StreamWriter(Writer): class StreamWriter(Writer):
stream_cmd= '' stream_cmd= ''
def __init__(self, stream_option): def __init__(self, stream_option, direct = 0):
super(StreamWriter, self).__init__() super(StreamWriter, self).__init__()
if stream_option == 'tar': if stream_option == 'tar':
self.stream_cmd= 'tar chf -' self.stream_cmd= 'tar chf -'
elif stream_option == 'xbstream': elif stream_option == 'xbstream':
self.stream_cmd= 'xbstream -c' self.stream_cmd= 'xbstream -c'
if direct:
self.stream_cmd = self.stream_cmd + ' -d'
else: else:
raise Exception("Only tar or xbstream is supported as streaming option.") raise Exception("Only tar or xbstream is supported as streaming option.")
...@@ -342,6 +344,13 @@ class MySQLUtil: ...@@ -342,6 +344,13 @@ class MySQLUtil:
row = cur.fetchone() row = cur.fetchone()
return row[0] return row[0]
@staticmethod
def is_directio_enabled(dbh):
sql = "SELECT @@global.rocksdb_use_direct_reads"
cur = dbh.cursor()
cur.execute(sql)
row = cur.fetchone()
return row[0]
class BackupRunner: class BackupRunner:
datadir = None datadir = None
...@@ -363,9 +372,7 @@ class BackupRunner: ...@@ -363,9 +372,7 @@ class BackupRunner:
try: try:
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
w = None w = None
if opts.output_stream: if not opts.output_stream:
w = StreamWriter(opts.output_stream)
else:
raise Exception("Currently only streaming backup is supported.") raise Exception("Currently only streaming backup is supported.")
snapshot_dir = opts.checkpoint_directory + '/' + str(backup_round) snapshot_dir = opts.checkpoint_directory + '/' + str(backup_round)
...@@ -373,6 +380,11 @@ class BackupRunner: ...@@ -373,6 +380,11 @@ class BackupRunner:
opts.mysql_password, opts.mysql_password,
opts.mysql_port, opts.mysql_port,
opts.mysql_socket) opts.mysql_socket)
direct = MySQLUtil.is_directio_enabled(dbh)
logger.info("Direct I/O: %d", direct)
w = StreamWriter(opts.output_stream, direct)
if not self.datadir: if not self.datadir:
self.datadir = MySQLUtil.get_datadir(dbh) self.datadir = MySQLUtil.get_datadir(dbh)
logger.info("Set datadir: %s", self.datadir) logger.info("Set datadir: %s", self.datadir)
......
...@@ -3,4 +3,3 @@ rocksdb_write_policy=write_committed ...@@ -3,4 +3,3 @@ rocksdb_write_policy=write_committed
[write_prepared] [write_prepared]
rocksdb_write_policy=write_prepared rocksdb_write_policy=write_prepared
rocksdb_commit_time_batch_for_recovery=on
...@@ -89,20 +89,32 @@ EOF ...@@ -89,20 +89,32 @@ EOF
# Make sure a snapshot held by another user doesn't block the bulk load # Make sure a snapshot held by another user doesn't block the bulk load
connect (other,localhost,root,,); connect (other,localhost,root,,);
set session transaction isolation level repeatable read; set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
start transaction with consistent snapshot; start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
# Assert that there is a pending snapshot
select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
connection default; connection default;
# Update CF to smaller value to create multiple SST in ingestion
eval SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
'$pk_cf_name={write_buffer_size=8m;target_file_size_base=1m};';
set rocksdb_bulk_load=1; set rocksdb_bulk_load=1;
set rocksdb_bulk_load_size=100000; set rocksdb_bulk_load_size=100000;
--disable_query_log --disable_query_log
--echo LOAD DATA INFILE <input_file> INTO TABLE t1; --echo LOAD DATA INFILE <input_file> INTO TABLE t1;
eval LOAD DATA INFILE '$file' INTO TABLE t1; eval LOAD DATA INFILE '$file' INTO TABLE t1;
# There should be no SST being ingested
select * from t1;
--echo LOAD DATA INFILE <input_file> INTO TABLE t2; --echo LOAD DATA INFILE <input_file> INTO TABLE t2;
eval LOAD DATA INFILE '$file' INTO TABLE t2; eval LOAD DATA INFILE '$file' INTO TABLE t2;
# There should be no SST being ingested
select * from t2;
--echo LOAD DATA INFILE <input_file> INTO TABLE t3; --echo LOAD DATA INFILE <input_file> INTO TABLE t3;
eval LOAD DATA INFILE '$file' INTO TABLE t3; eval LOAD DATA INFILE '$file' INTO TABLE t3;
# There should be no SST being ingested
select * from t3;
--enable_query_log --enable_query_log
set rocksdb_bulk_load=0; set rocksdb_bulk_load=0;
......
...@@ -98,9 +98,10 @@ EOF ...@@ -98,9 +98,10 @@ EOF
# Make sure a snapshot held by another user doesn't block the bulk load # Make sure a snapshot held by another user doesn't block the bulk load
connect (other,localhost,root,,); connect (other,localhost,root,,);
set session transaction isolation level repeatable read; set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
start transaction with consistent snapshot; start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
# Assert that there is a pending snapshot
select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
connection default; connection default;
set rocksdb_bulk_load=1; set rocksdb_bulk_load=1;
......
...@@ -52,8 +52,9 @@ let $ID = `SELECT connection_id()`; ...@@ -52,8 +52,9 @@ let $ID = `SELECT connection_id()`;
send SELECT * FROM t0 WHERE value > 0 FOR UPDATE; send SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
connection con2; connection con2;
let $wait_condition = SELECT 1 FROM information_schema.processlist let $wait_condition =
WHERE id = $ID AND state = "Sending data"; SELECT 1 FROM information_schema.processlist
WHERE (id = $ID OR srv_id = $ID) AND state = "Sending data";
--source include/wait_condition.inc --source include/wait_condition.inc
eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level; eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
UPDATE t0 SET VALUE=VALUE+1 WHERE id=190000; UPDATE t0 SET VALUE=VALUE+1 WHERE id=190000;
......
...@@ -52,8 +52,9 @@ let $ID = `SELECT connection_id()`; ...@@ -52,8 +52,9 @@ let $ID = `SELECT connection_id()`;
send SELECT * FROM t0 WHERE value > 0 FOR UPDATE; send SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
connection con2; connection con2;
let $wait_condition = SELECT 1 FROM information_schema.processlist let $wait_condition =
WHERE id = $ID AND state = "Sending data"; SELECT 1 FROM information_schema.processlist
WHERE (id = $ID OR srv_id = $ID) AND state = "Sending data";
--source include/wait_condition.inc --source include/wait_condition.inc
eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level; eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
INSERT INTO t0 VALUES(200001,1), (-1,1); INSERT INTO t0 VALUES(200001,1), (-1,1);
......
...@@ -55,8 +55,9 @@ let $ID = `SELECT connection_id()`; ...@@ -55,8 +55,9 @@ let $ID = `SELECT connection_id()`;
send SELECT * FROM t0 WHERE value > 0 FOR UPDATE; send SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
connection con2; connection con2;
let $wait_condition = SELECT 1 FROM information_schema.processlist let $wait_condition =
WHERE id = $ID AND state = "Sending data"; SELECT 1 FROM information_schema.processlist
WHERE (id = $ID OR srv_id = $ID) AND state = "Sending data";
--source include/wait_condition.inc --source include/wait_condition.inc
eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level; eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
BEGIN; BEGIN;
......
...@@ -55,8 +55,9 @@ let $ID = `SELECT connection_id()`; ...@@ -55,8 +55,9 @@ let $ID = `SELECT connection_id()`;
send SELECT * FROM t0 WHERE value > 0 FOR UPDATE; send SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
connection con2; connection con2;
let $wait_condition = SELECT 1 FROM information_schema.processlist let $wait_condition =
WHERE id = $ID AND state = "Sending data"; SELECT 1 FROM information_schema.processlist
WHERE (id = $ID OR srv_id = $ID) AND state = "Sending data";
--source include/wait_condition.inc --source include/wait_condition.inc
eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level; eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
BEGIN; BEGIN;
......
# Common test pattern for options that control direct i/o
#
# Required input:
# $io_option - name and assignment to enable on server command line
--source include/have_direct_io.inc
--echo Checking direct reads
--let $_mysqld_option=$io_option
--source include/restart_mysqld_with_option.inc
CREATE TABLE t1 (pk INT PRIMARY KEY DEFAULT '0', a INT(11), b CHAR(8)) ENGINE=rocksdb;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (1, 1,'a');
INSERT INTO t1 (a,b) VALUES (2,'b');
set global rocksdb_force_flush_memtable_now=1;
--sorted_result
SELECT a,b FROM t1;
DROP TABLE t1;
# cleanup
--let _$mysqld_option=
--source include/restart_mysqld.inc
...@@ -15,7 +15,7 @@ count(b) ...@@ -15,7 +15,7 @@ count(b)
3000000 3000000
ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE; ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY; ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY;
ERROR HY000: Got error 10 'Operation aborted: Failed to acquire lock due to max_num_locks limit' from ROCKSDB ERROR HY000: Got error 10 'Operation aborted: Failed to acquire lock due to rocksdb_max_row_locks limit' from ROCKSDB
set session rocksdb_bulk_load=1; set session rocksdb_bulk_load=1;
ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY; ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY;
set session rocksdb_bulk_load=0; set session rocksdb_bulk_load=0;
......
...@@ -159,3 +159,24 @@ INSERT INTO t1 (a) VALUES (1); ...@@ -159,3 +159,24 @@ INSERT INTO t1 (a) VALUES (1);
UPDATE t1 SET pk = 3; UPDATE t1 SET pk = 3;
ALTER TABLE t1 AUTO_INCREMENT 2; ALTER TABLE t1 AUTO_INCREMENT 2;
DROP TABLE t1; DROP TABLE t1;
#----------------------------------
# Issue #902 Debug assert in autoincrement with small field type
#----------------------------------
SET auto_increment_increment=100, auto_increment_offset=10;
CREATE TABLE t1(i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551615;
INSERT INTO t1 VALUES (NULL);
ERROR HY000: Failed to read auto-increment value from storage engine
SELECT * FROM t1;
i
ALTER TABLE t1 AUTO_INCREMENT=1;
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1;
i
10
ALTER TABLE t1 AUTO_INCREMENT=18446744073709551615;
INSERT INTO t1 VALUES (NULL);
ERROR HY000: Failed to read auto-increment value from storage engine
SELECT * FROM t1;
i
10
DROP TABLE t1;
...@@ -3,6 +3,7 @@ Warnings: ...@@ -3,6 +3,7 @@ Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[connection master] [connection master]
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
set @save_rocksdb_blind_delete_primary_key=@@session.rocksdb_blind_delete_primary_key; set @save_rocksdb_blind_delete_primary_key=@@session.rocksdb_blind_delete_primary_key;
set @save_rocksdb_master_skip_tx_api=@@session.rocksdb_master_skip_tx_api; set @save_rocksdb_master_skip_tx_api=@@session.rocksdb_master_skip_tx_api;
DROP TABLE IF EXISTS t1,t2; DROP TABLE IF EXISTS t1,t2;
...@@ -17,6 +18,7 @@ SELECT count(*) FROM t1; ...@@ -17,6 +18,7 @@ SELECT count(*) FROM t1;
count(*) count(*)
9000 9000
include/sync_slave_sql_with_master.inc include/sync_slave_sql_with_master.inc
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT count(*) FROM t1; SELECT count(*) FROM t1;
count(*) count(*)
9000 9000
...@@ -71,14 +73,14 @@ count(*) ...@@ -71,14 +73,14 @@ count(*)
call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table test.t1.*Error_code.*"); call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table test.t1.*Error_code.*");
call mtr.add_suppression("Slave: Can't find record in 't1'.*"); call mtr.add_suppression("Slave: Can't find record in 't1'.*");
include/wait_for_slave_sql_error.inc [errno=1032] include/wait_for_slave_sql_error.inc [errno=1032]
set @save_rocksdb_read_free_rpl_tables=@@global.rocksdb_read_free_rpl_tables; set @save_rocksdb_read_free_rpl=@@global.rocksdb_read_free_rpl;
set global rocksdb_read_free_rpl_tables="t.*"; set global rocksdb_read_free_rpl=PK_SK;
START SLAVE; START SLAVE;
include/sync_slave_sql_with_master.inc include/sync_slave_sql_with_master.inc
SELECT count(*) FROM t1; SELECT count(*) FROM t1;
count(*) count(*)
7000 7000
set global rocksdb_read_free_rpl_tables=@save_rocksdb_read_free_rpl_tables; set global rocksdb_read_free_rpl=@save_rocksdb_read_free_rpl;
SET session rocksdb_blind_delete_primary_key=@save_rocksdb_blind_delete_primary_key; SET session rocksdb_blind_delete_primary_key=@save_rocksdb_blind_delete_primary_key;
SET session rocksdb_master_skip_tx_api=@save_rocksdb_master_skip_tx_api; SET session rocksdb_master_skip_tx_api=@save_rocksdb_master_skip_tx_api;
DROP TABLE t1, t2; DROP TABLE t1, t2;
......
include/master-slave.inc
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[connection master]
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
set @save_rocksdb_blind_delete_primary_key=@@session.rocksdb_blind_delete_primary_key;
set @save_rocksdb_master_skip_tx_api=@@session.rocksdb_master_skip_tx_api;
DROP TABLE IF EXISTS t1,t2;
create table t1 (id int primary key, value int, value2 varchar(200)) engine=rocksdb;
create table t2 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
SET session rocksdb_blind_delete_primary_key=1;
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
variable_value-@c
1000
SELECT count(*) FROM t1;
count(*)
9000
include/sync_slave_sql_with_master.inc
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT count(*) FROM t1;
count(*)
9000
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
variable_value-@c
0
SELECT count(*) FROM t2;
count(*)
9000
SET session rocksdb_master_skip_tx_api=1;
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
variable_value-@c
1000
SELECT count(*) FROM t1;
count(*)
8000
SELECT count(*) FROM t2;
count(*)
8000
include/sync_slave_sql_with_master.inc
SELECT count(*) FROM t1;
count(*)
8000
SELECT count(*) FROM t2;
count(*)
8000
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
DELETE FROM t1 WHERE id BETWEEN 3001 AND 4000;
DELETE FROM t2 WHERE id BETWEEN 3001 AND 4000;
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
variable_value-@c
0
SELECT count(*) FROM t1;
count(*)
7000
SELECT count(*) FROM t2;
count(*)
7000
include/sync_slave_sql_with_master.inc
SELECT count(*) FROM t1;
count(*)
7000
SELECT count(*) FROM t2;
count(*)
7000
DELETE FROM t1 WHERE id = 10;
SELECT count(*) FROM t1;
count(*)
7000
call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table test.t1.*Error_code.*");
call mtr.add_suppression("Slave: Can't find record in 't1'.*");
include/wait_for_slave_sql_error.inc [errno=1032]
set @save_rocksdb_read_free_rpl=@@global.rocksdb_read_free_rpl;
set global rocksdb_read_free_rpl=PK_SK;
START SLAVE;
include/sync_slave_sql_with_master.inc
SELECT count(*) FROM t1;
count(*)
7000
set global rocksdb_read_free_rpl=@save_rocksdb_read_free_rpl;
SET session rocksdb_blind_delete_primary_key=@save_rocksdb_blind_delete_primary_key;
SET session rocksdb_master_skip_tx_api=@save_rocksdb_master_skip_tx_api;
DROP TABLE t1, t2;
include/rpl_end.inc
...@@ -21,12 +21,15 @@ select case when variable_value-@c > 0 then 'true' else 'false' end from informa ...@@ -21,12 +21,15 @@ select case when variable_value-@c > 0 then 'true' else 'false' end from informa
case when variable_value-@c > 0 then 'true' else 'false' end case when variable_value-@c > 0 then 'true' else 'false' end
true true
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
set @tmp_force_index_for_range=@@optimizer_force_index_for_range;
set optimizer_force_index_for_range=on;
select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 order by time desc; select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 order by time desc;
id1 id2 link_type visibility data time version id1 id2 link_type visibility data time version
100 100 1 1 100 100 100 100 100 1 1 100 100 100
select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
case when variable_value-@c > 0 then 'true' else 'false' end case when variable_value-@c > 0 then 'true' else 'false' end
true true
set global optimizer_force_index_for_range=@tmp_force_index_for_range;
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type3`) where id1 = 100 and time >= 0 and time <= 9223372036854775807 and visibility = 1 order by time desc; select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type3`) where id1 = 100 and time >= 0 and time <= 9223372036854775807 and visibility = 1 order by time desc;
id1 id2 link_type visibility data time version id1 id2 link_type visibility data time version
...@@ -101,7 +104,7 @@ insert into t1 values (21,2,2,0x12FFFFFFFFFF,1); ...@@ -101,7 +104,7 @@ insert into t1 values (21,2,2,0x12FFFFFFFFFF,1);
explain explain
select * from t1 where kp0=1 and kp1=1 and kp2=0x12FFFFFFFFFF order by kp3 desc; select * from t1 where kp0=1 and kp1=1 and kp2=0x12FFFFFFFFFF order by kp3 desc;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index kp12 kp12 28 NULL # Using where; Using index 1 SIMPLE t1 ref kp12 kp12 20 const,const,const # Using where; Using index
show status like '%rocksdb_bloom_filter_prefix%'; show status like '%rocksdb_bloom_filter_prefix%';
Variable_name Value Variable_name Value
rocksdb_bloom_filter_prefix_checked 0 rocksdb_bloom_filter_prefix_checked 0
......
...@@ -59,4 +59,27 @@ insert into t4 values (1, 0xFFFF, 0xFFF, 12345); ...@@ -59,4 +59,27 @@ insert into t4 values (1, 0xFFFF, 0xFFF, 12345);
# This must not fail an assert: # This must not fail an assert:
select * from t4 force index(kp1) where kp1=0xFFFFFFFF and kp2<=0xFFFFFFFF order by kp2 desc; select * from t4 force index(kp1) where kp1=0xFFFFFFFF and kp2<=0xFFFFFFFF order by kp2 desc;
pk kp1 kp2 col1 pk kp1 kp2 col1
drop table t1,t2,t3,t4; #
# Issue #881: Issue #809 still occurs for reverse scans on forward cfs
#
create table t5 (
id1 bigint not null,
id2 bigint not null,
id3 varchar(100) not null,
id4 int not null,
id5 int not null,
value bigint,
value2 varchar(100),
primary key (id1, id2, id3, id4) COMMENT 'bf5_1'
) engine=ROCKSDB;
insert into t5 select * from t1;
set global rocksdb_force_flush_memtable_now=1;
# An index scan starting from the end of the table:
explain
select * from t5 order by id1 desc,id2 desc, id3 desc, id4 desc limit 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 index NULL PRIMARY 122 NULL 1 NULL
select * from t5 order by id1 desc,id2 desc, id3 desc, id4 desc limit 1;
id1 id2 id3 id4 id5 value value2
1000 2000 2000 10000 10000 1000 aaabbbccc
drop table t1,t2,t3,t4,t5;
...@@ -21,18 +21,20 @@ PRIMARY KEY(pk) COMMENT "cf1", ...@@ -21,18 +21,20 @@ PRIMARY KEY(pk) COMMENT "cf1",
KEY(a) KEY(a)
) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4; ) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
set session transaction isolation level repeatable read; set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0
start transaction with consistent snapshot; start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS'; select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE Has opened snapshots
DB_NUM_SNAPSHOTS 1 1
SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
'cf1={write_buffer_size=8m;target_file_size_base=1m};';
set rocksdb_bulk_load=1; set rocksdb_bulk_load=1;
set rocksdb_bulk_load_size=100000; set rocksdb_bulk_load_size=100000;
LOAD DATA INFILE <input_file> INTO TABLE t1; LOAD DATA INFILE <input_file> INTO TABLE t1;
pk a b
LOAD DATA INFILE <input_file> INTO TABLE t2; LOAD DATA INFILE <input_file> INTO TABLE t2;
pk a b
LOAD DATA INFILE <input_file> INTO TABLE t3; LOAD DATA INFILE <input_file> INTO TABLE t3;
pk a b
set rocksdb_bulk_load=0; set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%'; SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
......
...@@ -21,18 +21,20 @@ PRIMARY KEY(pk) COMMENT "rev:cf1", ...@@ -21,18 +21,20 @@ PRIMARY KEY(pk) COMMENT "rev:cf1",
KEY(a) KEY(a)
) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4; ) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
set session transaction isolation level repeatable read; set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0
start transaction with consistent snapshot; start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS'; select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE Has opened snapshots
DB_NUM_SNAPSHOTS 1 1
SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
'cf1={write_buffer_size=8m;target_file_size_base=1m};';
set rocksdb_bulk_load=1; set rocksdb_bulk_load=1;
set rocksdb_bulk_load_size=100000; set rocksdb_bulk_load_size=100000;
LOAD DATA INFILE <input_file> INTO TABLE t1; LOAD DATA INFILE <input_file> INTO TABLE t1;
pk a b
LOAD DATA INFILE <input_file> INTO TABLE t2; LOAD DATA INFILE <input_file> INTO TABLE t2;
pk a b
LOAD DATA INFILE <input_file> INTO TABLE t3; LOAD DATA INFILE <input_file> INTO TABLE t3;
pk a b
set rocksdb_bulk_load=0; set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%'; SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
......
...@@ -21,18 +21,20 @@ PRIMARY KEY(pk) COMMENT "rev:cf1", ...@@ -21,18 +21,20 @@ PRIMARY KEY(pk) COMMENT "rev:cf1",
KEY(a) KEY(a)
) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4; ) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
set session transaction isolation level repeatable read; set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0
start transaction with consistent snapshot; start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS'; select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE Has opened snapshots
DB_NUM_SNAPSHOTS 1 1
SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
'cf1={write_buffer_size=8m;target_file_size_base=1m};';
set rocksdb_bulk_load=1; set rocksdb_bulk_load=1;
set rocksdb_bulk_load_size=100000; set rocksdb_bulk_load_size=100000;
LOAD DATA INFILE <input_file> INTO TABLE t1; LOAD DATA INFILE <input_file> INTO TABLE t1;
pk a b
LOAD DATA INFILE <input_file> INTO TABLE t2; LOAD DATA INFILE <input_file> INTO TABLE t2;
pk a b
LOAD DATA INFILE <input_file> INTO TABLE t3; LOAD DATA INFILE <input_file> INTO TABLE t3;
pk a b
set rocksdb_bulk_load=0; set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%'; SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
......
...@@ -21,18 +21,20 @@ PRIMARY KEY(pk) COMMENT "cf1", ...@@ -21,18 +21,20 @@ PRIMARY KEY(pk) COMMENT "cf1",
KEY(a) KEY(a)
) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4; ) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
set session transaction isolation level repeatable read; set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0
start transaction with consistent snapshot; start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS'; select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE Has opened snapshots
DB_NUM_SNAPSHOTS 1 1
SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
'cf1={write_buffer_size=8m;target_file_size_base=1m};';
set rocksdb_bulk_load=1; set rocksdb_bulk_load=1;
set rocksdb_bulk_load_size=100000; set rocksdb_bulk_load_size=100000;
LOAD DATA INFILE <input_file> INTO TABLE t1; LOAD DATA INFILE <input_file> INTO TABLE t1;
pk a b
LOAD DATA INFILE <input_file> INTO TABLE t2; LOAD DATA INFILE <input_file> INTO TABLE t2;
pk a b
LOAD DATA INFILE <input_file> INTO TABLE t3; LOAD DATA INFILE <input_file> INTO TABLE t3;
pk a b
set rocksdb_bulk_load=0; set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%'; SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
......
...@@ -58,13 +58,10 @@ ENGINE=ROCKSDB; ...@@ -58,13 +58,10 @@ ENGINE=ROCKSDB;
CREATE TABLE t3(a INT, b INT, PRIMARY KEY(a) COMMENT "cf1") CREATE TABLE t3(a INT, b INT, PRIMARY KEY(a) COMMENT "cf1")
ENGINE=ROCKSDB PARTITION BY KEY() PARTITIONS 4; ENGINE=ROCKSDB PARTITION BY KEY() PARTITIONS 4;
set session transaction isolation level repeatable read; set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0
start transaction with consistent snapshot; start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS'; select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE Has opened snapshots
DB_NUM_SNAPSHOTS 1 1
set rocksdb_bulk_load=1; set rocksdb_bulk_load=1;
set rocksdb_bulk_load_size=100000; set rocksdb_bulk_load_size=100000;
LOAD DATA INFILE <input_file> INTO TABLE t1; LOAD DATA INFILE <input_file> INTO TABLE t1;
......
...@@ -58,13 +58,10 @@ ENGINE=ROCKSDB; ...@@ -58,13 +58,10 @@ ENGINE=ROCKSDB;
CREATE TABLE t3(a INT, b INT, PRIMARY KEY(a) COMMENT "rev:cf1") CREATE TABLE t3(a INT, b INT, PRIMARY KEY(a) COMMENT "rev:cf1")
ENGINE=ROCKSDB PARTITION BY KEY() PARTITIONS 4; ENGINE=ROCKSDB PARTITION BY KEY() PARTITIONS 4;
set session transaction isolation level repeatable read; set session transaction isolation level repeatable read;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0
start transaction with consistent snapshot; start transaction with consistent snapshot;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS'; select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE Has opened snapshots
DB_NUM_SNAPSHOTS 1 1
set rocksdb_bulk_load=1; set rocksdb_bulk_load=1;
set rocksdb_bulk_load_size=100000; set rocksdb_bulk_load_size=100000;
LOAD DATA INFILE <input_file> INTO TABLE t1; LOAD DATA INFILE <input_file> INTO TABLE t1;
......
set debug_sync='RESET';
set global rocksdb_debug_ttl_read_filter_ts = -10;
CREATE TABLE t1 (id INT, value INT, KEY (id), KEY (value)) ENGINE=ROCKSDB;
CREATE TABLE t2 (id INT, value INT) ENGINE=ROCKSDB;
CREATE TABLE t3 (id INT, kp1 INT, PRIMARY KEY (id), KEY(kp1)) ENGINE=ROCKSDB COMMENT='ttl_duration=1';
INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4), (5,5);
INSERT INTO t2 SELECT * FROM t1;
INSERT INTO t3 SELECT * FROM t1;
set debug_sync='rocksdb.check_flags_rmi SIGNAL parked WAIT_FOR go';
SELECT value FROM t1 WHERE value = 3;
set debug_sync='now WAIT_FOR parked';
KILL QUERY $conn1_id;
set debug_sync='now SIGNAL go';
ERROR 70100: Query execution was interrupted
set debug_sync='RESET';
set debug_sync='rocksdb.check_flags_rmi_scan SIGNAL parked WAIT_FOR go';
SELECT DISTINCT(id) FROM t1 WHERE value = 5 AND id IN (1, 3, 5);
set debug_sync='now WAIT_FOR parked';
KILL QUERY $conn1_id;
set debug_sync='now SIGNAL go';
ERROR 70100: Query execution was interrupted
set debug_sync='RESET';
set debug_sync='rocksdb.check_flags_inwd SIGNAL parked WAIT_FOR go';
SELECT value FROM t1 WHERE value > 3;
set debug_sync='now WAIT_FOR parked';
KILL QUERY $conn1_id;
set debug_sync='now SIGNAL go';
ERROR 70100: Query execution was interrupted
set debug_sync='RESET';
set debug_sync='rocksdb.check_flags_rnwd SIGNAL parked WAIT_FOR go';
SELECT id FROM t2;
set debug_sync='now WAIT_FOR parked';
KILL QUERY $conn1_id;
set debug_sync='now SIGNAL go';
ERROR 70100: Query execution was interrupted
set debug_sync='RESET';
set debug_sync='rocksdb.check_flags_ser SIGNAL parked WAIT_FOR go';
SELECT kp1 FROM t3 ORDER BY kp1;
set debug_sync='now WAIT_FOR parked';
KILL QUERY $conn1_id;
set debug_sync='now SIGNAL go';
ERROR 70100: Query execution was interrupted
set debug_sync='RESET';
set global rocksdb_debug_ttl_read_filter_ts = DEFAULT;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
...@@ -5,7 +5,7 @@ connection con1; ...@@ -5,7 +5,7 @@ connection con1;
CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB; CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 12048 ERROR: 50048
connection con2; connection con2;
select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS'; select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
STAT_TYPE VALUE STAT_TYPE VALUE
...@@ -18,7 +18,7 @@ STAT_TYPE VALUE ...@@ -18,7 +18,7 @@ STAT_TYPE VALUE
DB_NUM_SNAPSHOTS 0 DB_NUM_SNAPSHOTS 0
connection con1; connection con1;
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 12048 ERROR: 50048
connection con2; connection con2;
INSERT INTO t1 (a) VALUES (1); INSERT INTO t1 (a) VALUES (1);
connection con1; connection con1;
...@@ -69,7 +69,7 @@ id value value2 ...@@ -69,7 +69,7 @@ id value value2
5 5 5 5 5 5
6 6 6 6 6 6
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 12048 ERROR: 50048
connection con2; connection con2;
INSERT INTO r1 values (7,7,7); INSERT INTO r1 values (7,7,7);
connection con1; connection con1;
...@@ -107,12 +107,12 @@ id value value2 ...@@ -107,12 +107,12 @@ id value value2
7 7 7 7 7 7
8 8 8 8 8 8
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 12048 ERROR: 50048
connection con2; connection con2;
INSERT INTO r1 values (9,9,9); INSERT INTO r1 values (9,9,9);
connection con1; connection con1;
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 12048 ERROR: 50048
connection con2; connection con2;
INSERT INTO r1 values (10,10,10); INSERT INTO r1 values (10,10,10);
connection con1; connection con1;
...@@ -129,7 +129,7 @@ id value value2 ...@@ -129,7 +129,7 @@ id value value2
9 9 9 9 9 9
10 10 10 10 10 10
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 12048 ERROR: 50048
INSERT INTO r1 values (11,11,11); INSERT INTO r1 values (11,11,11);
ERROR: 0 ERROR: 0
SELECT * FROM r1; SELECT * FROM r1;
......
...@@ -125,7 +125,7 @@ id value value2 ...@@ -125,7 +125,7 @@ id value value2
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
ERROR: 0 ERROR: 0
INSERT INTO r1 values (11,11,11); INSERT INTO r1 values (11,11,11);
ERROR: 12045 ERROR: 50045
SELECT * FROM r1; SELECT * FROM r1;
id value value2 id value value2
1 1 1 1 1 1
......
...@@ -20,7 +20,7 @@ set @tmp1=@@rocksdb_verify_row_debug_checksums; ...@@ -20,7 +20,7 @@ set @tmp1=@@rocksdb_verify_row_debug_checksums;
set rocksdb_verify_row_debug_checksums=1; set rocksdb_verify_row_debug_checksums=1;
set session debug= "+d,myrocks_simulate_bad_row_read1"; set session debug= "+d,myrocks_simulate_bad_row_read1";
select * from t1 where pk=1; select * from t1 where pk=1;
ERROR HY000: Got error 199 'Found data corruption.' from ROCKSDB ERROR HY000: Got error 200 'Found data corruption.' from ROCKSDB
set session debug= "-d,myrocks_simulate_bad_row_read1"; set session debug= "-d,myrocks_simulate_bad_row_read1";
set rocksdb_verify_row_debug_checksums=@tmp1; set rocksdb_verify_row_debug_checksums=@tmp1;
select * from t1 where pk=1; select * from t1 where pk=1;
...@@ -28,11 +28,11 @@ pk col1 ...@@ -28,11 +28,11 @@ pk col1
1 1 1 1
set session debug= "+d,myrocks_simulate_bad_row_read2"; set session debug= "+d,myrocks_simulate_bad_row_read2";
select * from t1 where pk=1; select * from t1 where pk=1;
ERROR HY000: Got error 199 'Found data corruption.' from ROCKSDB ERROR HY000: Got error 200 'Found data corruption.' from ROCKSDB
set session debug= "-d,myrocks_simulate_bad_row_read2"; set session debug= "-d,myrocks_simulate_bad_row_read2";
set session debug= "+d,myrocks_simulate_bad_row_read3"; set session debug= "+d,myrocks_simulate_bad_row_read3";
select * from t1 where pk=1; select * from t1 where pk=1;
ERROR HY000: Got error 199 'Found data corruption.' from ROCKSDB ERROR HY000: Got error 200 'Found data corruption.' from ROCKSDB
set session debug= "-d,myrocks_simulate_bad_row_read3"; set session debug= "-d,myrocks_simulate_bad_row_read3";
insert into t1 values(4,'0123456789'); insert into t1 values(4,'0123456789');
select * from t1; select * from t1;
...@@ -56,7 +56,7 @@ pk col1 ...@@ -56,7 +56,7 @@ pk col1
ABCD 1 ABCD 1
set session debug= "+d,myrocks_simulate_bad_pk_read1"; set session debug= "+d,myrocks_simulate_bad_pk_read1";
select * from t2; select * from t2;
ERROR HY000: Got error 199 'Found data corruption.' from ROCKSDB ERROR HY000: Got error 200 'Found data corruption.' from ROCKSDB
set session debug= "-d,myrocks_simulate_bad_pk_read1"; set session debug= "-d,myrocks_simulate_bad_pk_read1";
drop table t2; drop table t2;
create table t2 ( create table t2 (
...@@ -69,6 +69,6 @@ pk col1 ...@@ -69,6 +69,6 @@ pk col1
ABCD 1 ABCD 1
set session debug= "+d,myrocks_simulate_bad_pk_read1"; set session debug= "+d,myrocks_simulate_bad_pk_read1";
select * from t2; select * from t2;
ERROR HY000: Got error 199 'Found data corruption.' from ROCKSDB ERROR HY000: Got error 200 'Found data corruption.' from ROCKSDB
set session debug= "-d,myrocks_simulate_bad_pk_read1"; set session debug= "-d,myrocks_simulate_bad_pk_read1";
drop table t2; drop table t2;
...@@ -8,7 +8,7 @@ ERROR HY000: Table without primary key cannot be created outside mysql schema. ...@@ -8,7 +8,7 @@ ERROR HY000: Table without primary key cannot be created outside mysql schema.
CREATE TABLE IF NOT EXISTS mysql_table_2 (a INT) ENGINE=ROCKSDB; CREATE TABLE IF NOT EXISTS mysql_table_2 (a INT) ENGINE=ROCKSDB;
ERROR HY000: Table without primary key cannot be created outside mysql schema. ERROR HY000: Table without primary key cannot be created outside mysql schema.
CREATE TABLE mysql_table_no_cols ENGINE=ROCKSDB; CREATE TABLE mysql_table_no_cols ENGINE=ROCKSDB;
ERROR HY000: Table without primary key cannot be created outside mysql schema. ERROR 42000: A table must have at least 1 column
CREATE TABLE mysql.mysql_table_2 (a INT) ENGINE=ROCKSDB; CREATE TABLE mysql.mysql_table_2 (a INT) ENGINE=ROCKSDB;
CREATE TABLE mysql_primkey (a INT PRIMARY KEY, b INT, c INT, d INT, INDEX (c)) ENGINE=ROCKSDB; CREATE TABLE mysql_primkey (a INT PRIMARY KEY, b INT, c INT, d INT, INDEX (c)) ENGINE=ROCKSDB;
ALTER TABLE mysql_primkey DROP b, DROP a, ADD (f INT PRIMARY KEY); ALTER TABLE mysql_primkey DROP b, DROP a, ADD (f INT PRIMARY KEY);
...@@ -29,10 +29,24 @@ DROP INDEX `PRIMARY` ON mysql_primkey4; ...@@ -29,10 +29,24 @@ DROP INDEX `PRIMARY` ON mysql_primkey4;
ERROR HY000: Table without primary key cannot be created outside mysql schema. ERROR HY000: Table without primary key cannot be created outside mysql schema.
ALTER TABLE mysql.mysql_table ADD PRIMARY KEY (a); ALTER TABLE mysql.mysql_table ADD PRIMARY KEY (a);
ALTER TABLE mysql.mysql_table DROP PRIMARY KEY; ALTER TABLE mysql.mysql_table DROP PRIMARY KEY;
SET default_storage_engine=ROCKSDB;
CREATE TABLE mysql_noeng(a INT, b INT);
ERROR HY000: Table without primary key cannot be created outside mysql schema.
SET sql_mode="";
CREATE TABLE mysql_noeng_sub(a INT, b INT) ENGINE=BOGUS_ENGINE;
ERROR HY000: Table without primary key cannot be created outside mysql schema.
CREATE TABLE mysql_primkey5 LIKE mysql_primkey;
SET @@global.block_create_no_primary_key = false;
CREATE TABLE mysql_no_primkey (a INT) ENGINE=ROCKSDB;
SET @@global.block_create_no_primary_key = true;
CREATE TABLE mysql_block_no_primkey LIKE mysql_no_primkey;
ERROR HY000: Table without primary key cannot be created outside mysql schema.
DROP TABLE mysql_primkey; DROP TABLE mysql_primkey;
DROP TABLE mysql_primkey2; DROP TABLE mysql_primkey2;
DROP TABLE mysql_primkey3; DROP TABLE mysql_primkey3;
DROP TABLE mysql_primkey4; DROP TABLE mysql_primkey4;
DROP TABLE mysql_primkey5;
DROP TABLE mysql_no_primkey;
USE mysql; USE mysql;
DROP TABLE mysql_table; DROP TABLE mysql_table;
DROP TABLE mysql_table_2; DROP TABLE mysql_table_2;
set @prior_lock_wait_timeout = @@rocksdb_lock_wait_timeout; set @prior_deadlock_detect = @@rocksdb_deadlock_detect; set global rocksdb_deadlock_detect = on; set global rocksdb_lock_wait_timeout = 100000;; set @prior_lock_wait_timeout = @@rocksdb_lock_wait_timeout; set @prior_deadlock_detect = @@rocksdb_deadlock_detect;;
set global rocksdb_deadlock_detect = on; set global rocksdb_lock_wait_timeout = 100000;;
create table t (i int primary key) engine=rocksdb; create table t (i int primary key) engine=rocksdb;
insert into t values (1), (2), (3); insert into t values (1), (2), (3);
begin; begin;
......
set debug_sync='RESET';
drop table if exists t1;
create table t1 (id1 int, id2 int, value int, primary key (id1, id2)) engine=rocksdb;
insert into t1 values (1, 1, 1),(1, 2, 1),(1, 3, 1), (2, 2, 2);
set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
update t1 set value=100 where id1=1;
set debug_sync='now WAIT_FOR parked';
delete from t1 where id1=1 and id2=1;
set debug_sync='now SIGNAL go';
select * from t1 where id1=1 for update;
id1 id2 value
1 2 100
1 3 100
set debug_sync='RESET';
drop table t1;
create table t1 (
pk int not null primary key,
col1 varchar(10)
) engine=rocksdb;
insert into t1 values (1,1),(2,2),(3,3);
set session debug= "+d,myrocks_busy_loop_on_row_read";
select * from t1 where pk=1;
# testing unclean shutdown on stuck instance
# Run shutdown sql command with forcing kill (exit code 127)
shutdown 1;
Got one of the listed errors
# verifying exit code is printed
# restart the server
shutdown 230;
Got one of the listed errors
# restart the server
# verifying SHUTDOWN is refused if exit code > 255
SHUTDOWN 256;
ERROR HY000: exit code must be 0..255
SHUTDOWN 10000;
ERROR HY000: exit code must be 0..255
# verifying SHUTDOWN is refused if instances are not read only
SHUTDOWN 0 read_only;
ERROR HY000: Only read_only instance can be killed.
SHUTDOWN 127 read_only;
ERROR HY000: Only read_only instance can be killed.
SHUTDOWN 127;
Got one of the listed errors
# restart the server
set session debug= "+d,myrocks_busy_loop_on_row_read";
select * from t1 where pk=1;
SET GLOBAL read_only=1;
# verifying SHUTDOWN read_only works with read_only instance
# Run shutdown sql command with forcing kill (exit code 127)
shutdown 255 read_only;
Got one of the listed errors
# restart the server
drop table t1;
This diff is collapsed.
CREATE TABLE t1 (a INT, b CHAR(8), KEY ab(a, b)) ENGINE=rocksdb DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 (a,b) VALUES (76,'bar');
INSERT INTO t1 (a,b) VALUES (35,'foo');
INSERT INTO t1 (a,b) VALUES (77,'baz');
SET debug="+d,dbug.rocksdb.HA_EXTRA_KEYREAD";
SELECT b FROM t1 FORCE INDEX(ab) WHERE a=35;
b
foo
SET debug="-d,dbug.rocksdb.HA_EXTRA_KEYREAD";
DROP TABLE t1;
...@@ -21,9 +21,96 @@ a b ...@@ -21,9 +21,96 @@ a b
5 e 5 e
6 f 6 f
DROP TABLE t1; DROP TABLE t1;
#---------------------------------------- CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a)) ENGINE=rocksdb;
# UNIQUE KEYS are not supported currently INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
#----------------------------------------- INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
ERROR 23000: Duplicate entry '1' for key 'a'
INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
ERROR 23000: Duplicate entry '3' for key 'a'
INSERT INTO t1 (a,b) VALUES (0,'');
SELECT a,b FROM t1;
a b
0
1 a
100 a
2 b
29 n
3 c
30 m
4 d
5 e
6 f
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'d') ON DUPLICATE KEY UPDATE a = a+10;
SELECT a,b FROM t1;
a b
0
1 a
100 a
12345 z
13 c
14 d
2 b
29 n
30 m
5 e
6 f
DROP TABLE t1;
CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a,b)) ENGINE=rocksdb;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
INSERT INTO t1 (a,b) VALUES (100,'b'), (2,'c');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
ERROR 23000: Duplicate entry '1-a' for key 'a'
SELECT a,b FROM t1;
a b
1 a
100 a
100 b
2 b
2 c
29 n
3 c
30 m
4 d
5 e
6 f
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE a = a+VALUES(a);
SELECT a,b FROM t1;
a b
100 a
100 b
2 a
2 b
2 c
24690 z
29 n
3 c
30 m
4 d
5 e
6 f
INSERT INTO t1 (a,b) VALUES (101,'x'),(101,'x');
ERROR 23000: Duplicate entry '101-x' for key 'a'
SELECT a,b FROM t1;
a b
100 a
100 b
2 a
2 b
2 c
24690 z
29 n
3 c
30 m
4 d
5 e
6 f
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb; CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'); INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f'); INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
...@@ -61,3 +148,109 @@ a b ...@@ -61,3 +148,109 @@ a b
5 e 5 e
6 f 6 f
DROP TABLE t1; DROP TABLE t1;
INSERT on DUPLICATE KEY UPDATE with multiple keys
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(255)) ENGINE=rocksdb;
INSERT INTO t1 (a,b) VALUES (1,'a');
INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
SELECT a,b FROM t1;
a b
1 aaaaaaaaaaaaaaaaaa
10 aa
2 aaaaaaa
3 aa
4 aa
5 aa
6 aa
7 aa
8 aa
9 aa
DROP TABLE t1;
INSERT on DUPLICATE KEY UPDATE with secondary key
CREATE TABLE t1 (a INT, b CHAR(8), c INT DEFAULT 0, pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a,b)) ENGINE=rocksdb;
INSERT INTO t1 (a,b) VALUES (1,'a');
INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE c = c + 1;
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b') ON DUPLICATE KEY UPDATE c = c + 1;
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c') ON DUPLICATE KEY UPDATE c = c + 1;
SELECT a,b,c,pk FROM t1;
a b c pk
1 a 22 1
10 j 1 11
2 b 6 3
2 c 4 14
3 c 1 4
4 d 1 5
5 e 1 6
6 f 1 7
7 g 1 8
8 h 1 9
9 i 1 10
DROP TABLE t1;
Disable caching and see if it still functions properly
SELECT @@rocksdb_enable_insert_with_update_caching;
@@rocksdb_enable_insert_with_update_caching
1
SET GLOBAL rocksdb_enable_insert_with_update_caching=0;
SELECT @@rocksdb_enable_insert_with_update_caching;
@@rocksdb_enable_insert_with_update_caching
0
INSERT on DUPLICATE KEY UPDATE with multiple keys
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(255)) ENGINE=rocksdb;
INSERT INTO t1 (a,b) VALUES (1,'a');
INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
SELECT a,b FROM t1;
a b
1 aaaaaaaaaaaaaaaaaa
10 aa
2 aaaaaaa
3 aa
4 aa
5 aa
6 aa
7 aa
8 aa
9 aa
DROP TABLE t1;
INSERT on DUPLICATE KEY UPDATE with secondary key
CREATE TABLE t1 (a INT, b CHAR(8), c INT DEFAULT 0, pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a,b)) ENGINE=rocksdb;
INSERT INTO t1 (a,b) VALUES (1,'a');
INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE c = c + 1;
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b') ON DUPLICATE KEY UPDATE c = c + 1;
INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c') ON DUPLICATE KEY UPDATE c = c + 1;
SELECT a,b,c,pk FROM t1;
a b c pk
1 a 22 1
10 j 1 11
2 b 6 3
2 c 4 14
3 c 1 4
4 d 1 5
5 e 1 6
6 f 1 7
7 g 1 8
8 h 1 9
9 i 1 10
DROP TABLE t1;
Cleanup
SET GLOBAL rocksdb_enable_insert_with_update_caching=1;
...@@ -2,7 +2,7 @@ CREATE TABLE t1 (pk BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT); ...@@ -2,7 +2,7 @@ CREATE TABLE t1 (pk BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
INSERT INTO t1 VALUES (5); INSERT INTO t1 VALUES (5);
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB # Fixed 1 # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL t1 ROCKSDB # Fixed # # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL
INSERT INTO t1 VALUES ('538647864786478647864'); INSERT INTO t1 VALUES ('538647864786478647864');
Warnings: Warnings:
Warning 1264 Out of range value for column 'pk' at row 1 Warning 1264 Out of range value for column 'pk' at row 1
...@@ -21,7 +21,7 @@ pk ...@@ -21,7 +21,7 @@ pk
9223372036854775807 9223372036854775807
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB # Fixed 2 # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL
INSERT INTO t1 VALUES (); INSERT INTO t1 VALUES ();
ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY' ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY'
SELECT * FROM t1; SELECT * FROM t1;
...@@ -30,13 +30,13 @@ pk ...@@ -30,13 +30,13 @@ pk
9223372036854775807 9223372036854775807
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB # Fixed 2 # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (pk TINYINT NOT NULL PRIMARY KEY AUTO_INCREMENT); CREATE TABLE t1 (pk TINYINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
INSERT INTO t1 VALUES (5); INSERT INTO t1 VALUES (5);
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB # Fixed 1 # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL t1 ROCKSDB # Fixed # # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL
INSERT INTO t1 VALUES (1000); INSERT INTO t1 VALUES (1000);
Warnings: Warnings:
Warning 1264 Out of range value for column 'pk' at row 1 Warning 1264 Out of range value for column 'pk' at row 1
...@@ -46,7 +46,7 @@ pk ...@@ -46,7 +46,7 @@ pk
127 127
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB # Fixed 2 # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL
INSERT INTO t1 VALUES (); INSERT INTO t1 VALUES ();
ERROR 23000: Duplicate entry '127' for key 'PRIMARY' ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
SELECT * FROM t1; SELECT * FROM t1;
...@@ -55,7 +55,7 @@ pk ...@@ -55,7 +55,7 @@ pk
127 127
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB # Fixed 2 # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL
INSERT INTO t1 VALUES (); INSERT INTO t1 VALUES ();
ERROR 23000: Duplicate entry '127' for key 'PRIMARY' ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
SELECT * FROM t1; SELECT * FROM t1;
...@@ -64,5 +64,5 @@ pk ...@@ -64,5 +64,5 @@ pk
127 127
SHOW TABLE STATUS LIKE 't1'; SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 ROCKSDB # Fixed 2 # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL
DROP TABLE t1; DROP TABLE t1;
create table test (
a bigint(20) not null,
b bigint(20) not null,
c varchar(500) not null,
d bigint(20) not null,
e bigint(20) not null,
f varchar(500) not null,
g varchar(500) not null,
h varchar(500) not null,
i varchar(1000) not null,
j varchar(16384) not null,
k varchar(200) not null,
l varchar(500) not null,
m varchar(100) not null,
n bigint(20) not null,
primary key (a, b, m, c(100), l(100), d, e, f(100), g(100), h(100), n),
key n (n),
key d (d, a)
) engine = rocksdb default charset = latin1;
Table Op Msg_type Msg_text
test.test analyze status OK
explain
select * from test where d = 10 and a = 10 and b = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE test index_merge PRIMARY,d d,PRIMARY 24,16 NULL # Using intersect(d,PRIMARY); Using where
select * from test where d = 10 and a = 10 and b = 2;
a b c d e f g h i j k l m n
10 2 i 10 950 f g h i j k l m 950
10 2 i 10 951 f g h i j k l m 951
10 2 i 10 952 f g h i j k l m 952
10 2 i 10 953 f g h i j k l m 953
10 2 i 10 954 f g h i j k l m 954
10 2 i 10 955 f g h i j k l m 955
10 2 i 10 956 f g h i j k l m 956
10 2 i 10 957 f g h i j k l m 957
10 2 i 10 958 f g h i j k l m 958
10 2 i 10 959 f g h i j k l m 959
10 2 i 10 960 f g h i j k l m 960
10 2 i 10 961 f g h i j k l m 961
10 2 i 10 962 f g h i j k l m 962
10 2 i 10 963 f g h i j k l m 963
10 2 i 10 964 f g h i j k l m 964
10 2 i 10 965 f g h i j k l m 965
10 2 i 10 966 f g h i j k l m 966
10 2 i 10 967 f g h i j k l m 967
10 2 i 10 968 f g h i j k l m 968
10 2 i 10 969 f g h i j k l m 969
10 2 i 10 970 f g h i j k l m 970
10 2 i 10 971 f g h i j k l m 971
10 2 i 10 972 f g h i j k l m 972
10 2 i 10 973 f g h i j k l m 973
10 2 i 10 974 f g h i j k l m 974
10 2 i 10 975 f g h i j k l m 975
10 2 i 10 976 f g h i j k l m 976
10 2 i 10 977 f g h i j k l m 977
10 2 i 10 978 f g h i j k l m 978
10 2 i 10 979 f g h i j k l m 979
10 2 i 10 980 f g h i j k l m 980
10 2 i 10 981 f g h i j k l m 981
10 2 i 10 982 f g h i j k l m 982
10 2 i 10 983 f g h i j k l m 983
10 2 i 10 984 f g h i j k l m 984
10 2 i 10 985 f g h i j k l m 985
10 2 i 10 986 f g h i j k l m 986
10 2 i 10 987 f g h i j k l m 987
10 2 i 10 988 f g h i j k l m 988
10 2 i 10 989 f g h i j k l m 989
10 2 i 10 990 f g h i j k l m 990
10 2 i 10 991 f g h i j k l m 991
10 2 i 10 992 f g h i j k l m 992
10 2 i 10 993 f g h i j k l m 993
10 2 i 10 994 f g h i j k l m 994
10 2 i 10 995 f g h i j k l m 995
10 2 i 10 996 f g h i j k l m 996
10 2 i 10 997 f g h i j k l m 997
10 2 i 10 998 f g h i j k l m 998
10 2 i 10 999 f g h i j k l m 999
10 2 i 10 1000 f g h i j k l m 1000
drop table test;
CREATE TABLE `t1` (
`a` bigint(20) NOT NULL,
`b` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`u` bigint(20) unsigned NOT NULL,
`d` bigint(20) DEFAULT NULL,
PRIMARY KEY (`a`,`b`),
KEY `d` (`d`)
) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='ttl_duration=1000;ttl_col=u';
INSERT INTO t1 VALUES (100, 'aaabbb', UNIX_TIMESTAMP(), 200);
EXPLAIN SELECT COUNT(*) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL d 9 NULL # Using index
# segfault here without the fix
SELECT COUNT(*) FROM t1;
COUNT(*)
1
DROP TABLE t1;
CREATE TABLE t1(c1 VARCHAR(1) CHARACTER SET 'utf8' COLLATE 'utf8_bin', c2 YEAR, c3 REAL(1,0) UNSIGNED, PRIMARY KEY(c1)) ENGINE=RocksDB;
INSERT INTO t1 VALUES(0,'0','0');
INSERT INTO t1 VALUES('{0}','0','0');
Warnings:
Warning 1265 Data truncated for column 'c1' at row 1
INSERT INTO t1 VALUES('1','0','1');
ALTER TABLE t1 ADD INDEX(c3), ADD UNIQUE (c3);
ERROR 23000: Duplicate entry '0' for key 'c3_2'
SELECT c3 FROM t1 FORCE INDEX(c3) ORDER BY c3;
ERROR 42000: Key 'c3' doesn't exist in table 't1'
DROP TABLE t1;
create table t (i int primary key) engine=rocksdb;
drop table t;
create table t (i int primary key, j int, key(j) comment 'rev:bf5_2') engine=rocksdb;
select RIGHT(HEX(index_number), 2) from information_schema.rocksdb_ddl where table_name = 't';
RIGHT(HEX(index_number), 2)
FE
FF
insert into t values (1, 1);
select j from t order by j asc;
j
1
select j from t order by j desc;
j
1
drop table t;
reset master;
set GLOBAL binlog_format= 'ROW';
SET GLOBAL enable_blind_replace=ON;
set binlog_format=row;
create table t5 (c1 int primary key, c2 int);
insert into t5 values (1, 1);
insert into t5 values (2, 2);
insert into t5 values (3, 3);
select * from t5;
c1 c2
1 1
2 2
3 3
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t5 values (1, 11);
replace into t5 values (2, 22);
replace into t5 values (3, 33);
select case when variable_value-@c = 3 then 'true' else 'false' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
read_free
true
select * from t5;
c1 c2
1 11
2 22
3 33
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; create table t5 (c1 int primary key, c2 int)
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
flush logs;
drop table t5;
reset master;
Replaying binlog events containing blind replace statements should work
select * from t5;
c1 c2
1 11
2 22
3 33
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; create table t5 (c1 int primary key, c2 int)
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
drop table t5;
reset master;
Replaying the same binlog events with blind replace disabled should work
The server should internally convert such events into updates
SET GLOBAL enable_blind_replace=OFF;
select * from t5;
c1 c2
1 11
2 22
3 33
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; create table t5 (c1 int primary key, c2 int)
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t5)
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
set GLOBAL binlog_format=DEFAULT;
SET GLOBAL enable_blind_replace=DEFAULT;
drop table t5;
...@@ -2,7 +2,7 @@ drop table if exists r1; ...@@ -2,7 +2,7 @@ drop table if exists r1;
connect con1,localhost,root,,; connect con1,localhost,root,,;
connect con2,localhost,root,,; connect con2,localhost,root,,;
connection con1; connection con1;
create table r1 (id1 int, id2 int, id3 varchar(100), id4 int, value1 int, value2 int, value3 int, value4 int, primary key (id1, id2, id3, id4)) engine=rocksdb; create table r1 (id1 int, id2 int, id3 varchar(100), id4 int, value1 int, value2 int, value3 int, value4 int, primary key (id1, id2, id3, id4), KEY (value1, value2, value3)) engine=rocksdb;
insert into r1 values (1,1,1,1,1,1,1,1); insert into r1 values (1,1,1,1,1,1,1,1);
insert into r1 values (1,1,1,2,2,2,2,2); insert into r1 values (1,1,1,2,2,2,2,2);
insert into r1 values (1,1,2,1,3,3,3,3); insert into r1 values (1,1,2,1,3,3,3,3);
...@@ -41,7 +41,7 @@ update r1 set value1=value1+100 where id1=1 and id2=1 and id3='1'; ...@@ -41,7 +41,7 @@ update r1 set value1=value1+100 where id1=1 and id2=1 and id3='1';
/*!50601 SET @enable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load=1', 'SET @dummy = 0') */; /*!50601 SET @enable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load=1', 'SET @dummy = 0') */;
/*!50601 PREPARE s FROM @enable_bulk_load */; /*!50601 PREPARE s FROM @enable_bulk_load */;
/*!50601 EXECUTE s */; /*!50601 EXECUTE s */;
-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=3893; -- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
DROP TABLE IF EXISTS `r1`; DROP TABLE IF EXISTS `r1`;
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
...@@ -54,7 +54,8 @@ CREATE TABLE `r1` ( ...@@ -54,7 +54,8 @@ CREATE TABLE `r1` (
`value2` int(11) DEFAULT NULL, `value2` int(11) DEFAULT NULL,
`value3` int(11) DEFAULT NULL, `value3` int(11) DEFAULT NULL,
`value4` int(11) DEFAULT NULL, `value4` int(11) DEFAULT NULL,
PRIMARY KEY (`id1`,`id2`,`id3`,`id4`) PRIMARY KEY (`id1`,`id2`,`id3`,`id4`),
KEY `value1` (`value1`,`value2`,`value3`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1; ) ENGINE=ROCKSDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
/* ORDERING KEY (DESC) : PRIMARY */; /* ORDERING KEY (DESC) : PRIMARY */;
...@@ -77,9 +78,70 @@ UNLOCK TABLES; ...@@ -77,9 +78,70 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*!50601 SELECT count(*) INTO @is_mysql8 FROM information_schema.TABLES WHERE table_schema='performance_schema' AND table_name='session_variables' */;
/*!50601 SET @check_rocksdb = CONCAT( 'SELECT count(*) INTO @is_rocksdb_supported FROM ', IF (@is_mysql8, 'performance', 'information'), '_schema.session_variables WHERE variable_name=\'rocksdb_bulk_load\'') */;
/*!50601 PREPARE s FROM @check_rocksdb */;
/*!50601 EXECUTE s */;
/*!50601 SET @bulk_load_allow_sk = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load_allow_sk=1', 'SET @dummy = 0') */;
/*!50601 PREPARE s FROM @bulk_load_allow_sk */;
/*!50601 EXECUTE s */;
/*!50601 SET @enable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load=1', 'SET @dummy = 0') */;
/*!50601 PREPARE s FROM @enable_bulk_load */;
/*!50601 EXECUTE s */;
-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
DROP TABLE IF EXISTS `r1`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `r1` (
`id1` int(11) NOT NULL DEFAULT '0',
`id2` int(11) NOT NULL DEFAULT '0',
`id3` varchar(100) NOT NULL DEFAULT '',
`id4` int(11) NOT NULL DEFAULT '0',
`value1` int(11) DEFAULT NULL,
`value2` int(11) DEFAULT NULL,
`value3` int(11) DEFAULT NULL,
`value4` int(11) DEFAULT NULL,
PRIMARY KEY (`id1`,`id2`,`id3`,`id4`),
KEY `value1` (`value1`,`value2`,`value3`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
/* ORDERING KEY (DESC) : PRIMARY */;
LOCK TABLES `r1` WRITE;
/*!40000 ALTER TABLE `r1` DISABLE KEYS */;
INSERT INTO `r1` VALUES (2,2,'2',2,16,16,16,16),(2,2,'2',1,15,15,15,15),(2,2,'1',2,14,14,14,14),(2,2,'1',1,13,13,13,13),(2,1,'2',2,12,12,12,12),(2,1,'2',1,11,11,11,11),(2,1,'1',2,10,10,10,10),(2,1,'1',1,9,9,9,9),(1,2,'2',2,8,8,8,8),(1,2,'2',1,7,7,7,7),(1,2,'1',2,6,6,6,6),(1,2,'1',1,5,5,5,5),(1,1,'2',2,4,4,4,4),(1,1,'2',1,3,3,3,3),(1,1,'1',2,2,2,2,2),(1,1,'1',1,1,1,1,1);
/*!40000 ALTER TABLE `r1` ENABLE KEYS */;
UNLOCK TABLES;
/*!50601 SET @disable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load=0', 'SET @dummy = 0') */;
/*!50601 PREPARE s FROM @disable_bulk_load */;
/*!50601 EXECUTE s */;
/*!50601 SET @disable_bulk_load_allow_sk = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load_allow_sk=0', 'SET @dummy = 0') */;
/*!50601 PREPARE s FROM @disable_bulk_load_allow_sk */;
/*!50601 EXECUTE s */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
rollback; rollback;
connection con1; connection con1;
1 2
set @save_default_storage_engine=@@global.default_storage_engine; set @save_default_storage_engine=@@global.default_storage_engine;
SET GLOBAL default_storage_engine=rocksdb; SET GLOBAL default_storage_engine=rocksdb;
...@@ -93,7 +155,7 @@ SET GLOBAL default_storage_engine=rocksdb; ...@@ -93,7 +155,7 @@ SET GLOBAL default_storage_engine=rocksdb;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=3893; -- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
DROP TABLE IF EXISTS `r1`; DROP TABLE IF EXISTS `r1`;
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
...@@ -106,7 +168,8 @@ CREATE TABLE `r1` ( ...@@ -106,7 +168,8 @@ CREATE TABLE `r1` (
`value2` int(11) DEFAULT NULL, `value2` int(11) DEFAULT NULL,
`value3` int(11) DEFAULT NULL, `value3` int(11) DEFAULT NULL,
`value4` int(11) DEFAULT NULL, `value4` int(11) DEFAULT NULL,
PRIMARY KEY (`id1`,`id2`,`id3`,`id4`) PRIMARY KEY (`id1`,`id2`,`id3`,`id4`),
KEY `value1` (`value1`,`value2`,`value3`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1; ) ENGINE=ROCKSDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
/* ORDERING KEY : (null) */; /* ORDERING KEY : (null) */;
...@@ -126,7 +189,7 @@ UNLOCK TABLES; ...@@ -126,7 +189,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
2 3
==== mysqldump with --innodb-stats-on-metadata ==== ==== mysqldump with --innodb-stats-on-metadata ====
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
...@@ -139,7 +202,7 @@ UNLOCK TABLES; ...@@ -139,7 +202,7 @@ UNLOCK TABLES;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=3893; -- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
DROP TABLE IF EXISTS `r1`; DROP TABLE IF EXISTS `r1`;
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
...@@ -152,7 +215,8 @@ CREATE TABLE `r1` ( ...@@ -152,7 +215,8 @@ CREATE TABLE `r1` (
`value2` int(11) DEFAULT NULL, `value2` int(11) DEFAULT NULL,
`value3` int(11) DEFAULT NULL, `value3` int(11) DEFAULT NULL,
`value4` int(11) DEFAULT NULL, `value4` int(11) DEFAULT NULL,
PRIMARY KEY (`id1`,`id2`,`id3`,`id4`) PRIMARY KEY (`id1`,`id2`,`id3`,`id4`),
KEY `value1` (`value1`,`value2`,`value3`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1; ) ENGINE=ROCKSDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
/* ORDERING KEY : (null) */; /* ORDERING KEY : (null) */;
......
SET @prior_rocksdb_perf_context_level = @@rocksdb_perf_context_level;
SET GLOBAL rocksdb_perf_context_level=3;
SET GLOBAL enable_blind_replace=ON;
create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;
c1 c2
1 1
2 2
3 3
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
read_free
true
drop table t1;
create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
create trigger trg before insert on t1 for each row set @a:=1;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;
c1 c2
1 1
2 2
3 3
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
read_free
false
drop table t1;
create table t1(c1 int,c2 int) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;
c1 c2
1 1
2 2
3 3
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
read_free
true
drop table t1;
create table t1(c1 int,c2 int unique) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;
c1 c2
1 1
2 2
3 3
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
read_free
false
drop table t1;
create table t1(c1 int primary key,c2 int unique) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;
c1 c2
1 1
2 2
3 3
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
read_free
false
drop table t1;
create table t1(c1 int primary key,c2 int, key idx1(c2)) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;
c1 c2
1 1
2 2
3 3
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
read_free
false
drop table t1;
SET GLOBAL enable_blind_replace=OFF;
create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;
c1 c2
1 1
2 2
3 3
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
read_free
false
drop table t1;
SET GLOBAL enable_blind_replace=DEFAULT;
SET GLOBAL rocksdb_perf_context_level = @prior_rocksdb_perf_context_level;
SET GLOBAL enable_blind_replace=ON;
create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;
c1 c2
1 1
2 2
3 3
SELECT @@global.enable_blind_replace;
@@global.enable_blind_replace
1
begin;
replace into t1 values(1,11);
SELECT @@global.enable_blind_replace;
@@global.enable_blind_replace
1
begin;
update t1 set c2=22 where c1=1;
commit;
# Reap update.
commit;
select * from t1;
c1 c2
1 22
2 2
3 3
SELECT @@global.enable_blind_replace;
@@global.enable_blind_replace
1
begin;
update t1 set c2=55 where c1=1;
SELECT @@global.enable_blind_replace;
@@global.enable_blind_replace
1
begin;
replace into t1 values(1,66);
commit;
# Reap replace into.
commit;
select * from t1;
c1 c2
1 66
2 2
3 3
drop table t1;
SET GLOBAL enable_blind_replace=DEFAULT;
...@@ -33,6 +33,13 @@ CF_NAME OPTION_TYPE VALUE ...@@ -33,6 +33,13 @@ CF_NAME OPTION_TYPE VALUE
__system__ PREFIX_EXTRACTOR rocksdb.CappedPrefix.24 __system__ PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
cf1 PREFIX_EXTRACTOR rocksdb.CappedPrefix.26 cf1 PREFIX_EXTRACTOR rocksdb.CappedPrefix.26
default PREFIX_EXTRACTOR rocksdb.CappedPrefix.24 default PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
SET @@global.rocksdb_update_cf_options = 'cf2={prefix_extractor=capped:28};';
SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
CF_NAME OPTION_TYPE VALUE
__system__ PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
cf1 PREFIX_EXTRACTOR rocksdb.CappedPrefix.26
cf2 PREFIX_EXTRACTOR rocksdb.CappedPrefix.28
default PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1; SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
COUNT(*) COUNT(*)
......
...@@ -870,11 +870,14 @@ rocksdb_bulk_load_allow_sk OFF ...@@ -870,11 +870,14 @@ rocksdb_bulk_load_allow_sk OFF
rocksdb_bulk_load_allow_unsorted OFF rocksdb_bulk_load_allow_unsorted OFF
rocksdb_bulk_load_size 1000 rocksdb_bulk_load_size 1000
rocksdb_bytes_per_sync 0 rocksdb_bytes_per_sync 0
rocksdb_cache_dump ON
rocksdb_cache_high_pri_pool_ratio 0.000000
rocksdb_cache_index_and_filter_blocks ON rocksdb_cache_index_and_filter_blocks ON
rocksdb_cache_index_and_filter_with_high_priority ON
rocksdb_checksums_pct 100 rocksdb_checksums_pct 100
rocksdb_collect_sst_properties ON rocksdb_collect_sst_properties ON
rocksdb_commit_in_the_middle OFF rocksdb_commit_in_the_middle OFF
rocksdb_commit_time_batch_for_recovery OFF rocksdb_commit_time_batch_for_recovery ON
rocksdb_compact_cf rocksdb_compact_cf
rocksdb_compaction_readahead_size 0 rocksdb_compaction_readahead_size 0
rocksdb_compaction_sequential_deletes 0 rocksdb_compaction_sequential_deletes 0
...@@ -896,9 +899,11 @@ rocksdb_debug_ttl_rec_ts 0 ...@@ -896,9 +899,11 @@ rocksdb_debug_ttl_rec_ts 0
rocksdb_debug_ttl_snapshot_ts 0 rocksdb_debug_ttl_snapshot_ts 0
rocksdb_default_cf_options rocksdb_default_cf_options
rocksdb_delayed_write_rate 0 rocksdb_delayed_write_rate 0
rocksdb_delete_cf
rocksdb_delete_obsolete_files_period_micros 21600000000 rocksdb_delete_obsolete_files_period_micros 21600000000
rocksdb_enable_2pc ON rocksdb_enable_2pc ON
rocksdb_enable_bulk_load_api ON rocksdb_enable_bulk_load_api ON
rocksdb_enable_insert_with_update_caching ON
rocksdb_enable_thread_tracking ON rocksdb_enable_thread_tracking ON
rocksdb_enable_ttl ON rocksdb_enable_ttl ON
rocksdb_enable_ttl_read_filtering ON rocksdb_enable_ttl_read_filtering ON
...@@ -948,9 +953,11 @@ rocksdb_persistent_cache_size_mb 0 ...@@ -948,9 +953,11 @@ rocksdb_persistent_cache_size_mb 0
rocksdb_pin_l0_filter_and_index_blocks_in_cache ON rocksdb_pin_l0_filter_and_index_blocks_in_cache ON
rocksdb_print_snapshot_conflict_queries OFF rocksdb_print_snapshot_conflict_queries OFF
rocksdb_rate_limiter_bytes_per_sec 0 rocksdb_rate_limiter_bytes_per_sec 0
rocksdb_read_free_rpl_tables rocksdb_read_free_rpl OFF
rocksdb_read_free_rpl_tables .*
rocksdb_records_in_range 50 rocksdb_records_in_range 50
rocksdb_reset_stats OFF rocksdb_reset_stats OFF
rocksdb_rollback_on_timeout OFF
rocksdb_seconds_between_stat_computes 3600 rocksdb_seconds_between_stat_computes 3600
rocksdb_signal_drop_index_thread OFF rocksdb_signal_drop_index_thread OFF
rocksdb_sim_cache_size 0 rocksdb_sim_cache_size 0
...@@ -959,6 +966,7 @@ rocksdb_skip_fill_cache OFF ...@@ -959,6 +966,7 @@ rocksdb_skip_fill_cache OFF
rocksdb_skip_unique_check_tables .* rocksdb_skip_unique_check_tables .*
rocksdb_sst_mgr_rate_bytes_per_sec 0 rocksdb_sst_mgr_rate_bytes_per_sec 0
rocksdb_stats_dump_period_sec 600 rocksdb_stats_dump_period_sec 600
rocksdb_stats_level 0
rocksdb_stats_recalc_rate 0 rocksdb_stats_recalc_rate 0
rocksdb_store_row_debug_checksums OFF rocksdb_store_row_debug_checksums OFF
rocksdb_strict_collation_check OFF rocksdb_strict_collation_check OFF
...@@ -1340,7 +1348,7 @@ insert into t1 select (@a:=@a+1), 1234 from information_schema.session_variables ...@@ -1340,7 +1348,7 @@ insert into t1 select (@a:=@a+1), 1234 from information_schema.session_variables
set @tmp1= @@rocksdb_max_row_locks; set @tmp1= @@rocksdb_max_row_locks;
set rocksdb_max_row_locks= 20; set rocksdb_max_row_locks= 20;
update t1 set a=a+10; update t1 set a=a+10;
ERROR HY000: Got error 10 'Operation aborted: Failed to acquire lock due to max_num_locks limit' from ROCKSDB ERROR HY000: Got error 10 'Operation aborted: Failed to acquire lock due to rocksdb_max_row_locks limit' from ROCKSDB
DROP TABLE t1; DROP TABLE t1;
# #
# Test AUTO_INCREMENT behavior problem, # Test AUTO_INCREMENT behavior problem,
...@@ -1443,8 +1451,9 @@ set autocommit=1; ...@@ -1443,8 +1451,9 @@ set autocommit=1;
drop table t0, t1; drop table t0, t1;
# #
# Check status variables # Check status variables
# NOTE: We exclude rocksdb_num_get_for_update_calls because it's a debug only status var
# #
show status like 'rocksdb%'; show status where variable_name like 'rocksdb%' and variable_name not like '%num_get_for_update%';
Variable_name Value Variable_name Value
rocksdb_rows_deleted # rocksdb_rows_deleted #
rocksdb_rows_inserted # rocksdb_rows_inserted #
...@@ -1557,7 +1566,7 @@ rocksdb_write_other # ...@@ -1557,7 +1566,7 @@ rocksdb_write_other #
rocksdb_write_self # rocksdb_write_self #
rocksdb_write_timedout # rocksdb_write_timedout #
rocksdb_write_wal # rocksdb_write_wal #
select VARIABLE_NAME from INFORMATION_SCHEMA.global_status where VARIABLE_NAME LIKE 'rocksdb%'; select VARIABLE_NAME from INFORMATION_SCHEMA.global_status where VARIABLE_NAME LIKE 'rocksdb%' and VARIABLE_NAME NOT LIKE '%num_get_for_update%';
VARIABLE_NAME VARIABLE_NAME
ROCKSDB_ROWS_DELETED ROCKSDB_ROWS_DELETED
ROCKSDB_ROWS_INSERTED ROCKSDB_ROWS_INSERTED
...@@ -1672,7 +1681,7 @@ ROCKSDB_WRITE_TIMEDOUT ...@@ -1672,7 +1681,7 @@ ROCKSDB_WRITE_TIMEDOUT
ROCKSDB_WRITE_WAL ROCKSDB_WRITE_WAL
# RocksDB-SE's status variables are global internally # RocksDB-SE's status variables are global internally
# but they are shown as both session and global, like InnoDB's status vars. # but they are shown as both session and global, like InnoDB's status vars.
select VARIABLE_NAME from INFORMATION_SCHEMA.session_status where VARIABLE_NAME LIKE 'rocksdb%'; select VARIABLE_NAME from INFORMATION_SCHEMA.session_status where VARIABLE_NAME LIKE 'rocksdb%' and VARIABLE_NAME NOT LIKE '%num_get_for_update%';
VARIABLE_NAME VARIABLE_NAME
ROCKSDB_ROWS_DELETED ROCKSDB_ROWS_DELETED
ROCKSDB_ROWS_INSERTED ROCKSDB_ROWS_INSERTED
......
...@@ -111,7 +111,7 @@ set session debug= "-d,myrocks_simulate_bad_key_checksum1"; ...@@ -111,7 +111,7 @@ set session debug= "-d,myrocks_simulate_bad_key_checksum1";
explain explain
select a from t3 force index(a) where a<4; select a from t3 force index(a) where a<4;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 index a a 5 NULL # Using where; Using index 1 SIMPLE t3 range a a 5 NULL # Using where; Using index
select a from t3 force index(a) where a<4; select a from t3 force index(a) where a<4;
a a
1 1
......
include/master-slave.inc
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[connection master]
include/stop_slave.inc
set @@global.rocksdb_read_free_rpl = PK_SK;
include/start_slave.inc
include/sync_slave_sql_with_master.inc
include/diff_tables.inc [master:t1, slave:t1]
include/diff_tables.inc [master:t2, slave:t2]
include/diff_tables.inc [master:t3, slave:t3]
include/diff_tables.inc [master:t4, slave:t4]
include/diff_tables.inc [master:t5, slave:t5]
include/diff_tables.inc [master:t6, slave:t6]
include/diff_tables.inc [master:t7, slave:t7]
include/diff_tables.inc [master:t8, slave:t8]
include/sync_slave_sql_with_master.inc
include/stop_slave.inc
set @@global.rocksdb_read_free_rpl = PK_ONLY;
include/start_slave.inc
include/sync_slave_sql_with_master.inc
include/diff_tables.inc [master:t1, slave:t1]
include/diff_tables.inc [master:t2, slave:t2]
include/diff_tables.inc [master:t3, slave:t3]
include/diff_tables.inc [master:t4, slave:t4]
include/diff_tables.inc [master:t5, slave:t5]
include/diff_tables.inc [master:t6, slave:t6]
include/diff_tables.inc [master:t7, slave:t7]
include/diff_tables.inc [master:t8, slave:t8]
include/sync_slave_sql_with_master.inc
include/stop_slave.inc
set @@global.rocksdb_read_free_rpl = default;
include/start_slave.inc
include/rpl_end.inc
drop table if exists t1;
SET @@global.rocksdb_rollback_on_timeout = 1;
show variables like 'rocksdb_rollback_on_timeout';
Variable_name Value
rocksdb_rollback_on_timeout ON
create table t1 (a int unsigned not null primary key) engine = rocksdb;
insert into t1 values (1);
commit;
begin work;
insert into t1 values (5);
insert into t1 values (6);
update t1 set a = a + 1 where a = 1;
begin work;
insert into t1 values (7);
insert into t1 values (8);
update t1 set a = a + 1 where a = 1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on index: test.t1.PRIMARY
select * from t1;
a
1
commit;
select * from t1;
a
2
5
6
commit;
select * from t1;
a
2
5
6
SET @@global.rocksdb_rollback_on_timeout = 0;
show variables like 'rocksdb_rollback_on_timeout';
Variable_name Value
rocksdb_rollback_on_timeout OFF
begin work;
insert into t1 values (9);
insert into t1 values (10);
update t1 set a = a + 1 where a = 2;
begin work;
insert into t1 values (11);
insert into t1 values (12);
update t1 set a = a + 1 where a = 2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on index: test.t1.PRIMARY
select * from t1;
a
2
5
6
11
12
commit;
select * from t1;
a
3
5
6
9
10
commit;
select * from t1;
a
3
5
6
9
10
11
12
SET @@global.rocksdb_rollback_on_timeout = DEFAULT;
drop table t1;
This diff is collapsed.
This diff is collapsed.
let $trx_isolation = READ COMMITTED;
--source blind_delete_without_tx_api.inc
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment