Skip to content

Commit

Permalink
issue-2542: add timeout and rename request
Browse files Browse the repository at this point in the history
  • Loading branch information
vladstepanyuk committed Jan 22, 2025
1 parent caf7f0a commit ce82bbb
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 62 deletions.
5 changes: 4 additions & 1 deletion cloud/blockstore/config/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,10 @@ message TStorageServiceConfig

// Enable buttons for device state changing, when they in error state.
optional bool EnableToChangeErrorStatesFromDiskRegistryMonpage = 398;

// Enabling UsedQuota calculation as UsedIopsQuota + UsedBandwidthQuota
optional bool CalculateSplittedUsedQuotaMetric = 399;

// Timeout for TDestroyVolumeActor (in milliseconds)
optional uint32 DestroyVolumeTimeout = 400;
}
46 changes: 23 additions & 23 deletions cloud/blockstore/libs/storage/api/volume.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ namespace NCloud::NBlockStore::NStorage {
////////////////////////////////////////////////////////////////////////////////

#define BLOCKSTORE_VOLUME_REQUESTS(xxx, ...) \
xxx(AddClient, __VA_ARGS__) \
xxx(RemoveClient, __VA_ARGS__) \
xxx(WaitReady, __VA_ARGS__) \
xxx(DescribeBlocks, __VA_ARGS__) \
xxx(GetPartitionInfo, __VA_ARGS__) \
xxx(CompactRange, __VA_ARGS__) \
xxx(GetCompactionStatus, __VA_ARGS__) \
xxx(ReallocateDisk, __VA_ARGS__) \
xxx(GetVolumeLoadInfo, __VA_ARGS__) \
xxx(GetUsedBlocks, __VA_ARGS__) \
xxx(DeleteCheckpointData, __VA_ARGS__) \
xxx(UpdateUsedBlocks, __VA_ARGS__) \
xxx(RebuildMetadata, __VA_ARGS__) \
xxx(GetRebuildMetadataStatus, __VA_ARGS__) \
xxx(ScanDisk, __VA_ARGS__) \
xxx(GetScanDiskStatus, __VA_ARGS__) \
xxx(GetVolumeInfo, __VA_ARGS__) \
xxx(UpdateVolumeParams, __VA_ARGS__) \
xxx(ChangeStorageConfig, __VA_ARGS__) \
xxx(GetStorageConfig, __VA_ARGS__) \
xxx(StopPartitionBeforeVolumeDestruction, __VA_ARGS__) \
xxx(AddClient, __VA_ARGS__) \
xxx(RemoveClient, __VA_ARGS__) \
xxx(WaitReady, __VA_ARGS__) \
xxx(DescribeBlocks, __VA_ARGS__) \
xxx(GetPartitionInfo, __VA_ARGS__) \
xxx(CompactRange, __VA_ARGS__) \
xxx(GetCompactionStatus, __VA_ARGS__) \
xxx(ReallocateDisk, __VA_ARGS__) \
xxx(GetVolumeLoadInfo, __VA_ARGS__) \
xxx(GetUsedBlocks, __VA_ARGS__) \
xxx(DeleteCheckpointData, __VA_ARGS__) \
xxx(UpdateUsedBlocks, __VA_ARGS__) \
xxx(RebuildMetadata, __VA_ARGS__) \
xxx(GetRebuildMetadataStatus, __VA_ARGS__) \
xxx(ScanDisk, __VA_ARGS__) \
xxx(GetScanDiskStatus, __VA_ARGS__) \
xxx(GetVolumeInfo, __VA_ARGS__) \
xxx(UpdateVolumeParams, __VA_ARGS__) \
xxx(ChangeStorageConfig, __VA_ARGS__) \
xxx(GetStorageConfig, __VA_ARGS__) \
xxx(GracefulShutdown, __VA_ARGS__) \

// BLOCKSTORE_VOLUME_REQUESTS

Expand Down Expand Up @@ -332,8 +332,8 @@ struct TEvVolume
EvGetStorageConfigRequest = EvBegin + 58,
EvGetStorageConfigResponse = EvBegin + 59,

EvStopPartitionBeforeVolumeDestructionRequest = EvBegin + 60,
EvStopPartitionBeforeVolumeDestructionResponse = EvBegin + 61,
EvGracefulShutdownRequest = EvBegin + 60,
EvGracefulShutdownResponse = EvBegin + 61,

EvEnd
};
Expand Down
2 changes: 2 additions & 0 deletions cloud/blockstore/libs/storage/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ class TStorageConfig
GetEnableToChangeErrorStatesFromDiskRegistryMonpage() const;

