Skip to content

Commit

Permalink
issue-2725: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vladstepanyuk committed Jan 15, 2025
1 parent 0ccf202 commit 90a6642
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "acquire_release_disk.h"
#include "acquire_release_devices.h"

#include <cloud/blockstore/libs/storage/core/proto_helpers.h>
#include <cloud/storage/core/libs/actors/helpers.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "acquire_release_disk.h"
#include "acquire_release_devices.h"

#include <cloud/blockstore/libs/storage/core/proto_helpers.h>
#include <cloud/storage/core/libs/actors/helpers.h>
Expand Down
4 changes: 2 additions & 2 deletions cloud/blockstore/libs/storage/core/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ LIBRARY()
GENERATE_ENUM_SERIALIZATION(mount_token.h)

SRCS(
acquire_disk_actor.cpp
acquire_devices_actor.cpp
block_handler.cpp
compaction_map.cpp
compaction_options.cpp
Expand All @@ -20,7 +20,7 @@ SRCS(
pending_request.cpp
probes.cpp
proto_helpers.cpp
release_disk_actor.cpp
release_devices_actor.cpp
request_buffer.cpp
request_info.cpp
storage_request_counters.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,24 @@ void TDiskRegistryActor::BeforeDie(const NActors::TActorContext& ctx)
MakeTabletIsDeadError(E_REJECTED, __LOCATION__));
}
PendingDiskDeallocationRequests.clear();

for (auto& [actorId, requestInfo]: PendingAcquireDiskRequests) {
NCloud::Reply(
ctx,
*requestInfo,
std::make_unique<TEvDiskRegistry::TEvAcquireDiskResponse>(
MakeTabletIsDeadError(E_REJECTED, __LOCATION__)));
}
PendingAcquireDiskRequests.clear();

for (auto& [actorId, requestInfo]: PendingReleaseDiskRequests) {
NCloud::Reply(
ctx,
*requestInfo,
std::make_unique<TEvDiskRegistry::TEvReleaseDiskResponse>(
MakeTabletIsDeadError(E_REJECTED, __LOCATION__)));
}
PendingReleaseDiskRequests.clear();
}

void TDiskRegistryActor::OnDetach(const TActorContext& ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <cloud/blockstore/libs/storage/api/disk_agent.h>
#include <cloud/blockstore/libs/storage/api/disk_registry.h>
#include <cloud/blockstore/libs/storage/api/service.h>
#include <cloud/blockstore/libs/storage/core/acquire_release_disk.h>
#include <cloud/blockstore/libs/storage/core/acquire_release_devices.h>
#include <cloud/blockstore/libs/storage/core/config.h>
#include <cloud/blockstore/libs/storage/core/monitoring_utils.h>
#include <cloud/blockstore/libs/storage/core/pending_request.h>
Expand Down Expand Up @@ -118,8 +118,8 @@ class TDiskRegistryActor final
// Requests in-progress
THashSet<NActors::TActorId> Actors;

THashMap<NActors::TActorId, TRequestInfoPtr> AcquireDiskRequests;
THashMap<NActors::TActorId, TRequestInfoPtr> ReleaseDiskRequests;
THashMap<NActors::TActorId, TRequestInfoPtr> PendingAcquireDiskRequests;
THashMap<NActors::TActorId, TRequestInfoPtr> PendingReleaseDiskRequests;

TLogbrokerServicePtr LogbrokerService;
NNotify::IServicePtr NotifyService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void TDiskRegistryActor::HandleAcquireDisk(
/*muteIOErrors=*/false,
TBlockStoreComponents::DISK_REGISTRY);
Actors.insert(actor);
AcquireDiskRequests[actor] =
PendingAcquireDiskRequests[actor] =
CreateRequestInfo(ev->Sender, ev->Cookie, msg->CallContext);
}

