]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commit
Fix regression bug of Prev() with upper bound (#3989)
authorsdong <siying.d@fb.com>
Tue, 12 Jun 2018 23:59:46 +0000 (16:59 -0700)
committersdong <siying.d@fb.com>
Mon, 18 Jun 2018 16:50:10 +0000 (09:50 -0700)
commit843738d8dcbf666701db265c2479827040c8b1d3
treeb1136ada431c01f284255e240f397dd47d29fca0
parentcc0a65f4286e3833d99833433d8b0c63ec7dbdfd
Fix regression bug of Prev() with upper bound (#3989)

Summary:
A recent change pushed down the upper bound checking to child iterators. However, this causes the logic of following sequence wrong:
  Seek(key);
  if (!Valid()) SeekToLast();
Because !Valid() may be caused by upper bounds, rather than the end of the iterator. In this case SeekToLast() points to totally wrong places. This can cause wrong results, infinite loops, or segfault in some cases.
This sequence is called when changing direction from forward to backward. And this by itself also implicitly happen during reseeking optimization in Prev().

Fix this bug by using SeekForPrev() rather than this sequence, as what is already done in prefix extrator case.
Closes https://github.com/facebook/rocksdb/pull/3989

Differential Revision: D8385422

Pulled By: siying

fbshipit-source-id: 429e869990cfd2dc389421e0836fc496bed67bb4
db/db_iter_test.cc
db/db_iterator_test.cc
table/merging_iterator.cc