[[nodiscard]] bool GetCalculateSplittedUsedQuotaMetric() const;
[[nodiscard]] TDuration GetDestroyVolumeTimeout() const;

};

ui64 GetAllocationUnit(
Expand Down
6 changes: 3 additions & 3 deletions cloud/blockstore/libs/storage/protos/volume.proto
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,9 @@ message TGetStorageConfigResponse
}

////////////////////////////////////////////////////////////////////////////////
// StopPartitionBeforeVolumeDestruction request/response.
// GracefulShutdown request/response.

message TStopPartitionBeforeVolumeDestructionRequest
message TGracefulShutdownRequest
{
// Optional request headers.
THeaders Headers = 1;
Expand All @@ -666,7 +666,7 @@ message TStopPartitionBeforeVolumeDestructionRequest
string DiskId = 2;
}

message TStopPartitionBeforeVolumeDestructionResponse
message TGracefulShutdownResponse
{
// Optional error, set only if error happened.
NCloud.NProto.TError Error = 1;
Expand Down
58 changes: 42 additions & 16 deletions cloud/blockstore/libs/storage/service/service_actor_destroy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class TDestroyVolumeActor final
const bool DestroyIfBroken;
const bool Sync;
const ui64 FillGeneration;
const TDuration Timeout;

bool IsDiskRegistryBased = false;
bool VolumeNotFoundInSS = false;
Expand All @@ -47,7 +48,8 @@ class TDestroyVolumeActor final
TString diskId,
bool destroyIfBroken,
bool sync,
ui64 fillGeneration);
ui64 fillGeneration,
TDuration timeout);

void Bootstrap(const TActorContext& ctx);

Expand All @@ -57,7 +59,7 @@ class TDestroyVolumeActor final
void NotifyDiskRegistry(const TActorContext& ctx);
void StatVolume(const TActorContext& ctx);
void DeallocateDisk(const TActorContext& ctx);
void StopPartitions(const TActorContext& ctx);
void GracefulShutdown(const TActorContext& ctx);
NProto::TError CheckIfDestructionIsAllowed() const;

void HandleModifyResponse(
Expand All @@ -80,11 +82,15 @@ class TDestroyVolumeActor final
const TEvDiskRegistry::TEvDeallocateDiskResponse::TPtr& ev,
const TActorContext& ctx);

