Skip to content

Commit

Permalink
Fix to bug in log iterator (#159)
Browse files Browse the repository at this point in the history
* If the first log file is empty, the log iterator chooses wrong log
file for iterator.
  • Loading branch information
greensky00 authored Sep 18, 2023
1 parent 339593c commit 1470ed7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/log_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ Status LogMgr::Iterator::initInternal(DB* snap_handle,
uint64_t max_seq_log;
s = lMgr->mani->getLogFileNumBySeq(maxSeqSnap, max_seq_log);
if (s) {
l_num_max= max_seq_log;
// WARNING:
// `l_num_max` should always be equal to or greater than
// `l_num_min`. The inversion can happen when there are
// 2 files, and `l_num_min` file contains nothing.
l_num_max = std::max(l_num_min, max_seq_log);
}
}

Expand Down

0 comments on commit 1470ed7

Please sign in to comment.