24
24
25
25
namespace {
26
26
struct TWriteActorBackoffSettings {
27
- TDuration StartRetryDelay = TDuration::MilliSeconds(150 );
28
- TDuration MaxRetryDelay = TDuration::Seconds(5 );
27
+ TDuration StartRetryDelay = TDuration::MilliSeconds(250 );
28
+ TDuration MaxRetryDelay = TDuration::Seconds(10 );
29
29
double UnsertaintyRatio = 0.5 ;
30
30
double Multiplier = 2.0 ;
31
31
@@ -218,16 +218,15 @@ class TKqpWriteActor : public TActorBootstrapped<TKqpWriteActor>, public NYql::N
218
218
219
219
void CheckMemory () {
220
220
const auto freeSpace = Writer.GetFreeSpace ();
221
- if (NeedToResume && freeSpace > 0 ) {
222
- Writer.Callbacks ->ResumeExecution ();
223
- } else if (!NeedToResume && freeSpace <= 0 ) {
224
- NeedToResume = true ;
221
+ if (freeSpace > LastFreeMemory) {
222
+ Writer.ResumeExecution ();
225
223
}
224
+ LastFreeMemory = freeSpace;
226
225
}
227
226
228
227
private:
229
228
TKqpWriteActor& Writer;
230
- bool NeedToResume = false ;
229
+ i64 LastFreeMemory = std::numeric_limits<i64>::max() ;
231
230
};
232
231
233
232
friend class TResumeNotificationManager ;
@@ -291,9 +290,14 @@ class TKqpWriteActor : public TActorBootstrapped<TKqpWriteActor>, public NYql::N
291
290
}
292
291
293
292
i64 GetFreeSpace () const final {
294
- return Serializer
293
+ const i64 result = Serializer
295
294
? MemoryLimit - Serializer->GetMemory () - ShardsInfo.GetMemory ()
296
295
: std::numeric_limits<i64>::min (); // Can't use zero here because compute can use overcommit!
296
+
297
+ if (result <= 0 ) {
298
+ CA_LOG_D (" No free space left. FreeSpace=" << result << " bytes." );
299
+ }
300
+ return result;
297
301
}
298
302
299
303
TMaybe<google::protobuf::Any> ExtraData () override {
@@ -308,12 +312,14 @@ class TKqpWriteActor : public TActorBootstrapped<TKqpWriteActor>, public NYql::N
308
312
return result;
309
313
}
310
314
311
- void SendData (NMiniKQL::TUnboxedValueBatch&& data, i64, const TMaybe<NYql::NDqProto::TCheckpoint>&, bool finished) final {
315
+ void SendData (NMiniKQL::TUnboxedValueBatch&& data, i64 size , const TMaybe<NYql::NDqProto::TCheckpoint>&, bool finished) final {
312
316
YQL_ENSURE (!data.IsWide (), " Wide stream is not supported yet" );
313
317
YQL_ENSURE (!Finished);
314
318
Finished = finished;
315
319
EgressStats.Resume ();
316
320
321
+ CA_LOG_D (" New data: size=" << size << " , finished=" << finished << " ." );
322
+
317
323
YQL_ENSURE (Serializer);
318
324
try {
319
325
Serializer->AddData (std::move (data), Finished);
@@ -394,8 +400,6 @@ class TKqpWriteActor : public TActorBootstrapped<TKqpWriteActor>, public NYql::N
394
400
}
395
401
396
402
Prepare ();
397
-
398
- Callbacks->ResumeExecution ();
399
403
}
400
404
401
405
void Handle (NKikimr::NEvents::TDataEvents::TEvWriteResult::TPtr& ev) {
@@ -554,7 +558,8 @@ class TKqpWriteActor : public TActorBootstrapped<TKqpWriteActor>, public NYql::N
554
558
555
559
CA_LOG_D (" Send EvWrite to ShardID=" << shardId << " , TxId=" << std::get<ui64>(TxId)
556
560
<< " , LockTxId=" << Settings.GetLockTxId () << " , LockNodeId=" << Settings.GetLockNodeId ()
557
- << " , Size=" << inFlightBatch.Data .size () << " , Cookie=" << inFlightBatch.Cookie );
561
+ << " , Size=" << inFlightBatch.Data .size () << " , Cookie=" << inFlightBatch.Cookie
562
+ << " ; ShardBatchesLeft=" << shard.Size () << " , ShardClosed=" << shard.IsClosed ());
558
563
Send (
559
564
PipeCacheId,
560
565
new TEvPipeCache::TEvForward (evWrite.release (), shardId, true ),
@@ -628,13 +633,18 @@ class TKqpWriteActor : public TActorBootstrapped<TKqpWriteActor>, public NYql::N
628
633
*SchemeEntry,
629
634
columnsMetadata,
630
635
TypeEnv);
636
+ ResumeExecution ();
631
637
} catch (...) {
632
638
RuntimeError (
633
639
CurrentExceptionMessage (),
634
640
NYql::NDqProto::StatusIds::INTERNAL_ERROR);
635
641
}
636
642
}
637
643
644
+ void ResumeExecution () {
645
+ CA_LOG_D (" Resuming execution." );
646
+ Callbacks->ResumeExecution ();
647
+ }
638
648
639
649
NActors::TActorId TxProxyId = MakeTxProxyID();
640
650
NActors::TActorId PipeCacheId = NKikimr::MakePipePeNodeCacheID(false );
0 commit comments