Skip to content

Commit

Permalink
Fix TTL testcase and rebase various test failures - inikep#2
Browse files Browse the repository at this point in the history
Summary:
1. ttl_primary has an interesting bug that it inserts using UNIX_TIMESTAMP and then updates the same keys with UNIX_TIMESTAMP in attempt to renew its TTL (while setting debug_rocksdb_ttl_ts to a positive value) but if the commands are executed fast enough the UNIX_TIMESTAMP won't change and as a result the update will not trigger any TTL update. I've verified 5.6 has the same behavior in this case so it's just flaky test. Fixed to use UNIX_TIMESTAMP() + 1 so as long as time flows in the positive direction in the foreseeable future (paring unexpected clock time jumps) we should be fine. Other TTL tests seems to employ similar pattern.
2. Rebaseline line a few other tests due to issues that already been observed. See my earlier diffs for more context.

Reviewed By: lloyd

Differential Revision: D17529590 (facebook@b30636d)

fbshipit-source-id: b235485053e
  • Loading branch information
yizhang82 authored and inikep committed Sep 2, 2021
1 parent e6423c9 commit d0490be
Show file tree
Hide file tree
Showing 12 changed files with 186 additions and 156 deletions.
9 changes: 7 additions & 2 deletions mysql-test/suite/rocksdb/r/allow_no_primary_key.result
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ a b
123 bbb
321 ccc
321 ccc
# restart
INSERT INTO t1 (a,b) VALUES (45,'bob');
SELECT * FROM t1;
a b
Expand Down Expand Up @@ -171,6 +172,7 @@ a b
123 bbb
321 ccc
321 ccc
# restart
INSERT INTO t1 (a,b) VALUES (45,'bob');
SELECT * FROM t1;
a b
Expand Down Expand Up @@ -240,8 +242,10 @@ SELECT * FROM t1 WHERE a = 2;
a b
2 b
EXPLAIN SELECT * FROM t1 WHERE a = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const a a 5 const 1 NULL
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL const a a 5 const 1 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select '2' AS `a`,'b' AS `b` from `test`.`t1` where 1
DROP TABLE t1;
CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
SHOW CREATE TABLE t1;
Expand All @@ -254,6 +258,7 @@ SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a int(11) YES NULL
b char(8) YES NULL
# restart
INSERT INTO t1 (a,b) VALUES (35,'foo');
INSERT INTO t1 (a,b) VALUES (35,'foo');
INSERT INTO t1 (a,b) VALUES (36,'foo');
Expand Down
10 changes: 6 additions & 4 deletions mysql-test/suite/rocksdb/r/autoinc_debug.result
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ from information_schema.rocksdb_ddl where table_name = 't';
table_name index_name auto_increment
t PRIMARY NULL
set debug='-d,myrocks_autoinc_upgrade';
# restart
insert into t values ();
insert into t values ();
insert into t values ();
Expand All @@ -35,6 +36,7 @@ from information_schema.rocksdb_ddl where table_name = 't';
table_name index_name auto_increment
t PRIMARY 5
delete from t where i > 1;
# restart
insert into t values ();
insert into t values ();
insert into t values ();
Expand All @@ -61,7 +63,7 @@ commit;
ERROR HY000: Lost connection to MySQL server during query
select max(i) into @row_max from t;
select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
table_schema table_name auto_increment > @row_max
TABLE_SCHEMA TABLE_NAME auto_increment > @row_max
test t 1
# After engine prepare
begin;
Expand All @@ -72,7 +74,7 @@ commit;
ERROR HY000: Lost connection to MySQL server during query
select max(i) into @row_max from t;
select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
table_schema table_name auto_increment > @row_max
TABLE_SCHEMA TABLE_NAME auto_increment > @row_max
test t 1
# After binlog
begin;
Expand All @@ -83,7 +85,7 @@ commit;
ERROR HY000: Lost connection to MySQL server during query
select max(i) into @row_max from t;
select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
table_schema table_name auto_increment > @row_max
TABLE_SCHEMA TABLE_NAME auto_increment > @row_max
test t 1
# After everything
begin;
Expand All @@ -94,6 +96,6 @@ commit;
ERROR HY000: Lost connection to MySQL server during query
select max(i) into @row_max from t;
select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
table_schema table_name auto_increment > @row_max
TABLE_SCHEMA TABLE_NAME auto_increment > @row_max
test t 1
drop table t;
186 changes: 95 additions & 91 deletions mysql-test/suite/rocksdb/r/records_in_range.result

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions mysql-test/suite/rocksdb/r/ttl_primary.result
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ INSERT INTO t1 values (3, UNIX_TIMESTAMP());
INSERT INTO t1 values (5, UNIX_TIMESTAMP());
INSERT INTO t1 values (7, UNIX_TIMESTAMP());
set global rocksdb_debug_ttl_rec_ts = 300;
UPDATE t1 SET b=UNIX_TIMESTAMP() WHERE a < 4;
UPDATE t1 SET b=UNIX_TIMESTAMP()+1 WHERE a < 4;
set global rocksdb_debug_ttl_rec_ts = 0;
SELECT a FROM t1;
a
Expand Down Expand Up @@ -462,10 +462,10 @@ set global rocksdb_debug_ttl_rec_ts = 0;
set global rocksdb_enable_ttl=0;
set global rocksdb_force_flush_memtable_now=1;
set global rocksdb_compact_cf='default';
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value into @c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
set global rocksdb_enable_ttl=1;
set global rocksdb_compact_cf='default';
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value-@c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
variable_value-@c
3
SELECT COUNT(*) FROM t1;
Expand All @@ -480,10 +480,10 @@ COMMENT='ttl_duration=100;';
INSERT INTO t1 values (1);
INSERT INTO t1 values (2);
INSERT INTO t1 values (3);
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value into @c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
set global rocksdb_force_flush_memtable_now=1;
set global rocksdb_compact_cf='default';
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value-@c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
variable_value-@c
0
DROP TABLE t1;
38 changes: 19 additions & 19 deletions mysql-test/suite/rocksdb/r/ttl_primary_read_filtering.result
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ set global rocksdb_debug_ttl_rec_ts = 0;
set global rocksdb_force_flush_memtable_now=1;
SELECT * FROM t1;
a
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value into @c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
set global rocksdb_compact_cf='default';
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value-@c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
variable_value-@c
2
DROP TABLE t1;
Expand Down Expand Up @@ -51,28 +51,28 @@ INSERT INTO t1 values (3);
INSERT INTO t1 values (5);
INSERT INTO t1 values (7);
set global rocksdb_debug_ttl_rec_ts = 0;
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value into @a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
SELECT * FROM t1;
a
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value-@a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
variable_value-@a
4
set global rocksdb_enable_ttl_read_filtering=0;
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value into @a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
SELECT * FROM t1;
a
1
3
5
7
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value-@a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
variable_value-@a
0
set global rocksdb_enable_ttl_read_filtering=1;
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value into @a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
SELECT * FROM t1;
a
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value-@a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
variable_value-@a
4
DROP TABLE t1;
Expand All @@ -93,7 +93,7 @@ INSERT INTO t1 values (1,2,1);
INSERT INTO t1 values (1,2,2);
INSERT INTO t1 values (1,2,3);
set global rocksdb_debug_ttl_rec_ts = 0;
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value into @c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
set global rocksdb_force_flush_memtable_now=1;
SELECT * FROM t1 WHERE a=1 AND b=2 AND c=2;
a b c
Expand All @@ -118,11 +118,11 @@ max(a)
NULL
select a from t1 where a > 0 and a <= 2;
a
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value-@c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
variable_value-@c
0
set global rocksdb_compact_cf='default';
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value-@c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
variable_value-@c
8
DROP TABLE t1;
Expand Down Expand Up @@ -199,33 +199,33 @@ a
# Switching to connection 2
set global rocksdb_force_flush_memtable_now=1;
set global rocksdb_compact_cf='default';
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value into @a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
SELECT * FROM t1;
a
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value-@a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
variable_value-@a
1
# Switching to connection 1
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value into @a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
SELECT * FROM t1;
a
1
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value-@a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
variable_value-@a
0
UPDATE t1 set a = a + 1;
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value into @a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
SELECT * FROM t1;
a
2
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value-@a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
variable_value-@a
0
COMMIT;
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value into @a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
SELECT * FROM t1;
a
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
select variable_value-@a from performance_schema.global_status where variable_name='rocksdb_rows_filtered';
variable_value-@a
1
DROP TABLE t1;
Expand Down
11 changes: 6 additions & 5 deletions mysql-test/suite/rocksdb/r/ttl_rows_examined.result
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ connection conn2;
set debug_sync='now WAIT_FOR parked';
affected rows: 0
SHOW PROCESSLIST;
Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
### ### ### ### Query ### debug sync point: rocksdb.ttl_rows_examined SELECT * FROM t_re 1 ### ### ###
### ### ### ### Query ### init SHOW PROCESSLIST 0 ### ### ###
### ### ### ### Sleep ### NULL 0 ### ### ###
affected rows: 3
Id User Host db Command Time State Info
### ### ### ### Daemon ### Waiting on empty queue NULL
### ### ### ### Query ### debug sync point: rocksdb.ttl_rows_examined SELECT * FROM t_re
### ### ### ### Query ### starting SHOW PROCESSLIST
### ### ### ### Sleep ### NULL
affected rows: 4
set debug_sync='now SIGNAL go';
affected rows: 0
connection conn1;
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/rocksdb/r/ttl_secondary.result
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ set global rocksdb_debug_ttl_rec_ts = 0;
set global rocksdb_enable_ttl=0;
set global rocksdb_force_flush_memtable_now=1;
set global rocksdb_compact_cf='default';
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value into @c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
set global rocksdb_enable_ttl=1;
set global rocksdb_compact_cf='default';
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value-@c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
variable_value-@c
6
SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
Expand All @@ -548,10 +548,10 @@ COMMENT='ttl_duration=100;';
INSERT INTO t1 values (1, 1);
INSERT INTO t1 values (2, 2);
INSERT INTO t1 values (3, 3);
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value into @c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
set global rocksdb_force_flush_memtable_now=1;
set global rocksdb_compact_cf='default';
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value-@c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
variable_value-@c
0
DROP TABLE t1;
Expand Down
10 changes: 5 additions & 5 deletions mysql-test/suite/rocksdb/r/ttl_secondary_read_filtering.result
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ SELECT * FROM t1 FORCE INDEX (PRIMARY);
a b
SELECT * FROM t1 FORCE INDEX (kb);
a b
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value into @c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
set global rocksdb_debug_ttl_ignore_pk = 1;
set global rocksdb_compact_cf='default';
set global rocksdb_debug_ttl_ignore_pk = 0;
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value-@c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
variable_value-@c
2
DROP TABLE t1;
Expand Down Expand Up @@ -120,7 +120,7 @@ INSERT INTO t1 values (1,2,1);
INSERT INTO t1 values (1,2,2);
INSERT INTO t1 values (1,2,3);
set global rocksdb_debug_ttl_rec_ts = 0;
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value into @c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
set global rocksdb_force_flush_memtable_now=1;
SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE a=1 AND b=2 AND c=2;
a b c
Expand Down Expand Up @@ -168,13 +168,13 @@ SELECT a FROM t1 FORCE INDEX (PRIMARY) WHERE a > 0 and a <= 2;
a
SELECT a FROM t1 FORCE INDEX (kb) WHERE a > 0 and a <= 2;
a
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value-@c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
variable_value-@c
0
set global rocksdb_debug_ttl_ignore_pk = 1;
set global rocksdb_compact_cf='default';
set global rocksdb_debug_ttl_ignore_pk = 0;
select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
select variable_value-@c from performance_schema.global_status where variable_name='rocksdb_rows_expired';
variable_value-@c
8
DROP TABLE t1;
Expand Down
45 changes: 31 additions & 14 deletions mysql-test/suite/rocksdb/r/type_char_indexes_collation.result
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ set session debug= "+d,myrocks_enable_unknown_collation_index_only_scans";
create table t (id int not null auto_increment primary key,
c varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci,
key sk (c));
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
insert into t (c) values ('☀'), ('ß');
explain select c from t;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL sk 27 NULL # Using index
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t NULL index NULL sk 27 # 1000 100.00 Using index
Warnings:
Note 1003 /* select#1 */ select `test`.`t`.`c` AS `c` from `test`.`t`
select c from t;
c
ß
Expand All @@ -19,17 +24,25 @@ primary key (id),
key sk1 (c1),
key sk2 (c2));
explain select hex(c1) from t order by c1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL sk1 4 NULL # Using index
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t NULL index NULL sk1 4 # 1000 100.00 Using index
Warnings:
Note 1003 /* select#1 */ select hex(`test`.`t`.`c1`) AS `hex(c1)` from `test`.`t` order by `test`.`t`.`c1`
explain select hex(c1) from t IGNORE INDEX (sk1) order by c1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t ALL NULL NULL NULL NULL # Using filesort
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t NULL ALL NULL NULL NULL # 1000 100.00 Using filesort
Warnings:
Note 1003 /* select#1 */ select hex(`test`.`t`.`c1`) AS `hex(c1)` from `test`.`t` IGNORE INDEX (`sk1`) order by `test`.`t`.`c1`
explain select hex(c2) from t order by c2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL sk2 2 NULL # Using index
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t NULL index NULL sk2 2 # 1000 100.00 Using index
Warnings:
Note 1003 /* select#1 */ select hex(`test`.`t`.`c2`) AS `hex(c2)` from `test`.`t` order by `test`.`t`.`c2`
explain select hex(c2) from t IGNORE INDEX (sk1) order by c2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL sk2 2 NULL # Using index
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t NULL index NULL sk2 2 # 1000 100.00 Using index
Warnings:
Note 1003 /* select#1 */ select hex(`test`.`t`.`c2`) AS `hex(c2)` from `test`.`t` IGNORE INDEX (`sk1`) order by `test`.`t`.`c2`
truncate t;
insert into t (c1, c2) values ('Asdf ', 'Asdf ');
Warnings:
Expand Down Expand Up @@ -66,8 +79,10 @@ insert into t (c1) values ('bbbb ');
insert into t (c1) values ('a ');
ERROR 23000: Duplicate entry 'a' for key 'sk1'
explain select c1 from t;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t ALL NULL NULL NULL NULL # NULL
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t NULL ALL NULL NULL NULL # 1000 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select `test`.`t`.`c1` AS `c1` from `test`.`t`
select c1 from t;
c1
Asdf
Expand All @@ -77,8 +92,10 @@ set session rocksdb_verify_row_debug_checksums = on;
create table t (id int primary key, email varchar(100), KEY email_i (email(30))) engine=rocksdb default charset=latin1;
insert into t values (1, ' a');
explain select 'email_i' as index_name, count(*) AS count from t force index(email_i);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL email_i 33 NULL # Using index
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t NULL index NULL email_i 33 # 1000 100.00 Using index
Warnings:
Note 1003 /* select#1 */ select 'email_i' AS `index_name`,count(0) AS `count` from `test`.`t` FORCE INDEX (`email_i`)
select 'email_i' as index_name, count(*) AS count from t force index(email_i);
index_name count
email_i 1
Expand Down
Loading

0 comments on commit d0490be

Please sign in to comment.