Skip to content

Commit

Permalink
Combine rnd_next/index_next/position_to_correct_key codepaths
Browse files Browse the repository at this point in the history
Summary:
This combines the iteration codepaths so that we consolidate the places where we perform the snapshot refresh loop/bloomfilter calculations/ttl/icp into a single location.

Roughly, I'm doing the following:
- `rnd_next`/`index_next` as well as `index_read_map` are now all calling into `index_next_with_direction_intern`, which will perform the required iteration.
- In `index_read_map` filtering logic was split between `position_to_correct_key` and `read_row_from_secondary_key`. The first function did some TTL checks, and the second function did ICP. Instead `position_to_correct_key` is now solely responsible for seeking to the correct key without regard for ttl (or any other filtering) logic. With better rocksdb primitives (ie. prefix seek), we wouldn't even need these functions. All filtering logic is now consolidated into `index_next_with_direction_intern`.
- There are checks to see if the current key is in the current index id, as well as checks against `m_sk_match_prefix_buf` to see if the current key is within the current check. Conceptually, these two checks are doing the same thing, and can be merged together. This probably saves some memcmps.

Reviewed By: hermanlee

Differential Revision: D23399596

fbshipit-source-id: 642388720fd
  • Loading branch information
lth authored and facebook-github-bot committed May 21, 2021
1 parent 5862e88 commit 2b8ff6d
Show file tree
Hide file tree
Showing 5 changed files with 258 additions and 596 deletions.
10 changes: 5 additions & 5 deletions mysql-test/suite/rocksdb/r/check_flags.result
Expand Up @@ -6,35 +6,35 @@ CREATE TABLE t3 (id INT, kp1 INT, PRIMARY KEY (id), KEY(kp1)) ENGINE=ROCKSDB COM
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';
set debug_sync='rocksdb.check_flags_iri 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';
set debug_sync='rocksdb.check_flags_iri_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';
set debug_sync='rocksdb.check_flags_inwdi 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';
set debug_sync='rocksdb.check_flags_inwdi 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_rke SIGNAL parked WAIT_FOR go';
set debug_sync='rocksdb.check_flags_inwdi SIGNAL parked WAIT_FOR go';
SELECT kp1 FROM t3 ORDER BY kp1;
set debug_sync='now WAIT_FOR parked';
KILL QUERY $conn1_id;
Expand Down
Expand Up @@ -149,7 +149,7 @@ LIST OF SNAPSHOTS FOR EACH SESSION:
---SNAPSHOT, ACTIVE NUM sec
MySQL thread id TID, OS thread handle PTR, query id QID localhost root ACTION
SHOW ENGINE rocksdb TRANSACTION STATUS
lock count 5, write count 7
lock count 4, write count 7
insert count 2, update count 1, delete count 1
----------LATEST DETECTED DEADLOCKS----------
-----------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions mysql-test/suite/rocksdb/t/check_flags.test
Expand Up @@ -18,7 +18,7 @@ INSERT INTO t2 SELECT * FROM t1;
INSERT INTO t3 SELECT * FROM t1;

connection conn1;
set debug_sync='rocksdb.check_flags_rmi SIGNAL parked WAIT_FOR go';
set debug_sync='rocksdb.check_flags_iri SIGNAL parked WAIT_FOR go';
send SELECT value FROM t1 WHERE value = 3;

connection default;
Expand All @@ -36,7 +36,7 @@ connection conn1;
set debug_sync='RESET';

connection conn1;
set debug_sync='rocksdb.check_flags_rmi_scan SIGNAL parked WAIT_FOR go';
set debug_sync='rocksdb.check_flags_iri_scan SIGNAL parked WAIT_FOR go';
send SELECT DISTINCT(id) FROM t1 WHERE value = 5 AND id IN (1, 3, 5);

connection default;
Expand All @@ -54,7 +54,7 @@ connection conn1;
set debug_sync='RESET';

connection conn1;
set debug_sync='rocksdb.check_flags_inwd SIGNAL parked WAIT_FOR go';
set debug_sync='rocksdb.check_flags_inwdi SIGNAL parked WAIT_FOR go';
send SELECT value FROM t1 WHERE value > 3;

connection default;
Expand All @@ -72,7 +72,7 @@ connection conn1;
set debug_sync='RESET';

connection conn1;
set debug_sync='rocksdb.check_flags_rnwd SIGNAL parked WAIT_FOR go';
set debug_sync='rocksdb.check_flags_inwdi SIGNAL parked WAIT_FOR go';
send SELECT id FROM t2;

connection default;
Expand All @@ -91,7 +91,7 @@ set debug_sync='RESET';


connection conn1;
set debug_sync='rocksdb.check_flags_rke SIGNAL parked WAIT_FOR go';
set debug_sync='rocksdb.check_flags_inwdi SIGNAL parked WAIT_FOR go';
send SELECT kp1 FROM t3 ORDER BY kp1;

connection default;
Expand Down

0 comments on commit 2b8ff6d

Please sign in to comment.