25
25
namespace NKikimr {
26
26
namespace NStat {
27
27
28
-
29
28
struct TAggregationStatistics {
30
29
using TColumnsStatistics = ::google::protobuf::RepeatedPtrField<::NKikimrStat::TColumnStatistics>;
31
30
@@ -128,6 +127,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
128
127
EvDispatchKeepAlive,
129
128
EvKeepAliveTimeout,
130
129
EvKeepAliveAckTimeout,
130
+ EvStatisticsRequestTimeout,
131
131
132
132
EvEnd
133
133
};
@@ -155,6 +155,13 @@ class TStatService : public TActorBootstrapped<TStatService> {
155
155
ui64 Round;
156
156
ui32 NodeId;
157
157
};
158
+
159
+ struct TEvStatisticsRequestTimeout : public NActors ::TEventLocal<TEvStatisticsRequestTimeout, EvStatisticsRequestTimeout> {
160
+ TEvStatisticsRequestTimeout (ui64 round, ui64 tabletId): Round(round), TabletId(tabletId) {}
161
+
162
+ ui64 Round;
163
+ ui64 TabletId;
164
+ };
158
165
};
159
166
160
167
void Bootstrap () {
@@ -195,6 +202,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
195
202
hFunc (TEvStatistics::TEvAggregateKeepAlive, Handle );
196
203
hFunc (TEvPrivate::TEvDispatchKeepAlive, Handle );
197
204
hFunc (TEvPrivate::TEvKeepAliveTimeout, Handle );
205
+ hFunc (TEvPrivate::TEvStatisticsRequestTimeout, Handle );
198
206
hFunc (TEvStatistics::TEvStatisticsResponse, Handle );
199
207
hFunc (TEvStatistics::TEvAggregateStatisticsResponse, Handle );
200
208
@@ -902,7 +910,31 @@ class TStatService : public TActorBootstrapped<TStatService> {
902
910
}
903
911
}
904
912
905
- void SendStatisticsRequest (const TActorId& clientId) {
913
+ void Handle (TEvPrivate::TEvStatisticsRequestTimeout::TPtr& ev) {
914
+ const auto round = ev->Get ()->Round ;
915
+ if (IsNotCurrentRound (round )) {
916
+ LOG_DEBUG_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
917
+ " Skip TEvStatisticsRequestTimeout" );
918
+ return ;
919
+ }
920
+
921
+ const auto tabletId = ev->Get ()->TabletId ;
922
+ auto tabletPipe = AggregationStatistics.LocalTablets .TabletsPipes .find (tabletId);
923
+ if (tabletPipe == AggregationStatistics.LocalTablets .TabletsPipes .end ()) {
924
+ LOG_DEBUG_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
925
+ " Tablet " << tabletId << " has already been processed" );
926
+ return ;
927
+ }
928
+
929
+ LOG_ERROR_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
930
+ " No result was received from the tablet " << tabletId);
931
+
932
+ auto clientId = tabletPipe->second ;
933
+ OnTabletError (tabletId);
934
+ NTabletPipe::CloseClient (SelfId (), clientId);
935
+ }
936
+
937
+ void SendStatisticsRequest (const TActorId& clientId, ui64 tabletId) {
906
938
auto request = std::make_unique<TEvStatistics::TEvStatisticsRequest>();
907
939
auto & record = request->Record ;
908
940
record.MutableTypes ()->Add (NKikimrStat::TYPE_COUNT_MIN_SKETCH);
@@ -916,7 +948,9 @@ class TStatService : public TActorBootstrapped<TStatService> {
916
948
columnTags->Add (tag);
917
949
}
918
950
919
- NTabletPipe::SendData (SelfId (), clientId, request.release (), AggregationStatistics.Round );
951
+ const auto round = AggregationStatistics.Round ;
952
+ NTabletPipe::SendData (SelfId (), clientId, request.release (), round );
953
+ Schedule (Settings.StatisticsRequestTimeout , new TEvPrivate::TEvStatisticsRequestTimeout (round , tabletId));
920
954
921
955
LOG_DEBUG_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
922
956
" TEvStatisticsRequest send"
@@ -928,7 +962,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
928
962
LOG_DEBUG_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
929
963
" Tablet " << tabletId << " is not local." );
930
964
931
- constexpr auto error = NKikimrStat::TEvAggregateStatisticsResponse::TYPE_NON_LOCAL_TABLET;
965
+ const auto error = NKikimrStat::TEvAggregateStatisticsResponse::TYPE_NON_LOCAL_TABLET;
932
966
AggregationStatistics.FailedTablets .emplace_back (tabletId, 0 , error);
933
967
934
968
AggregationStatistics.LocalTablets .TabletsPipes .erase (tabletId);
@@ -966,7 +1000,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
966
1000
967
1001
if (tabletPipe != tabletsPipes.end () && clientId == tabletPipe->second ) {
968
1002
if (ev->Get ()->Status == NKikimrProto::OK) {
969
- SendStatisticsRequest (clientId);
1003
+ SendStatisticsRequest (clientId, tabletId );
970
1004
} else {
971
1005
OnTabletError (tabletId);
972
1006
}
0 commit comments