Skip to content

Commit f0ee235

Browse files
committed
Fix issue with iterator operations in this order: Prev(), Seek(), Prev()
Summary: Due to a bad merge of D14163 and D14001 before checking in D14001, "direction_ = kForward;" in MergeIterator::Seek() was deleted my mistake (in commit b135d01 ). It will generate wrong results or assert failure after the sequence of Prev() (or SeekToLast()), Seek() and Prev(). Fix it Test Plan: make all check Reviewers: igor, haobo, dhruba Reviewed By: igor CC: yhchiang, i.am.jin.lei, ljin, leveldb Differential Revision: https://reviews.facebook.net/D16527
1 parent 5142b37 commit f0ee235

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

table/merger.cc

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class MergingIterator : public Iterator {
122122
// one, or null if there is no first child.
123123
current_ = first_child;
124124
}
125+
direction_ = kForward;
125126
}
126127

127128
virtual void Next() {
@@ -228,6 +229,8 @@ class MergingIterator : public Iterator {
228229
// If the value is true, both of iterators in the heap and current_
229230
// contain valid rows. If it is false, only current_ can possibly contain
230231
// valid rows.
232+
// This flag is always true for reverse direction, as we always use heap for
233+
// the reverse iterating case.
231234
bool use_heap_;
232235
Env* const env_;
233236
// Which direction is the iterator moving?

0 commit comments

Comments
 (0)