fix consistency scan ubsan issue and replication factor calculation (#10492)

This commit is contained in:
Josh Slocum 2023-06-15 08:10:49 -05:00 committed by GitHub
parent 5c8a163c72
commit 01ce1ab24d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -652,10 +652,11 @@ ACTOR Future<Void> consistencyScanCore(Database db,
(statsCurrentRound.logicalBytesScanned == 0)
? 3
: ((double)statsCurrentRound.replicatedBytesRead / statsCurrentRound.logicalBytesScanned);
configuredRate =
std::min<int>(config.maxReadByteRate,
memState->databaseSize.get() * replicationFactor /
(config.targetRoundTimeSeconds > 0 ? config.targetRoundTimeSeconds : 1));
double bytesPerSecTarget = memState->databaseSize.get() * replicationFactor /
(config.targetRoundTimeSeconds > 0 ? config.targetRoundTimeSeconds : 1);
// avoid ubsan int conversion issue if misconfigured, also max of 100MB/s is reasonable anyway
bytesPerSecTarget = std::min(bytesPerSecTarget, 1e8);
configuredRate = std::min<int>(config.maxReadByteRate, bytesPerSecTarget);
}
configuredRate = std::max<int>(100e3, configuredRate);
@ -842,6 +843,7 @@ ACTOR Future<Void> consistencyScanCore(Database db,
state std::vector<Future<ErrorOr<GetKeyValuesReply>>> keyValueFutures;
state Optional<int> firstValidServer;
memState->stats.requests += storageServerInterfaces.size();
state int64_t replicatedBytesReadThisLoop = 0;
int newErrors = wait(consistencyCheckReadData(memState->csId,
db,
targetRange,
@ -849,7 +851,7 @@ ACTOR Future<Void> consistencyScanCore(Database db,
&storageServerInterfaces,
&keyValueFutures,
&firstValidServer,
&replicatedBytesRead,
&replicatedBytesReadThisLoop,
statsCurrentRound.startVersion));
errors += newErrors;
memState->stats.inconsistencies += newErrors;
@ -870,6 +872,7 @@ ACTOR Future<Void> consistencyScanCore(Database db,
ASSERT(firstValidServer.present());
GetKeyValuesReply rangeResult = keyValueFutures[firstValidServer.get()].get().get();
logicalBytesRead += rangeResult.data.expectedSize();
replicatedBytesRead += replicatedBytesReadThisLoop;
if (!rangeResult.more) {
statsCurrentRound.lastEndKey = targetRange.end;
noMoreRecords = statsCurrentRound.lastEndKey == allKeys.end;
@ -901,6 +904,7 @@ ACTOR Future<Void> consistencyScanCore(Database db,
nextKey = storageNextKey;
}
}
replicatedBytesRead += replicatedBytesReadThisLoop;
statsCurrentRound.lastEndKey = nextKey;
if (nextKey == targetRange.end) {
noMoreRecords = nextKey == allKeys.end;
@ -920,7 +924,9 @@ ACTOR Future<Void> consistencyScanCore(Database db,
}
// FIXME: increment failed request count if error present
ASSERT(failedRequest.get().code() != error_code_operation_cancelled);
totalReadBytesFromStorageServers += 100000;
// don't include replicated bytes this loop in metrics to avoid getting replication
// factor wrong, but make sure we stil throttle based on it
totalReadBytesFromStorageServers += replicatedBytesReadThisLoop + 100000;
break;
}