void HandleStopPartitions(
const TEvVolume::TEvStopPartitionBeforeVolumeDestructionResponse::TPtr&
void HandleGracefulShutdownResponse(
const TEvVolume::TEvGracefulShutdownResponse::TPtr&
ev,
const TActorContext& ctx);

void HandleTimeout(
const TEvents::TEvWakeup::TPtr& ev,
const TActorContext& ctx);

void ReplyAndDie(const TActorContext& ctx, NProto::TError error);

private:
Expand All @@ -101,7 +107,8 @@ TDestroyVolumeActor::TDestroyVolumeActor(
TString diskId,
bool destroyIfBroken,
bool sync,
ui64 fillGeneration)
ui64 fillGeneration,
TDuration timeout)
: Sender(sender)
, Cookie(cookie)
, AttachedDiskDestructionTimeout(attachedDiskDestructionTimeout)
Expand All @@ -111,10 +118,12 @@ TDestroyVolumeActor::TDestroyVolumeActor(
, DestroyIfBroken(destroyIfBroken)
, Sync(sync)
, FillGeneration(fillGeneration)
, Timeout(timeout)
{}

void TDestroyVolumeActor::Bootstrap(const TActorContext& ctx)
{
ctx.Schedule(Timeout, new TEvents::TEvWakeup());
if (DestroyIfBroken) {
WaitReady(ctx);
} else {
Expand Down Expand Up @@ -186,12 +195,12 @@ void TDestroyVolumeActor::DeallocateDisk(const TActorContext& ctx)
NCloud::Send(ctx, MakeDiskRegistryProxyServiceId(), std::move(request));
}

void TDestroyVolumeActor::StopPartitions(const TActorContext& ctx)
void TDestroyVolumeActor::GracefulShutdown(const TActorContext& ctx)
{
auto stopPartReq = std::make_unique<
TEvVolume::TEvStopPartitionBeforeVolumeDestructionRequest>();
stopPartReq->Record.SetDiskId(DiskId);
NCloud::Send(ctx, MakeVolumeProxyServiceId(), std::move(stopPartReq));
auto request = std::make_unique<
TEvVolume::TEvGracefulShutdownRequest>();
request->Record.SetDiskId(DiskId);
NCloud::Send(ctx, MakeVolumeProxyServiceId(), std::move(request));
}

NProto::TError TDestroyVolumeActor::CheckIfDestructionIsAllowed() const
Expand Down Expand Up @@ -296,7 +305,7 @@ void TDestroyVolumeActor::HandleMarkDiskForCleanupResponse(
return;
}

StopPartitions(ctx);
GracefulShutdown(ctx);
}

void TDestroyVolumeActor::HandleDeallocateDiskResponse(
Expand Down Expand Up @@ -397,14 +406,28 @@ void TDestroyVolumeActor::HandleStatVolumeResponse(
}
}

void TDestroyVolumeActor::HandleStopPartitions(
const TEvVolume::TEvStopPartitionBeforeVolumeDestructionResponse::TPtr& ev,
void TDestroyVolumeActor::HandleGracefulShutdownResponse(
const TEvVolume::TEvGracefulShutdownResponse::TPtr& ev,
const TActorContext& ctx)
{
Y_UNUSED(ev);
DestroyVolume(ctx);
}

void TDestroyVolumeActor::HandleTimeout(
const TEvents::TEvWakeup::TPtr& ev,
const TActorContext& ctx)
{
Y_UNUSED(ev);

LOG_WARN(
ctx,
TBlockStoreComponents::SERVICE,
"Timeout destroy volume request");

ReplyAndDie(ctx, MakeError(E_TIMEOUT, "Timeout"));
}

void TDestroyVolumeActor::ReplyAndDie(
const TActorContext& ctx,
NProto::TError error)
Expand Down Expand Up @@ -435,8 +458,10 @@ STFUNC(TDestroyVolumeActor::StateWork)
HandleStatVolumeResponse);

HFunc(
TEvVolume::TEvStopPartitionBeforeVolumeDestructionResponse,
HandleStopPartitions);
TEvVolume::TEvGracefulShutdownResponse,
HandleGracefulShutdownResponse);

HFunc(TEvents::TEvWakeup, HandleTimeout);

default:
HandleUnexpectedEvent(ev, TBlockStoreComponents::SERVICE);
Expand Down Expand Up @@ -475,7 +500,8 @@ void TServiceActor::HandleDestroyVolume(
diskId,
destroyIfBroken,
sync,
fillGeneration);
fillGeneration,
Config->GetDestroyVolumeTimeout());
}

} // namespace NCloud::NBlockStore::NStorage
8 changes: 4 additions & 4 deletions cloud/blockstore/libs/storage/volume/testlib/test_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@ TVolumeClient::CreateReadMetaHistoryRequest()
return std::make_unique<TEvVolumePrivate::TEvReadMetaHistoryRequest>();
}

