Fix contiguousLogEnd calculation
The contiguous version should scan from the max of scanBegin version and the minLogBegin version. Once we found a version that's larger, set it as the contiguousLogEnd version.
This commit is contained in:
parent
efbd01894d
commit
abcb458a44
|
@ -827,7 +827,7 @@ public:
|
|||
}
|
||||
|
||||
if (partitioned) {
|
||||
determinePartitionedLogsBeginEnd(&desc, logs);
|
||||
updatePartitionedLogsContinuousEnd(&desc, logs, scanBegin, scanEnd);
|
||||
} else {
|
||||
Version& end = desc.contiguousLogEnd.get();
|
||||
computeRestoreEndVersion(logs, nullptr, &end, std::numeric_limits<Version>::max());
|
||||
|
@ -1149,14 +1149,21 @@ public:
|
|||
indices.push_back(i);
|
||||
}
|
||||
|
||||
// check tag 0 is continuous and create a map of ranges to tags
|
||||
std::map<std::pair<Version, Version>, int> tags; // range [start, end] -> tags
|
||||
if (!isContinuous(files, tagIndices[0], begin, end, &tags)) return false;
|
||||
// check partition 0 is continuous and create a map of ranges to tags
|
||||
std::map<std::pair<Version, Version>, int> tags; // range [begin, end] -> tags
|
||||
if (!isContinuous(files, tagIndices[0], begin, end, &tags)) {
|
||||
TraceEvent(SevWarn, "BackupFileNotContinuous").detail("Partition", 0).detail("Begin", begin).detail("End", end);
|
||||
return false;
|
||||
}
|
||||
|
||||
// for each range in tags, check all tags from 1 are continouous
|
||||
for (const auto [beginEnd, count] : tags) {
|
||||
for (int i = 1; i < count; i++) {
|
||||
if (!isContinuous(files, tagIndices[i], beginEnd.first, beginEnd.second, nullptr)) {
|
||||
TraceEvent(SevWarn, "BackupFileNotContinuous")
|
||||
.detail("Partition", i)
|
||||
.detail("Begin", begin)
|
||||
.detail("End", end);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1184,20 +1191,18 @@ public:
|
|||
return filtered;
|
||||
}
|
||||
|
||||
// Analyze partitioned logs and set minLogBegin and contiguousLogEnd.
|
||||
// For partitioned logs, different tags may start at different versions, so
|
||||
// we need to find the "minLogBegin" version as well.
|
||||
static void determinePartitionedLogsBeginEnd(BackupDescription* desc, const std::vector<LogFile>& logs) {
|
||||
// Analyze partitioned logs and set contiguousLogEnd for "desc" if larger
|
||||
// than the "scanBegin" version.
|
||||
static void updatePartitionedLogsContinuousEnd(BackupDescription* desc, const std::vector<LogFile>& logs,
|
||||
const Version scanBegin, const Version scanEnd) {
|
||||
if (logs.empty()) return;
|
||||
|
||||
for (const LogFile& file : logs) {
|
||||
Version end = getPartitionedLogsContinuousEndVersion(logs, file.beginVersion);
|
||||
if (end > file.beginVersion) {
|
||||
// desc->minLogBegin = file.beginVersion;
|
||||
// contiguousLogEnd is not inclusive, so +1 here.
|
||||
desc->contiguousLogEnd.get() = end + 1;
|
||||
return;
|
||||
}
|
||||
Version ver = getPartitionedLogsContinuousEndVersion(
|
||||
logs, scanBegin > desc->minLogBegin.get() ? scanBegin : desc->minLogBegin.get());
|
||||
if (ver >= desc->contiguousLogEnd.get()) {
|
||||
// contiguousLogEnd is not inclusive, so +1 here.
|
||||
desc->contiguousLogEnd.get() = ver + 1;
|
||||
TraceEvent("UpdateContinuousLogEnd").detail("Version", ver + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1223,26 +1228,32 @@ public:
|
|||
}
|
||||
end = std::max(end, logs[i].endVersion - 1);
|
||||
}
|
||||
TraceEvent("ContinuousLogEnd").detail("Begin", begin).detail("InitVersion", end);
|
||||
|
||||
// check tag 0 is continuous in [begin, end] and create a map of ranges to tags
|
||||
std::map<std::pair<Version, Version>, int> tags; // range [start, end] -> tags
|
||||
// check partition 0 is continuous in [begin, end] and create a map of ranges to partitions
|
||||
std::map<std::pair<Version, Version>, int> tags; // range [start, end] -> partitions
|
||||
isContinuous(logs, tagIndices[0], begin, end, &tags);
|
||||
if (tags.empty() || end <= begin) return 0;
|
||||
end = std::min(end, tags.rbegin()->first.second);
|
||||
TraceEvent("ContinuousLogEnd").detail("Partition", 0).detail("EndVersion", end).detail("Begin", begin);
|
||||
|
||||
// for each range in tags, check all tags from 1 are continouous
|
||||
// for each range in tags, check all partitions from 1 are continouous
|
||||
Version lastEnd = begin;
|
||||
for (const auto [beginEnd, count] : tags) {
|
||||
Version tagEnd = end; // This range's minimum continous tag version
|
||||
Version tagEnd = beginEnd.second; // This range's minimum continous partition version
|
||||
for (int i = 1; i < count; i++) {
|
||||
std::map<std::pair<Version, Version>, int> rangeTags;
|
||||
isContinuous(logs, tagIndices[i], beginEnd.first, beginEnd.second, &rangeTags);
|
||||
tagEnd = rangeTags.empty() ? 0 : std::min(tagEnd, rangeTags.rbegin()->first.second);
|
||||
TraceEvent("ContinuousLogEnd")
|
||||
.detail("Partition", i)
|
||||
.detail("EndVersion", tagEnd)
|
||||
.detail("RangeBegin", beginEnd.first)
|
||||
.detail("RangeEnd", beginEnd.second);
|
||||
if (tagEnd == 0) return lastEnd;
|
||||
}
|
||||
if (tagEnd < beginEnd.second) {
|
||||
end = tagEnd;
|
||||
break;
|
||||
return tagEnd;
|
||||
}
|
||||
lastEnd = beginEnd.second;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue