Skip to content

Commit

Permalink
MyRocks: post-merge fixes part #5: make rocksdb.rocksdb_checksums tes…
Browse files Browse the repository at this point in the history
…t pass
  • Loading branch information
spetrunia committed Aug 29, 2018
1 parent 3d2c0f6 commit 5e4f3af
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 11 deletions.
16 changes: 14 additions & 2 deletions mysql-test/include/search_pattern_in_file.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
# Optionally, SEARCH_ABORT can be set to "FOUND" or "NOT FOUND" and this
# will abort if the search result doesn't match the requested one.
#
# Optionally, SEARCH_OUTPUT can be set to control the format of output.
# Supported formats:
# - (default) : "FOUND n /pattern/ in FILE " or "NOT FOUND ..."
# - "matches" : Each match is printed, on a separate line
#
# In case of
# - SEARCH_FILE and/or SEARCH_PATTERN is not set
# - SEARCH_FILE cannot be opened
Expand Down Expand Up @@ -75,7 +80,14 @@ perl;
my @matches=($content =~ m/$search_pattern/gs);
my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND";
$ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";

if ($ENV{SEARCH_OUTPUT} eq "matches") {
foreach (@matches) {
print $_ . "\n";
}
} else {
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
}
die "$ENV{SEARCH_ABORT}\n"
if $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/;
if $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/;
EOF
21 changes: 18 additions & 3 deletions storage/rocksdb/mysql-test/rocksdb/r/rocksdb_checksums.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,25 @@ insert into t1 values (1,1,1),(2,2,2),(3,3,3);
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
FOUND 1 /0 table records had checksums/ in mysqld.1.err
CHECKTABLE t1: Checking table t1
CHECKTABLE t1: Checking index a
CHECKTABLE t1: ... 3 index entries checked (0 had checksums)
CHECKTABLE t1: Checking index b
CHECKTABLE t1: ... 3 index entries checked (0 had checksums)
CHECKTABLE t1: 0 table records had checksums
drop table t1;
set session rocksdb_store_row_debug_checksums=on;
create table t2 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
insert into t2 values (1,1,1),(2,2,2),(3,3,3);
check table t2;
Table Op Msg_type Msg_text
test.t2 check status OK
FOUND 1 /3 table records had checksums/ in mysqld.1.err
CHECKTABLE t2: Checking table t2
CHECKTABLE t2: Checking index a
CHECKTABLE t2: ... 3 index entries checked (3 had checksums)
CHECKTABLE t2: Checking index b
CHECKTABLE t2: ... 3 index entries checked (3 had checksums)
CHECKTABLE t2: 3 table records had checksums
# Now, make a table that has both rows with checksums and without
create table t3 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
insert into t3 values (1,1,1),(2,2,2),(3,3,3);
Expand All @@ -29,7 +39,12 @@ set session rocksdb_store_row_debug_checksums=on;
check table t3;
Table Op Msg_type Msg_text
test.t3 check status OK
FOUND 1 /2 table records had checksums/ in mysqld.1.err
CHECKTABLE t3: Checking table t3
CHECKTABLE t3: Checking index a
CHECKTABLE t3: ... 3 index entries checked (3 had checksums)
CHECKTABLE t3: Checking index b
CHECKTABLE t3: ... 3 index entries checked (2 had checksums)
CHECKTABLE t3: 2 table records had checksums
set session rocksdb_store_row_debug_checksums=on;
set session rocksdb_checksums_pct=5;
create table t4 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
Expand Down
15 changes: 9 additions & 6 deletions storage/rocksdb/mysql-test/rocksdb/t/rocksdb_checksums.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ show variables like 'rocksdb_%checksum%';
create table t1 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
insert into t1 values (1,1,1),(2,2,2),(3,3,3);
check table t1;
--let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err
--let SEARCH_FILE=$LOG
--let SEARCH_PATTERN=0 table records had checksums
--let SEARCH_PATTERN=CHECKTABLE t1[^\n]*
--let SEARCH_OUTPUT=matches
--source include/search_pattern_in_file.inc

drop table t1;
Expand All @@ -29,7 +31,7 @@ set session rocksdb_store_row_debug_checksums=on;
create table t2 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
insert into t2 values (1,1,1),(2,2,2),(3,3,3);
check table t2;
--let SEARCH_PATTERN=3 table records had checksums
--let SEARCH_PATTERN=CHECKTABLE t2[^\n]*
--source include/search_pattern_in_file.inc

--echo # Now, make a table that has both rows with checksums and without
Expand All @@ -39,7 +41,7 @@ set session rocksdb_store_row_debug_checksums=off;
update t3 set b=3 where a=2;
set session rocksdb_store_row_debug_checksums=on;
check table t3;
--let SEARCH_PATTERN=2 table records had checksums
--let SEARCH_PATTERN=CHECKTABLE t3[^\n]*
--source include/search_pattern_in_file.inc

set session rocksdb_store_row_debug_checksums=on;
Expand All @@ -58,11 +60,12 @@ while ($i<4000)
--enable_query_log
check table t4;
perl;
$total=10000;
$total=4000;
$pct=5;
@out=();

$filename= "$ENV{MYSQLTEST_VARDIR}/log/mysqld.1.err";
$filename= "$ENV{LOG}";
print $filename "\n";
open(F, '<', $filename) || die("Can't open file $filename: $!");
while(<F>) {
@out=() if /^CURRENT_TEST:/;
Expand Down Expand Up @@ -144,6 +147,6 @@ set @@global.rocksdb_verify_row_debug_checksums=@save_rocksdb_verify_row_debug_c
set @@global.rocksdb_checksums_pct=@save_rocksdb_checksums_pct;

--source include/restart_mysqld.inc
--remove_file $LOG
#--remove_file $LOG

drop table t2,t3,t4;

0 comments on commit 5e4f3af

Please sign in to comment.