std::unique_ptr<TEvVolume::TEvStopPartitionBeforeVolumeDestructionRequest>
TVolumeClient::CreateStopPartitionBeforeVolumeDestructionRequest() {
return std::make_unique<
TEvVolume::TEvStopPartitionBeforeVolumeDestructionRequest>();
std::unique_ptr<TEvVolume::TEvGracefulShutdownRequest>
TVolumeClient::CreateGracefulShutdownRequest()
{
return std::make_unique<TEvVolume::TEvGracefulShutdownRequest>();
}

void TVolumeClient::SendRemoteHttpInfo(
Expand Down
4 changes: 2 additions & 2 deletions cloud/blockstore/libs/storage/volume/testlib/test_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ class TVolumeClient
std::unique_ptr<TEvVolumePrivate::TEvReadMetaHistoryRequest>
CreateReadMetaHistoryRequest();

std::unique_ptr<TEvVolume::TEvStopPartitionBeforeVolumeDestructionRequest>
CreateStopPartitionBeforeVolumeDestructionRequest();
std::unique_ptr<TEvVolume::TEvGracefulShutdownRequest>
CreateGracefulShutdownRequest();

void SendRemoteHttpInfo(
const TString& params,
Expand Down
16 changes: 6 additions & 10 deletions cloud/blockstore/libs/storage/volume/volume_actor_startstop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,24 +346,22 @@ void TVolumeActor::StartPartitionsForGc(const TActorContext& ctx)
PartitionsStartedReason = EPartitionsStartedReason::STARTED_FOR_GC;
}

void TVolumeActor::HandleStopPartitionBeforeVolumeDestruction(
const TEvVolume::TEvStopPartitionBeforeVolumeDestructionRequest::TPtr& ev,
void TVolumeActor::HandleGracefulShutdown(
const TEvVolume::TEvGracefulShutdownRequest::TPtr& ev,
const TActorContext& ctx)
{
if (!State->GetDiskRegistryBasedPartitionActor()) {
LOG_ERROR(
ctx,
TBlockStoreComponents::VOLUME,
"[%lu] StopPartitionBeforeVolumeDestruction request was send to "
"not "
"DR based disk",
"[%lu] GracefulShutdown request was send to "
"not DR based disk",
TabletID());

NCloud::Reply(
ctx,
*ev,
std::make_unique<
TEvVolume::TEvStopPartitionBeforeVolumeDestructionResponse>(
std::make_unique<TEvVolume::TEvGracefulShutdownResponse>(
MakeError(E_NOT_IMPLEMENTED, "request not supported")));
return;
}
Expand All @@ -383,9 +381,7 @@ void TVolumeActor::HandleStopPartitionBeforeVolumeDestruction(
NCloud::Reply(
ctx,
*reqInfo,
std::make_unique<
TEvVolume::
TEvStopPartitionBeforeVolumeDestructionResponse>());
std::make_unique<TEvVolume::TEvGracefulShutdownResponse>());
});

TerminateTransactions(ctx);
Expand Down
6 changes: 3 additions & 3 deletions cloud/blockstore/libs/storage/volume/volume_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8175,7 +8175,7 @@ Y_UNIT_TEST_SUITE(TVolumeTest)
0,
false,
1,
NCloud::NProto::EStorageMediaKind::STORAGE_MEDIA_SSD_NONREPLICATED,
NCloud::NProto::STORAGE_MEDIA_SSD_NONREPLICATED,
1024,
"vol0",
"cloud",
Expand All @@ -8190,10 +8190,10 @@ Y_UNIT_TEST_SUITE(TVolumeTest)
false);


volume.StopPartitionBeforeVolumeDestruction();
volume.GracefulShutdown();
UNIT_ASSERT(partitionsStopped);

// Check that volume after TEvStopPartitionBeforeVolumeDestructionRequest
// Check that volume after TEvGracefulShutdownRequest
// in zombie state and rejects requsts.
volume.SendGetVolumeInfoRequest();
auto response = volume.RecvGetVolumeInfoResponse();
Expand Down

0 comments on commit ce82bbb

Please sign in to comment.