Merge branch 'master' into docs-for-s3-settings

This commit is contained in:
Dan Roscigno 2023-01-24 18:12:39 -05:00 committed by GitHub
commit 09a190b4fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 6 deletions

View File

@ -18,13 +18,18 @@ bool MarkRange::operator<(const MarkRange & rhs) const
/// We allow only consecutive non-intersecting ranges
/// Here we check whether a beginning of one range lies inside another range
/// (ranges are intersect)
const bool is_intersection = (begin <= rhs.begin && rhs.begin < end) ||
(rhs.begin <= begin && begin < rhs.end);
if (this != &rhs)
{
const bool is_intersection = (begin <= rhs.begin && rhs.begin < end) ||
(rhs.begin <= begin && begin < rhs.end);
if (is_intersection)
throw Exception(ErrorCodes::LOGICAL_ERROR,
"Intersecting mark ranges are not allowed, it "
"is a bug! First range ({}, {}), second range ({}, {})", begin, end, rhs.begin, rhs.end);
if (is_intersection)
throw Exception(
ErrorCodes::LOGICAL_ERROR,
"Intersecting mark ranges are not allowed, it is a bug! "
"First range ({}, {}), second range ({}, {})",
begin, end, rhs.begin, rhs.end);
}
return begin < rhs.begin && end <= rhs.begin;
}
@ -49,4 +54,15 @@ std::string toString(const MarkRanges & ranges)
return result;
}
void assertSortedAndNonIntersecting(const MarkRanges & ranges)
{
MarkRanges ranges_copy(ranges.begin(), ranges.end());
/// Should also throw an exception if interseting range is found during comparison.
std::sort(ranges_copy.begin(), ranges_copy.end());
if (ranges_copy != ranges)
throw Exception(
ErrorCodes::LOGICAL_ERROR, "Expected sorted and non intersecting ranges. Ranges: {}",
toString(ranges));
}
}

View File

@ -34,4 +34,6 @@ size_t getLastMark(const MarkRanges & ranges);
std::string toString(const MarkRanges & ranges);
void assertSortedAndNonIntersecting(const MarkRanges & ranges);
}

View File

@ -201,6 +201,10 @@ std::vector<size_t> MergeTreeReadPool::fillPerPartInfo(const RangesInDataParts &
for (const auto i : collections::range(0, parts.size()))
{
const auto & part = parts[i];
#ifndef NDEBUG
assertSortedAndNonIntersecting(part.ranges);
#endif
bool part_on_remote_disk = part.data_part->isStoredOnRemoteDisk();
is_part_on_remote_disk[i] = part_on_remote_disk;
do_not_steal_tasks |= part_on_remote_disk;