-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue-2722: add ability to read from certain replica of mirrored disk #2918
base: main
Are you sure you want to change the base?
Conversation
eb6020e
to
b0eafc5
Compare
Opts.AddLongOption( | ||
"replica-index", | ||
"from which replica(numerate from 1) read data, only for " | ||
"ssd-io disks") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В blockstore-client есть mirrorX/ssd_mirrorX, про ssd-io он не знает
if (replicaIndex) { | ||
if (replicaIndex > State.GetReplicaInfos().size()) { | ||
auto response = | ||
std::make_unique<typename TMethod::TResponse>(MakeError( | ||
E_ARGUMENT, | ||
TStringBuilder() | ||
<< "Request " << TMethod::Name | ||
<< " has incorrect ReplicaIndex " << replicaIndex | ||
<< " disk has " << State.GetReplicaInfos().size() | ||
<< " replicas")); | ||
NCloud::Reply(ctx, *ev, std::move(response)); | ||
return; | ||
} | ||
|
||
if (!replicaActorIds.insert(replicaActorId).second) { | ||
break; | ||
const auto& replicaInfo = State.GetReplicaInfos()[replicaIndex - 1]; | ||
if (!replicaInfo.Config->DevicesReadyForReading(blockRange)) { | ||
auto response = | ||
std::make_unique<typename TMethod::TResponse>(MakeError( | ||
E_REJECTED, | ||
TStringBuilder() << "Cannot process " << TMethod::Name | ||
<< " cause replica " << replicaIndex | ||
<< " has not ready devices")); | ||
NCloud::Reply(ctx, *ev, std::move(response)); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше вынести выбор реплик в отдельную функцию:
auto TMirrorPartitionActor::SelectReplicasToReadFrom(
ui32 replicaIndex,
TBlockRange64 blockRange) -> TResultOrError<TVector<TActorId>>
{...}
const auto replicaIndex = record.GetHeaders().GetReplicaIndex();
auto [replicaActorIds, error] =
SelectReplicasToReadFrom(replicaIndex, blockRange);
if (HasError(error)) {
NCloud::Reply(ctx, *ev, std::make_unique<TResponse>(error));
return;
}
if (replicaIndex) { | ||
if (replicaIndex > State.GetReplicaInfos().size()) { | ||
auto response = | ||
std::make_unique<typename TMethod::TResponse>(MakeError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Удобно сделать using в начале фyнкции:
using TResponse = TMethod::TResponse;
In order to provide better diagnostics for checksum mismatches in replicas, I want to add the ability for blockstore-client to read certain replica and compare it further in scripts