Skip to content

Commit

Permalink
add logs in return status
Browse files Browse the repository at this point in the history
Signed-off-by: tabokie <xy.tao@outlook.com>
  • Loading branch information
tabokie committed Jul 28, 2023
1 parent 5b9cef9 commit 3f79098
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion db/db_impl/db_impl_merge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,29 @@ Status DBImpl::MergeDisjointInstances(const MergeInstanceOptions& merge_options,
auto* comparator = this_cfd->user_comparator();
using CfRange = std::pair<PinnableSlice, PinnableSlice>;
std::vector<CfRange> db_ranges;
std::string ranges_str;
auto process_cf = [&](ColumnFamilyData* cfd) {
assert(cfd && s.ok());
PinnableSlice smallest, largest;
bool found = false;
// assert memtable is empty.
if (!merge_options.merge_memtable) {
cfd->GetMemtablesUserKeyRange(&smallest, &largest, &found);
if (found) {
s = Status::InvalidArgument(std::string("Memtable is not empty: ") +
smallest.ToString(true) + ", " +
largest.ToString(true));
return;
}
}
s = cfd->GetUserKeyRange(&smallest, &largest, &found);
if (s.ok() && found) {
ranges_str.append(smallest.ToString(true) + ", " +
largest.ToString(true) + ";");
db_ranges.emplace_back(
std::make_pair(std::move(smallest), std::move(largest)));
} else {
ranges_str.append("empty;");
}
};
process_cf(this_cfd);
Expand All @@ -146,7 +161,8 @@ Status DBImpl::MergeDisjointInstances(const MergeInstanceOptions& merge_options,
comparator->Compare(last_largest, range.first) < 0) {
last_largest = range.second;
} else {
return Status::InvalidArgument("Source DBs have overlapping range");
return Status::InvalidArgument(
std::string("Source DBs have overlapping range: ") + ranges_str);
}
}
}
Expand Down

0 comments on commit 3f79098

Please sign in to comment.