@@ -81,7 +81,10 @@ void PrepareCreationUnixTime(const R& request, I& interm)
81
81
// Guideline:
82
82
// Check SetError calls: there must be no changes made to the DB before SetError call (!)
83
83
84
- TKeyValueState::TKeyValueState () {
84
+ TKeyValueState::TKeyValueState ()
85
+ : ReadRequestsInFlightLimit_Base(3 , 1 , 4096 )
86
+ , ReadRequestsInFlightLimit(ReadRequestsInFlightLimit_Base)
87
+ {
85
88
TabletCounters = nullptr ;
86
89
Clear ();
87
90
}
@@ -114,7 +117,6 @@ void TKeyValueState::Clear() {
114
117
115
118
Queue.clear ();
116
119
IntermediatesInFlight = 0 ;
117
- IntermediatesInFlightLimit = 3 ; // FIXME: Change to something like 10
118
120
RoInlineIntermediatesInFlight = 0 ;
119
121
DeletesPerRequestLimit = 100'000 ;
120
122
@@ -551,6 +553,14 @@ void TKeyValueState::InitExecute(ui64 tabletId, TActorId keyValueActorId, ui32 e
551
553
}
552
554
ChannelBalancerActorId = ctx.Register (new TChannelBalancer (maxChannel + 1 , KeyValueActorId));
553
555
556
+ TActorSystem *actorSystem = TActivationContext::ActorSystem ();
557
+ if (actorSystem && actorSystem->AppData <TAppData>() && actorSystem->AppData <TAppData>()->Icb ) {
558
+ const TIntrusivePtr<NKikimr::TControlBoard>& icb = actorSystem->AppData <TAppData>()->Icb ;
559
+
560
+ icb->RegisterSharedControl (ReadRequestsInFlightLimit_Base, " KeyValueVolumeControls.ReadRequestsInFlightLimit" );
561
+ ReadRequestsInFlightLimit.ResetControl (ReadRequestsInFlightLimit_Base);
562
+ }
563
+
554
564
// Issue hard barriers
555
565
using TGroupChannel = std::tuple<ui32, ui8>;
556
566
{
@@ -1831,7 +1841,8 @@ void TKeyValueState::OnRequestComplete(ui64 requestUid, ui64 generation, ui64 st
1831
1841
CountRequestComplete (status, stat, ctx);
1832
1842
ResourceMetrics->TryUpdate (ctx);
1833
1843
1834
- if (Queue.size () && IntermediatesInFlight < IntermediatesInFlightLimit) {
1844
+ ui64 limit = ReadRequestsInFlightLimit.Update (ctx.Now ());
1845
+ if (Queue.size () && IntermediatesInFlight < limit) {
1835
1846
TRequestType::EType requestType = Queue.front ()->Stat .RequestType ;
1836
1847
1837
1848
CountLatencyQueue (Queue.front ()->Stat );
@@ -2488,14 +2499,14 @@ bool TKeyValueState::PrepareCmdPatch(const TActorContext &ctx, NKikimrClient::TK
2488
2499
return true ;
2489
2500
}
2490
2501
}
2491
- interm.Diffs [diffIdx].Offset = diff.GetOffset ();
2502
+ interm.Diffs [diffIdx].Offset = diff.GetOffset ();
2492
2503
}
2493
2504
2494
2505
ui32 storageChannelIdx = BLOB_CHANNEL;
2495
2506
if (request.HasStorageChannel ()) {
2496
2507
auto storageChannel = request.GetStorageChannel ();
2497
2508
ui32 storageChannelOffset = (ui32)storageChannel;
2498
-
2509
+
2499
2510
if (storageChannelOffset == NKikimrClient::TKeyValueRequest::INLINE) {
2500
2511
TStringStream str;
2501
2512
str << " KeyValue# " << TabletId;
@@ -3188,14 +3199,15 @@ void TKeyValueState::OnEvReadRequest(TEvKeyValue::TEvRead::TPtr &ev, const TActo
3188
3199
RegisterReadRequestActor (ctx, std::move (intermediate), info, ExecutorGeneration);
3189
3200
++RoInlineIntermediatesInFlight;
3190
3201
} else {
3191
- if (IntermediatesInFlight < IntermediatesInFlightLimit) {
3202
+ ui64 limit = ReadRequestsInFlightLimit.Update (ctx.Now ());
3203
+ if (IntermediatesInFlight < limit) {
3204
+ ++IntermediatesInFlight;
3192
3205
ALOG_DEBUG (NKikimrServices::KEYVALUE, " KeyValue# " << TabletId
3193
- << " Create storage read request, Marker# KV54" );
3206
+ << " Create storage read request, InFlight# " << IntermediatesInFlight << " / " << limit << " , Marker# KV54" );
3194
3207
RegisterReadRequestActor (ctx, std::move (intermediate), info, ExecutorGeneration);
3195
- ++IntermediatesInFlight;
3196
3208
} else {
3197
3209
ALOG_DEBUG (NKikimrServices::KEYVALUE, " KeyValue# " << TabletId
3198
- << " Enqueue storage read request " << IntermediatesInFlight << ' /' << IntermediatesInFlightLimit << " , Marker# KV56" );
3210
+ << " Enqueue storage read request " << IntermediatesInFlight << ' /' << limit << " , Marker# KV56" );
3199
3211
PostponeIntermediate<TEvKeyValue::TEvRead>(std::move (intermediate));
3200
3212
}
3201
3213
}
@@ -3224,11 +3236,12 @@ void TKeyValueState::OnEvReadRangeRequest(TEvKeyValue::TEvReadRange::TPtr &ev, c
3224
3236
RegisterReadRequestActor (ctx, std::move (intermediate), info, ExecutorGeneration);
3225
3237
++RoInlineIntermediatesInFlight;
3226
3238
} else {
3227
- if (IntermediatesInFlight < IntermediatesInFlightLimit) {
3239
+ ui64 limit = ReadRequestsInFlightLimit.Update (ctx.Now ());
3240
+ if (IntermediatesInFlight < limit) {
3241
+ ++IntermediatesInFlight;
3228
3242
ALOG_DEBUG (NKikimrServices::KEYVALUE, " KeyValue# " << TabletId
3229
- << " Create storage read range request, Marker# KV66" );
3243
+ << " Create storage read range request, InFlight# " << IntermediatesInFlight << " / " << limit << " , Marker# KV66" );
3230
3244
RegisterReadRequestActor (ctx, std::move (intermediate), info, ExecutorGeneration);
3231
- ++IntermediatesInFlight;
3232
3245
} else {
3233
3246
ALOG_DEBUG (NKikimrServices::KEYVALUE, " KeyValue# " << TabletId
3234
3247
<< " Enqueue storage read range request, Marker# KV59" );
@@ -3365,11 +3378,12 @@ void TKeyValueState::OnEvRequest(TEvKeyValue::TEvRequest::TPtr &ev, const TActor
3365
3378
RegisterRequestActor (ctx, std::move (intermediate), info, ExecutorGeneration);
3366
3379
++RoInlineIntermediatesInFlight;
3367
3380
} else {
3368
- if (IntermediatesInFlight < IntermediatesInFlightLimit) {
3381
+ ui64 limit = ReadRequestsInFlightLimit.Update (ctx.Now ());
3382
+ if (IntermediatesInFlight < limit) {
3383
+ ++IntermediatesInFlight;
3369
3384
ALOG_DEBUG (NKikimrServices::KEYVALUE, " KeyValue# " << TabletId
3370
- << " Create storage request for RO/RW, Marker# KV43" );
3385
+ << " Create storage request for RO/RW, InFlight# " << IntermediatesInFlight << " / " << limit << " , Marker# KV43" );
3371
3386
RegisterRequestActor (ctx, std::move (intermediate), info, ExecutorGeneration);
3372
- ++IntermediatesInFlight;
3373
3387
} else {
3374
3388
ALOG_DEBUG (NKikimrServices::KEYVALUE, " KeyValue# " << TabletId
3375
3389
<< " Enqueue storage request for RO/RW, Marker# KV44" );
0 commit comments