Skip to content
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

Do the lite reallocation when only IOModeTs is changed #2851

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,17 @@ bool ValidateDevices(
return ok;
}

std::unique_ptr<MessageDifferencer> CreateNodeIdChangeDifferencer()
std::unique_ptr<MessageDifferencer> CreateLiteReallocationDifferencer()
{
const auto* ioModeTsDescriptor =
NProto::TVolumeMeta::GetDescriptor()->FindFieldByName("IOModeTs");
// These are two fields that will change during disk agent blue-green
// deploy.
const auto* nodeIdDescriptor =
NProto::TDeviceConfig::GetDescriptor()->FindFieldByName("NodeId");
const auto* rdmaPortDescriptor =
NProto::TRdmaEndpoint::GetDescriptor()->FindFieldByName("Port");
if (!nodeIdDescriptor || !rdmaPortDescriptor) {
if (!nodeIdDescriptor || !rdmaPortDescriptor || !ioModeTsDescriptor) {
ReportFieldDescriptorNotFound(
TStringBuilder()
<< "Lite reallocation is impossible. nodeIdDescriptor = "
Expand All @@ -129,6 +131,7 @@ std::unique_ptr<MessageDifferencer> CreateNodeIdChangeDifferencer()
}

auto diff = std::make_unique<MessageDifferencer>();
diff->IgnoreField(ioModeTsDescriptor);
diff->IgnoreField(nodeIdDescriptor);
diff->IgnoreField(rdmaPortDescriptor);
diff->set_float_comparison(
Expand Down Expand Up @@ -538,7 +541,7 @@ void TVolumeActor::ExecuteUpdateDevices(

Y_DEBUG_ABORT_UNLESS(State->IsDiskRegistryMediaKind());
if (Config->GetAllowLiteDiskReallocations()) {
auto differencer = CreateNodeIdChangeDifferencer();
auto differencer = CreateLiteReallocationDifferencer();
args.LiteReallocation =
differencer && differencer->Compare(oldMeta, newMeta);
}
Expand Down
39 changes: 36 additions & 3 deletions cloud/blockstore/libs/storage/volume/volume_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5050,10 +5050,12 @@ Y_UNIT_TEST_SUITE(TVolumeTest)

Y_UNIT_TEST(ShouldDoLiteReallocations)
{
auto runtime = PrepareTestActorRuntime();
auto state = MakeIntrusive<TDiskRegistryState>();
auto runtime = PrepareTestActorRuntime(
NProto::TStorageServiceConfig(), state);

const auto expectedBlockCount = DefaultDeviceBlockSize * DefaultDeviceBlockCount
/ DefaultBlockSize;
const auto expectedBlockCount =
DefaultDeviceBlockSize * DefaultDeviceBlockCount / DefaultBlockSize;
const auto expectedDeviceCount = 3;

TVolumeClient volume(*runtime);
Expand All @@ -5077,6 +5079,9 @@ Y_UNIT_TEST_SUITE(TVolumeTest)
auto metaHistory = volume.ReadMetaHistory();
UNIT_ASSERT_VALUES_EQUAL(S_OK, metaHistory->Error.GetCode());
UNIT_ASSERT_VALUES_EQUAL(1, metaHistory->MetaHistory.size());
UNIT_ASSERT_VALUES_EQUAL(
0,
metaHistory->MetaHistory[0].Meta.GetIOModeTs());
}

{
Expand Down Expand Up @@ -5149,6 +5154,34 @@ Y_UNIT_TEST_SUITE(TVolumeTest)
auto metaHistory = volume.ReadMetaHistory();
UNIT_ASSERT_VALUES_EQUAL(S_OK, metaHistory->Error.GetCode());
UNIT_ASSERT_VALUES_EQUAL(2, metaHistory->MetaHistory.size());
UNIT_ASSERT_VALUES_EQUAL(
0,
metaHistory->MetaHistory[1].Meta.GetIOModeTs());
}

runtime->SetEventFilter([](TTestActorRuntimeBase&,
TAutoPtr<IEventHandle>&) { return false; });
auto now = Now();
state->Disks["vol0"].IOModeTs = now;
volume.ReallocateDisk();
{
// Lite reallocation happened. Meta history still contains 2 items.
auto metaHistory = volume.ReadMetaHistory();
UNIT_ASSERT_VALUES_EQUAL(S_OK, metaHistory->Error.GetCode());
UNIT_ASSERT_VALUES_EQUAL(2, metaHistory->MetaHistory.size());
}

state->Disks["vol0"].MuteIOErrors = true;
volume.ReallocateDisk();
{
// No lite reallocation, since MuteIOErrors has changed. Meta
// history contains 3 items now.
auto metaHistory = volume.ReadMetaHistory();
UNIT_ASSERT_VALUES_EQUAL(S_OK, metaHistory->Error.GetCode());
UNIT_ASSERT_VALUES_EQUAL(3, metaHistory->MetaHistory.size());
UNIT_ASSERT_VALUES_EQUAL(
now.MicroSeconds(),
metaHistory->MetaHistory.back().Meta.GetIOModeTs());
}
}

Expand Down
Loading