Skip to content

Commit

Permalink
fix an empty session stuck in 'acquire in progress' (#683) (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpeye authored Mar 8, 2024
1 parent f5fb65f commit e27543d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,6 @@ void TDiskRegistryActor::HandleAcquireDisk(
std::make_move_iterator(replica.end()));
}

if (devices.empty()) {
NCloud::Reply(
ctx,
*ev,
std::make_unique<TEvDiskRegistry::TEvAcquireDiskResponse>());

return;
}

auto actor = NCloud::Register<TAcquireDiskActor>(
ctx,
ctx.SelfID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,26 +543,25 @@ Y_UNIT_TEST_SUITE(TDiskRegistryTest)

Y_UNIT_TEST(ShouldNotSendAcquireReleaseRequestsToUnavailableAgents)
{
const auto agent1 = CreateAgentConfig("agent-1", {
Device("test", "uuid-1", "rack-1", 10_GB)
});

const auto agent2 = CreateAgentConfig("agent-2", {
Device("test", "uuid-2", "rack-2", 10_GB)
});
const TVector agents {
CreateAgentConfig("agent-1", {
Device("test", "uuid-1", "rack-1", 10_GB)
}),
CreateAgentConfig("agent-2", {
Device("test", "uuid-2", "rack-2", 10_GB)
})
};

auto runtime = TTestRuntimeBuilder()
.WithAgents({ agent1, agent2 })
.WithAgents(agents)
.Build();

TDiskRegistryClient diskRegistry(*runtime);
diskRegistry.WaitReady();
diskRegistry.SetWritableState(true);
diskRegistry.UpdateConfig(CreateRegistryConfig(0, {agent1, agent2}));
diskRegistry.UpdateConfig(CreateRegistryConfig(0, agents));

RegisterAgents(*runtime, 2);
WaitForAgents(*runtime, 2);
WaitForSecureErase(*runtime, {agent1, agent2});
RegisterAndWaitForAgents(*runtime, agents);

{
auto response = diskRegistry.AllocateDisk("disk-1", 20_GB);
Expand Down Expand Up @@ -624,7 +623,27 @@ Y_UNIT_TEST_SUITE(TDiskRegistryTest)
UNIT_ASSERT_VALUES_EQUAL(0, response->Record.DevicesSize());
}

// Let's acquire one more session
{
diskRegistry.SendAcquireDiskRequest(
"disk-1",
"session-2",
NProto::VOLUME_ACCESS_READ_ONLY);

auto response = diskRegistry.RecvAcquireDiskResponse();
UNIT_ASSERT_VALUES_EQUAL(S_OK, response->GetStatus());

UNIT_ASSERT_VALUES_EQUAL(0, response->Record.DevicesSize());
}

diskRegistry.ReleaseDisk("disk-1", "session-1");
diskRegistry.ReleaseDisk("disk-1", "session-2");

diskRegistry.ChangeAgentState("agent-1", NProto::AGENT_STATE_WARNING);
{
auto response = diskRegistry.AcquireDisk("disk-1", "session-1");
UNIT_ASSERT_VALUES_EQUAL(1, response->Record.DevicesSize());
}
}

Y_UNIT_TEST(ShouldAcquireReleaseSession)
Expand Down

0 comments on commit e27543d

Please sign in to comment.