@@ -316,9 +316,16 @@ class TRowDispatcher : public TActorBootstrapped<TRowDispatcher> {
316
316
TMap<TActorId, SessionInfo> Sessions; // key - TopicSession actor id
317
317
};
318
318
319
+ struct ReadActorInfo {
320
+ TString InternalState;
321
+ TInstant RequestTime;
322
+ TInstant ResponseTime;
323
+ };
324
+
319
325
THashMap<ConsumerSessionKey, TAtomicSharedPtr<ConsumerInfo>, ConsumerSessionKeyHash> Consumers;
320
326
TMap<ui64, TAtomicSharedPtr<ConsumerInfo>> ConsumersByEventQueueId;
321
327
THashMap<TopicSessionKey, TopicSessionInfo, TopicSessionKeyHash> TopicSessions;
328
+ TMap<TActorId, ReadActorInfo> ReadActorsInternalState;
322
329
323
330
public:
324
331
explicit TRowDispatcher (
@@ -352,6 +359,7 @@ class TRowDispatcher : public TActorBootstrapped<TRowDispatcher> {
352
359
void Handle (NFq::TEvRowDispatcher::TEvSessionError::TPtr& ev);
353
360
void Handle (NFq::TEvRowDispatcher::TEvStatistics::TPtr& ev);
354
361
void Handle (NFq::TEvRowDispatcher::TEvSessionStatistic::TPtr& ev);
362
+ void Handle (NFq::TEvRowDispatcher::TEvGetInternalStateResponse::TPtr& ev);
355
363
356
364
void Handle (NFq::TEvRowDispatcher::TEvHeartbeat::TPtr& ev);
357
365
void Handle (const TEvPrivate::TEvTryConnect::TPtr&);
@@ -363,6 +371,8 @@ class TRowDispatcher : public TActorBootstrapped<TRowDispatcher> {
363
371
void DeleteConsumer (const ConsumerSessionKey& key);
364
372
void UpdateMetrics ();
365
373
TString GetInternalState ();
374
+ TString GetReadActorsInternalState ();
375
+ void UpdateReadActorsInternalState ();
366
376
template <class TEventPtr >
367
377
bool CheckSession (TAtomicSharedPtr<ConsumerInfo>& consumer, const TEventPtr& ev);
368
378
void SetQueryMetrics (const TQueryStatKey& queryKey, ui64 unreadBytesMax, ui64 unreadBytesAvg, i64 readLagMessagesMax);
@@ -384,6 +394,7 @@ class TRowDispatcher : public TActorBootstrapped<TRowDispatcher> {
384
394
hFunc (NFq::TEvRowDispatcher::TEvSessionError, Handle );
385
395
hFunc (NFq::TEvRowDispatcher::TEvStatistics, Handle );
386
396
hFunc (NFq::TEvRowDispatcher::TEvSessionStatistic, Handle );
397
+ hFunc (NFq::TEvRowDispatcher::TEvGetInternalStateResponse, Handle );
387
398
hFunc (TEvPrivate::TEvTryConnect, Handle );
388
399
hFunc (NYql::NDq::TEvRetryQueuePrivate::TEvEvHeartbeat, Handle );
389
400
hFunc (NFq::TEvRowDispatcher::TEvHeartbeat, Handle );
@@ -656,6 +667,39 @@ TString TRowDispatcher::GetInternalState() {
656
667
return str.Str ();
657
668
}
658
669
670
+ TString TRowDispatcher::GetReadActorsInternalState () {
671
+ TStringStream str;
672
+ for (const auto & [_, internalState]: ReadActorsInternalState) {
673
+ str << " ResponseTime: " << internalState.ResponseTime << " " << internalState.InternalState << Endl;
674
+ }
675
+ return str.Str ();
676
+ }
677
+
678
+ void TRowDispatcher::UpdateReadActorsInternalState () {
679
+ TSet<TActorId> ReadActors;
680
+ for (const auto & [key, _]: Consumers) {
681
+ ReadActors.insert (key.ReadActorId );
682
+ }
683
+
684
+ for (auto it = ReadActorsInternalState.begin (); it != ReadActorsInternalState.end ();) {
685
+ if (!ReadActors.contains (it->first )) {
686
+ it = ReadActorsInternalState.erase (it);
687
+ } else {
688
+ ++it;
689
+ }
690
+ }
691
+
692
+ auto now = TInstant::Now ();
693
+ for (const auto & readActor: ReadActors) {
694
+ auto & internalStateInfo = ReadActorsInternalState[readActor];
695
+ if (now - internalStateInfo.RequestTime < TDuration::Seconds (30 )) {
696
+ continue ;
697
+ }
698
+ internalStateInfo.RequestTime = now;
699
+ Send (readActor, new NFq::TEvRowDispatcher::TEvGetInternalStateRequest{}, 0 , 0 );
700
+ }
701
+ }
702
+
659
703
void TRowDispatcher::Handle (NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev) {
660
704
LOG_ROW_DISPATCHER_DEBUG (" Received TEvStartSession from " << ev->Sender << " , topicPath " << ev->Get ()->Record .GetSource ().GetTopicPath () <<
661
705
" part id " << ev->Get ()->Record .GetPartitionId () << " query id " << ev->Get ()->Record .GetQueryId () << " cookie " << ev->Cookie );
@@ -916,11 +960,15 @@ void TRowDispatcher::PrintStateToLog() {
916
960
}
917
961
918
962
void TRowDispatcher::Handle (const NMon::TEvHttpInfo::TPtr& ev) {
963
+ UpdateReadActorsInternalState ();
919
964
TStringStream str;
920
965
HTML (str) {
921
966
PRE () {
967
+ str << " Current Time: " << TInstant::Now () << Endl;
922
968
str << " Current state:" << Endl;
923
969
str << GetInternalState () << Endl;
970
+ str << " Read actors state: " << Endl;
971
+ str << GetReadActorsInternalState () << Endl;
924
972
str << Endl;
925
973
}
926
974
}
@@ -954,6 +1002,12 @@ void TRowDispatcher::Handle(NFq::TEvRowDispatcher::TEvSessionStatistic::TPtr& ev
954
1002
}
955
1003
}
956
1004
1005
+ void TRowDispatcher::Handle (NFq::TEvRowDispatcher::TEvGetInternalStateResponse::TPtr& ev) {
1006
+ auto & readActorInternalState = ReadActorsInternalState[ev->Sender ];
1007
+ readActorInternalState.InternalState = ev->Get ()->Record .GetInternalState ();
1008
+ readActorInternalState.ResponseTime = TInstant::Now ();
1009
+ }
1010
+
957
1011
} // namespace
958
1012
959
1013
// //////////////////////////////////////////////////////////////////////////////
0 commit comments