@@ -492,7 +492,8 @@ void TPartition::Handle(TEvPQ::TEvMirrorerCounters::TPtr& ev, const TActorContex
492
492
}
493
493
}
494
494
495
- void TPartition::Handle (TEvents::TEvPoisonPill::TPtr&, const TActorContext& ctx) {
495
+ void TPartition::DestroyActor (const TActorContext& ctx)
496
+ {
496
497
// Reply to all outstanding requests in order to destroy corresponding actors
497
498
498
499
TStringBuilder ss;
@@ -523,12 +524,19 @@ void TPartition::Handle(TEvents::TEvPoisonPill::TPtr&, const TActorContext& ctx)
523
524
UsersInfoStorage->Clear (ctx);
524
525
}
525
526
526
- Send (ReadQuotaTrackerActor, new TEvents::TEvPoisonPill ());
527
- Send (WriteQuotaTrackerActor, new TEvents::TEvPoisonPill ());
527
+ if (!IsSupportive ()) {
528
+ Send (ReadQuotaTrackerActor, new TEvents::TEvPoisonPill ());
529
+ Send (WriteQuotaTrackerActor, new TEvents::TEvPoisonPill ());
530
+ }
528
531
529
532
Die (ctx);
530
533
}
531
534
535
+ void TPartition::Handle (TEvents::TEvPoisonPill::TPtr&, const TActorContext& ctx)
536
+ {
537
+ DestroyActor (ctx);
538
+ }
539
+
532
540
bool CheckDiskStatus (const TStorageStatusFlags status) {
533
541
return !status.Check (NKikimrBlobStorage::StatusDiskSpaceYellowStop);
534
542
}
@@ -1020,6 +1028,7 @@ void TPartition::Handle(TEvPQ::TEvGetWriteInfoResponse::TPtr& ev, const TActorCo
1020
1028
--ImmediateTxCount;
1021
1029
1022
1030
ProcessImmediateTx (tx, predicate, ctx);
1031
+ ScheduleTransactionCompleted (tx);
1023
1032
TxInProgress = false ;
1024
1033
ContinueProcessTxsAndUserActs (ctx);
1025
1034
@@ -1056,6 +1065,7 @@ void TPartition::Handle(TEvPQ::TEvGetWriteInfoError::TPtr& ev, const TActorConte
1056
1065
NKikimrPQ::TEvProposeTransactionResult::ABORTED,
1057
1066
NKikimrPQ::TError::BAD_REQUEST,
1058
1067
ev->Get ()->Message );
1068
+ ScheduleTransactionCompleted (t->Record );
1059
1069
1060
1070
UserActionAndTransactionEvents.pop_front ();
1061
1071
--ImmediateTxCount;
@@ -1574,13 +1584,11 @@ void TPartition::Handle(TEvKeyValue::TEvResponse::TPtr& ev, const TActorContext&
1574
1584
1575
1585
const auto writeDuration = ctx.Now () - WriteStartTime;
1576
1586
const auto minWriteLatency = TDuration::MilliSeconds (AppData (ctx)->PQConfig .GetMinWriteLatencyMs ());
1587
+
1577
1588
if (writeDuration > minWriteLatency) {
1578
- KVWriteInProgress = false ;
1579
- OnProcessTxsAndUserActsWriteComplete (ctx);
1580
- HandleWriteResponse (ctx);
1581
- ProcessTxsAndUserActs (ctx);
1589
+ OnHandleWriteResponse (ctx);
1582
1590
} else {
1583
- ctx.Schedule (minWriteLatency - writeDuration, new TEvPQ::TEvHandleWriteResponse ());
1591
+ ctx.Schedule (minWriteLatency - writeDuration, new TEvPQ::TEvHandleWriteResponse (response. GetCookie () ));
1584
1592
}
1585
1593
}
1586
1594
@@ -1658,6 +1666,19 @@ void TPartition::ContinueProcessTxsAndUserActs(const TActorContext& ctx)
1658
1666
1659
1667
THolder<TEvKeyValue::TEvRequest> request (new TEvKeyValue::TEvRequest);
1660
1668
1669
+ if (DeletePartitionState == DELETION_INITED) {
1670
+ ScheduleNegativeReplies ();
1671
+ ScheduleDeletePartitionDone ();
1672
+
1673
+ AddCmdDeleteRangeForAllKeys (*request);
1674
+
1675
+ ctx.Send (Tablet, request.Release ());
1676
+
1677
+ DeletePartitionState = DELETION_IN_PROCESS;
1678
+
1679
+ return ;
1680
+ }
1681
+
1661
1682
HaveWriteMsg = false ;
1662
1683
1663
1684
if (UserActionAndTransactionEvents.empty ()) {
@@ -2629,6 +2650,12 @@ void TPartition::SchedulePartitionConfigChanged()
2629
2650
MakeHolder<TEvPQ::TEvPartitionConfigChanged>(Partition).Release ());
2630
2651
}
2631
2652
2653
+ void TPartition::ScheduleDeletePartitionDone ()
2654
+ {
2655
+ Replies.emplace_back (Tablet,
2656
+ MakeHolder<TEvPQ::TEvDeletePartitionDone>(Partition).Release ());
2657
+ }
2658
+
2632
2659
void TPartition::AddCmdDeleteRange (NKikimrClient::TKeyValueRequest& request,
2633
2660
const TKeyPrefix& ikey, const TKeyPrefix& ikeyDeprecated)
2634
2661
{
@@ -3013,6 +3040,82 @@ void TPartition::Handle(TEvPQ::TEvCheckPartitionStatusRequest::TPtr& ev, const T
3013
3040
Send (ev->Sender , response.Release ());
3014
3041
}
3015
3042
3043
+ void TPartition::HandleOnInit (TEvPQ::TEvDeletePartition::TPtr& ev, const TActorContext&)
3044
+ {
3045
+ PendingEvents.emplace_back (ev->ReleaseBase ().Release ());
3046
+ }
3047
+
3048
+ void TPartition::Handle (TEvPQ::TEvDeletePartition::TPtr&, const TActorContext& ctx)
3049
+ {
3050
+ Y_ABORT_UNLESS (IsSupportive ());
3051
+ Y_ABORT_UNLESS (DeletePartitionState == DELETION_NOT_INITED);
3052
+
3053
+ DeletePartitionState = DELETION_INITED;
3054
+
3055
+ ProcessTxsAndUserActs (ctx);
3056
+ }
3057
+
3058
+ void TPartition::ScheduleNegativeReplies ()
3059
+ {
3060
+ for (auto & event : UserActionAndTransactionEvents) {
3061
+ auto visitor = [this ](auto & event) {
3062
+ using T = std::decay_t <decltype (event)>;
3063
+ if constexpr (TIsSimpleSharedPtr<T>::value) {
3064
+ return this ->ScheduleNegativeReply (*event);
3065
+ } else {
3066
+ return this ->ScheduleNegativeReply (event);
3067
+ }
3068
+ };
3069
+
3070
+ std::visit (visitor, event);
3071
+ }
3072
+
3073
+ UserActionAndTransactionEvents.clear ();
3074
+ }
3075
+
3076
+ void TPartition::AddCmdDeleteRangeForAllKeys (TEvKeyValue::TEvRequest& request)
3077
+ {
3078
+ NPQ::AddCmdDeleteRange (request, TKeyPrefix::TypeInfo, Partition);
3079
+ NPQ::AddCmdDeleteRange (request, TKeyPrefix::TypeData, Partition);
3080
+ NPQ::AddCmdDeleteRange (request, TKeyPrefix::TypeTmpData, Partition);
3081
+ NPQ::AddCmdDeleteRange (request, TKeyPrefix::TypeMeta, Partition);
3082
+ NPQ::AddCmdDeleteRange (request, TKeyPrefix::TypeTxMeta, Partition);
3083
+ }
3084
+
3085
+ void TPartition::ScheduleNegativeReply (const TEvPQ::TEvSetClientInfo&)
3086
+ {
3087
+ Y_ABORT (" The supportive partition does not accept read operations" );
3088
+ }
3089
+
3090
+ void TPartition::ScheduleNegativeReply (const TEvPersQueue::TEvProposeTransaction&)
3091
+ {
3092
+ Y_ABORT (" The supportive partition does not accept immediate transactions" );
3093
+ }
3094
+
3095
+ void TPartition::ScheduleNegativeReply (const TTransaction&)
3096
+ {
3097
+ Y_ABORT (" The supportive partition does not accept distribute transactions" );
3098
+ }
3099
+
3100
+ void TPartition::ScheduleNegativeReply (const TMessage& msg)
3101
+ {
3102
+ ScheduleReplyError (msg.GetCookie (), NPersQueue::NErrorCode::ERROR, " The transaction is completed" );
3103
+ }
3104
+
3105
+ void TPartition::ScheduleTransactionCompleted (const NKikimrPQ::TEvProposeTransaction& tx)
3106
+ {
3107
+ Y_ABORT_UNLESS (tx.GetTxBodyCase () == NKikimrPQ::TEvProposeTransaction::kData );
3108
+ Y_ABORT_UNLESS (tx.HasData ());
3109
+
3110
+ TMaybe<ui64> writeId;
3111
+ if (tx.GetData ().HasWriteId ()) {
3112
+ writeId = tx.GetData ().GetWriteId ();
3113
+ }
3114
+
3115
+ Replies.emplace_back (Tablet,
3116
+ MakeHolder<TEvPQ::TEvTransactionCompleted>(writeId).Release ());
3117
+ }
3118
+
3016
3119
const NKikimrPQ::TPQTabletConfig::TPartition* TPartition::GetPartitionConfig (const NKikimrPQ::TPQTabletConfig& config)
3017
3120
{
3018
3121
return NPQ::GetPartitionConfig (config, Partition.OriginalPartitionId );
0 commit comments