Expand All @@ -99,11 +99,13 @@ void TDiskRegistryActor::HandleDevicesAcquireFinished(

OnDiskAcquired(std::move(msg->SentRequests));

auto reqInfo = AcquireDiskRequests.at(ev->Sender);
auto reqInfo = PendingAcquireDiskRequests.at(ev->Sender);

auto response = std::make_unique<TEvDiskRegistry::TEvAcquireDiskResponse>(
std::move(msg->Error));

const auto* disk = State->GetDisk(msg->DiskId);

if (HasError(response->GetError())) {
LOG_ERROR(
ctx,
Expand All @@ -117,13 +119,16 @@ void TDiskRegistryActor::HandleDevicesAcquireFinished(
response->Record.MutableDevices()->Reserve(msg->Devices.size());

for (auto& device: msg->Devices) {
if (disk) {
ToLogicalBlocks(device, disk->LogicalBlockSize);
}
*response->Record.AddDevices() = std::move(device);
}
}

NCloud::Reply(ctx, *reqInfo, std::move(response));
Actors.erase(ev->Sender);
AcquireDiskRequests.erase(ev->Sender);
PendingAcquireDiskRequests.erase(ev->Sender);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -214,7 +219,7 @@ void TDiskRegistryActor::HandleReleaseDisk(
TBlockStoreComponents::DISK_REGISTRY);

Actors.insert(actor);
ReleaseDiskRequests[actor] =
PendingReleaseDiskRequests[actor] =
CreateRequestInfo(ev->Sender, ev->Cookie, msg->CallContext);
}

Expand All @@ -227,14 +232,14 @@ void TDiskRegistryActor::HandleDevicesReleaseFinished(
OnDiskReleased(msg->SentRequests);

State->FinishAcquireDisk(msg->DiskId);
auto reqInfo = ReleaseDiskRequests.at(ev->Sender);
auto reqInfo = PendingReleaseDiskRequests.at(ev->Sender);

auto response =
std::make_unique<TEvDiskRegistry::TEvReleaseDiskResponse>(msg->Error);
NCloud::Reply(ctx, *reqInfo, std::move(response));

Actors.erase(ev->Sender);
ReleaseDiskRequests.erase(ev->Sender);
PendingReleaseDiskRequests.erase(ev->Sender);
}

} // namespace NCloud::NBlockStore::NStorage
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <cloud/blockstore/libs/kikimr/components.h>
#include <cloud/blockstore/libs/kikimr/events.h>
#include <cloud/blockstore/libs/storage/api/disk_agent.h>
#include <cloud/blockstore/libs/storage/core/acquire_release_disk.h>
#include <cloud/blockstore/libs/storage/core/acquire_release_devices.h>
#include <cloud/blockstore/libs/storage/core/request_info.h>
#include <cloud/blockstore/libs/storage/protos/disk.pb.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3363,6 +3363,12 @@ NProto::EDiskState TDiskRegistryState::GetDiskState(const TDiskId& diskId) const
return disk->State;
}

const TDiskRegistryState::TDiskState* TDiskRegistryState::GetDisk(
const TDiskId& diskId) const
{
return Disks.FindPtr(diskId);
}

NProto::TError TDiskRegistryState::GetShadowDiskId(
const TDiskId& sourceDiskId,
const TCheckpointId& checkpointId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ class TDiskRegistryState

NProto::TError GetDiskInfo(const TDiskId& diskId, TDiskInfo& diskInfo) const;
NProto::EDiskState GetDiskState(const TDiskId& diskId) const;
const TDiskState* GetDisk(const TDiskId& diskId) const;
NProto::TError GetShadowDiskId(
const TDiskId& sourceDiskId,
const TCheckpointId& checkpointId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@ Y_UNIT_TEST_SUITE(TDiskRegistryTest)

runtime->SetObserverFunc( [&] (TAutoPtr<IEventHandle>& event) {
switch (event->GetTypeRewrite()) {
case TEvDiskRegistryPrivate::EvFinishAcquireDiskResponse: {
case NAcquireReleaseDevices::TEvDevicesAcquireFinished::
EventType: {
finished = true;
break;
}
Expand Down Expand Up @@ -676,10 +677,7 @@ Y_UNIT_TEST_SUITE(TDiskRegistryTest)
}

{
auto response = diskRegistry.RemoveDiskSession(
"disk-1",
"session-1",
TVector<TAgentReleaseDevicesCachedRequest>());
auto response = diskRegistry.ReleaseDisk("disk-1", "session-1");
UNIT_ASSERT(!HasError(response->GetError()));
}
}
Expand Down
12 changes: 0 additions & 12 deletions cloud/blockstore/libs/storage/disk_registry/testlib/test_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,18 +780,6 @@ class TDiskRegistryClient
std::move(devices));
}

auto CreateRemoveDiskSessionRequest(
TString diskId,
TString clientId,
TVector<TAgentReleaseDevicesCachedRequest> sentRequests)
{
return std::make_unique<
TEvDiskRegistryPrivate::TEvRemoveDiskSessionRequest>(
std::move(diskId),
std::move(clientId),
std::move(sentRequests));
}

auto CreateUpdateAgentStatsRequest(NProto::TAgentStats stats)
{
auto request = std::make_unique<TEvDiskRegistry::TEvUpdateAgentStatsRequest>();
Expand Down
2 changes: 1 addition & 1 deletion cloud/blockstore/libs/storage/volume/volume_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <cloud/blockstore/libs/storage/api/service.h>
#include <cloud/blockstore/libs/storage/api/stats_service.h>
#include <cloud/blockstore/libs/storage/api/volume.h>
#include <cloud/blockstore/libs/storage/core/acquire_release_disk.h>
#include <cloud/blockstore/libs/storage/core/acquire_release_devices.h>
#include <cloud/blockstore/libs/storage/core/config.h>
#include <cloud/blockstore/libs/storage/core/disk_counters.h>
#include <cloud/blockstore/libs/storage/core/metrics.h>
Expand Down

0 comments on commit 90a6642

Please sign in to comment.