Skip to content

Commit

Permalink
Skip calling rocksdb::GetApproximateSize is start >= limit (facebook#131
Browse files Browse the repository at this point in the history
)

Summary:
When kd::successor() is called in records_in_range, there is a
possiblity of range.start >= range.limit. RocksDB has an assertion
"v->cfd_->internal_comparator().Compare(start, end) <= 0'" so
range should not be passed to rocksdb::GetApproximateSize in that case.
This diff skips calling rocksdb::GetApproximateSize() and just returns
0.

Differential Revision: https://reviews.facebook.net/D52491

fbshipit-source-id: 8b717bf
  • Loading branch information
yoshinorim authored and inikep committed Oct 5, 2020
1 parent 29cf812 commit 94a75a8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mysql-test/suite/rocksdb/r/rocksdb.result
Original file line number Diff line number Diff line change
Expand Up @@ -2172,4 +2172,15 @@ insert into t2
select concat('v-', 100 + A.a*100 + B.a), 12345 from t1 A, t1 B;
update t2 set a=concat('x-', a) where a between 'v-1002' and 'v-1004';
drop table t1,t2;
#
# Issue #131: Assertion `v->cfd_->internal_comparator().Compare(start, end) <= 0' failed
#
CREATE TABLE t2(c1 INTEGER UNSIGNED NOT NULL, c2 INTEGER NULL, c3 TINYINT, c4 SMALLINT , c5 MEDIUMINT, c6 INT, c7 BIGINT, PRIMARY KEY(c1,c6)) ENGINE=RocksDB;
INSERT INTO t2 VALUES (1,1,1,1,1,1,1);
SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
EXPLAIN SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
drop table t2;
SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
9 changes: 9 additions & 0 deletions mysql-test/suite/rocksdb/t/rocksdb.test
Original file line number Diff line number Diff line change
Expand Up @@ -1744,4 +1744,13 @@ update t2 set a=concat('x-', a) where a between 'v-1002' and 'v-1004';

drop table t1,t2;

--echo #
--echo # Issue #131: Assertion `v->cfd_->internal_comparator().Compare(start, end) <= 0' failed
--echo #
CREATE TABLE t2(c1 INTEGER UNSIGNED NOT NULL, c2 INTEGER NULL, c3 TINYINT, c4 SMALLINT , c5 MEDIUMINT, c6 INT, c7 BIGINT, PRIMARY KEY(c1,c6)) ENGINE=RocksDB;
INSERT INTO t2 VALUES (1,1,1,1,1,1,1);
SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6;
EXPLAIN SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6;
drop table t2;

SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
6 changes: 6 additions & 0 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6444,6 +6444,12 @@ ha_rows ha_rocksdb::records_in_range(uint inx, key_range *min_key,
rocksdb::Slice slice1((const char*) sec_key_packed_tuple, size1);
rocksdb::Slice slice2((const char*) sec_key_packed_tuple_old, size2);

// slice1 >= slice2 means no row will match
if (slice1.compare(slice2) >= 0)
{
DBUG_RETURN(0);
}

rocksdb::Range r(
kd->is_reverse_cf ? slice2 : slice1,
kd->is_reverse_cf ? slice1 : slice2
Expand Down

0 comments on commit 94a75a8

Please sign in to comment.