Skip to content

Commit

Permalink
Always respond with E_REJECT when killing a volume tablet actor (#1988)
Browse files Browse the repository at this point in the history
* Save all partition requests info in VolumeRequests

* Test

* Fix review issues

* Small improvements
  • Loading branch information
drbasic committed Oct 25, 2024
1 parent e3a0ca1 commit e9b8765
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 203 deletions.
34 changes: 0 additions & 34 deletions cloud/blockstore/libs/storage/volume/multi_partition_requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class TMultiPartitionRequestActor final
{
private:
const TRequestInfoPtr RequestInfo;
const NActors::TActorId VolumeActorId;
const ui64 VolumeRequestId;
const TBlockRange64 OriginalRange;
const ui32 BlocksPerStripe;
const ui32 BlockSize;
Expand All @@ -72,8 +70,6 @@ class TMultiPartitionRequestActor final
public:
TMultiPartitionRequestActor(
TRequestInfoPtr requestInfo,
NActors::TActorId volumeActorId,
ui64 volumeRequestId,
TBlockRange64 originalRange,
ui32 blocksPerStripe,
ui32 blockSize,
Expand Down Expand Up @@ -276,8 +272,6 @@ class TMultiPartitionRequestActor final
MergeCommonFields(src, dst);
}

void NotifyCompleted(const NActors::TActorContext& ctx);

void ForkTraces(TCallContextPtr callContext)
{
auto& cc = RequestInfo->CallContext;
Expand Down Expand Up @@ -305,17 +299,13 @@ class TMultiPartitionRequestActor final
template <typename TMethod>
TMultiPartitionRequestActor<TMethod>::TMultiPartitionRequestActor(
TRequestInfoPtr requestInfo,
NActors::TActorId volumeActorId,
ui64 volumeRequestId,
TBlockRange64 originalRange,
ui32 blocksPerStripe,
ui32 blockSize,
ui32 partitionsCount,
TVector<TPartitionRequest<TMethod>> partitionRequests,
TRequestTraceInfo traceInfo)
: RequestInfo(std::move(requestInfo))
, VolumeActorId(volumeActorId)
, VolumeRequestId(volumeRequestId)
, OriginalRange(originalRange)
, BlocksPerStripe(blocksPerStripe)
, BlockSize(blockSize)
Expand Down Expand Up @@ -368,26 +358,6 @@ void TMultiPartitionRequestActor<TMethod>::Prepare(

////////////////////////////////////////////////////////////////////////////////

template <typename TMethod>
void TMultiPartitionRequestActor<TMethod>::NotifyCompleted(
const NActors::TActorContext& ctx)
{
if constexpr (RequiresReadWriteAccess<TMethod>) {
using TEvent = TEvVolumePrivate::TEvMultipartitionWriteOrZeroCompleted;
auto ev = std::make_unique<TEvent>(
VolumeRequestId,
Record.GetError().GetCode());

NCloud::Send(
ctx,
VolumeActorId,
std::move(ev)
);
}
}

////////////////////////////////////////////////////////////////////////////////

template <typename TMethod>
void TMultiPartitionRequestActor<TMethod>::HandlePartitionResponse(
const typename TMethod::TResponse::TPtr& ev,
Expand Down Expand Up @@ -426,8 +396,6 @@ void TMultiPartitionRequestActor<TMethod>::HandlePartitionResponse(

NCloud::Reply(ctx, *RequestInfo, std::move(response));

NotifyCompleted(ctx);

TBase::Die(ctx);
}
}
Expand Down Expand Up @@ -456,8 +424,6 @@ void TMultiPartitionRequestActor<TMethod>::HandleUndelivery(

NCloud::Reply(ctx, *RequestInfo, std::move(response));

NotifyCompleted(ctx);

TBase::Die(ctx);
}

Expand Down
3 changes: 0 additions & 3 deletions cloud/blockstore/libs/storage/volume/volume_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,6 @@ STFUNC(TVolumeActor::StateWork)
HandleDiskRegistryBasedPartCounters);
HFunc(TEvStatsService::TEvVolumePartCounters, HandlePartCounters);
HFunc(TEvVolumePrivate::TEvPartStatsSaved, HandlePartStatsSaved);
HFunc(
TEvVolumePrivate::TEvMultipartitionWriteOrZeroCompleted,
HandleMultipartitionWriteOrZeroCompleted);
HFunc(
TEvVolumePrivate::TEvWriteOrZeroCompleted,
HandleWriteOrZeroCompleted);
Expand Down
41 changes: 28 additions & 13 deletions cloud/blockstore/libs/storage/volume/volume_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,29 @@ class TVolumeActor final
TCallContext& callContext,
NProto::TError error);

NActors::TActorId Caller;
ui64 CallerCookie;
TCallContextPtr CallContext;
TCallContextPtr ForkedContext;
ui64 ReceiveTime;
TCancelRoutine* CancelRoutine;
const NActors::TActorId Caller;
const ui64 CallerCookie;
const TCallContextPtr CallContext;
const TCallContextPtr ForkedContext;
const ui64 ReceiveTime;
TCancelRoutine* const CancelRoutine;
const bool IsMultipartitionWriteOrZero;

TVolumeRequest(
const NActors::TActorId& caller,
ui64 callerCookie,
TCallContextPtr callContext,
TCallContextPtr forkedContext,
ui64 receiveTime,
TCancelRoutine cancelRoutine)
TCancelRoutine cancelRoutine,
bool isMultipartitionWriteOrZero)
: Caller(caller)
, CallerCookie(callerCookie)
, CallContext(std::move(callContext))
, ForkedContext(std::move(forkedContext))
, ReceiveTime(receiveTime)
, CancelRoutine(cancelRoutine)
, IsMultipartitionWriteOrZero(isMultipartitionWriteOrZero)
{}

void CancelRequest(
Expand Down Expand Up @@ -645,14 +648,18 @@ class TVolumeActor final
const TEvVolumePrivate::TEvPartStatsSaved::TPtr& ev,
const NActors::TActorContext& ctx);

void HandleMultipartitionWriteOrZeroCompleted(
const TEvVolumePrivate::TEvMultipartitionWriteOrZeroCompleted::TPtr& ev,
const NActors::TActorContext& ctx);

void HandleWriteOrZeroCompleted(
const TEvVolumePrivate::TEvWriteOrZeroCompleted::TPtr& ev,
const NActors::TActorContext& ctx);

template <typename TMethod>
bool ReplyToOriginalRequest(
const NActors::TActorContext& ctx,
NActors::TActorId sender,
NActors::IEventHandle::TEventFlags flags,
ui64 volumeRequestId,
std::unique_ptr<typename TMethod::TResponse> response);

void ReplyToDuplicateRequests(
const NActors::TActorContext& ctx,
ui64 key,
Expand Down Expand Up @@ -818,6 +825,15 @@ class TVolumeActor final
TCallContext& callContext,
ui64 startTime);

template <typename TMethod>
typename TMethod::TRequest::TPtr WrapRequest(
const typename TMethod::TRequest::TPtr& ev,
NActors::TActorId newRecipient,
ui64 volumeRequestId,
ui64 traceTime,
bool forkTraces,
bool isMultipartition);

template <typename TMethod>
void SendRequestToPartition(
const NActors::TActorContext& ctx,
Expand Down Expand Up @@ -849,7 +865,6 @@ class TVolumeActor final
void HandleCheckpointRequest(
const NActors::TActorContext& ctx,
const typename TMethod::TRequest::TPtr& ev,
ui64 volumeRequestId,
bool isTraced,
ui64 traceTs);

Expand All @@ -865,7 +880,7 @@ class TVolumeActor final
bool throttlingDisabled);

template <typename TMethod>
void HandleResponse(
void ForwardResponse(
const NActors::TActorContext& ctx,
const typename TMethod::TResponse::TPtr& ev);

Expand Down
11 changes: 0 additions & 11 deletions cloud/blockstore/libs/storage/volume/volume_actor_checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,12 +926,9 @@ template <>
void TVolumeActor::HandleCheckpointRequest<TCreateCheckpointMethod>(
const TActorContext& ctx,
const TCreateCheckpointMethod::TRequest::TPtr& ev,
ui64 volumeRequestId,
bool isTraced,
ui64 traceTs)
{
Y_UNUSED(volumeRequestId);

const auto& msg = *ev->Get();

auto requestInfo = CreateRequestInfo<TCreateCheckpointMethod>(
Expand Down Expand Up @@ -962,12 +959,9 @@ template <>
void TVolumeActor::HandleCheckpointRequest<TDeleteCheckpointMethod>(
const TActorContext& ctx,
const TDeleteCheckpointMethod::TRequest::TPtr& ev,
ui64 volumeRequestId,
bool isTraced,
ui64 traceTs)
{
Y_UNUSED(volumeRequestId);

const auto& msg = *ev->Get();

auto requestInfo = CreateRequestInfo<TDeleteCheckpointMethod>(
Expand All @@ -991,12 +985,9 @@ template <>
void TVolumeActor::HandleCheckpointRequest<TDeleteCheckpointDataMethod>(
const TActorContext& ctx,
const TDeleteCheckpointDataMethod::TRequest::TPtr& ev,
ui64 volumeRequestId,
bool isTraced,
ui64 traceTs)
{
Y_UNUSED(volumeRequestId);

const auto& msg = *ev->Get();

auto requestInfo = CreateRequestInfo<TDeleteCheckpointDataMethod>(
Expand All @@ -1020,11 +1011,9 @@ template <>
void TVolumeActor::HandleCheckpointRequest<TGetCheckpointStatusMethod>(
const TActorContext& ctx,
const TGetCheckpointStatusMethod::TRequest::TPtr& ev,
ui64 volumeRequestId,
bool isTraced,
ui64 traceTs)
{
Y_UNUSED(volumeRequestId);
Y_UNUSED(isTraced);
Y_UNUSED(traceTs);

Expand Down
Loading

0 comments on commit e9b8765

Please sign in to comment.