Skip to content

Commit 9ad3631

Browse files
andrewstalinazevaykin
authored andcommitted
fixed the count-min request deletion error (#10427)
1 parent aa471d4 commit 9ad3631

File tree

1 file changed

+53
-75
lines changed

1 file changed

+53
-75
lines changed

ydb/core/statistics/service/service_impl.cpp

Lines changed: 53 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "service.h"
22
#include "http_request.h"
33

4+
#include <ydb/core/statistics/common.h>
45
#include <ydb/core/statistics/events.h>
56
#include <ydb/core/statistics/database/database.h>
67

@@ -103,8 +104,7 @@ struct TAggregationStatistics {
103104
? &Nodes[i] : nullptr;
104105
}
105106
}
106-
LOG_ERROR_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
107-
"Child node with the specified id was not found");
107+
SA_LOG_E("Child node with the specified id was not found");
108108
return nullptr;
109109
}
110110
};
@@ -211,15 +211,13 @@ class TStatService : public TActorBootstrapped<TStatService> {
211211
hFunc(NMon::TEvHttpInfoRes, Handle);
212212
cFunc(TEvents::TEvPoison::EventType, PassAway);
213213
default:
214-
LOG_CRIT_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
215-
"NStat::TStatService: unexpected event# " << ev->GetTypeRewrite() << " " << ev->ToString());
214+
SA_LOG_CRIT("NStat::TStatService: unexpected event# " << ev->GetTypeRewrite() << " " << ev->ToString());
216215
}
217216
}
218217

219218
private:
220219
void HandleConfig(NConsole::TEvConfigsDispatcher::TEvSetConfigSubscriptionResponse::TPtr&) {
221-
LOG_INFO_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
222-
"Subscribed for config changes on node " << SelfId().NodeId());
220+
SA_LOG_I("Subscribed for config changes on node " << SelfId().NodeId());
223221
}
224222

225223
void HandleConfig(NConsole::TEvConsole::TEvConfigNotificationRequest::TPtr& ev) {
@@ -239,8 +237,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
239237

240238
bool IsNotCurrentRound(ui64 round) {
241239
if (round != AggregationStatistics.Round) {
242-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
243-
"Event round " << round << " is different from the current " << AggregationStatistics.Round);
240+
SA_LOG_D("Event round " << round << " is different from the current " << AggregationStatistics.Round);
244241
return true;
245242
}
246243
return false;
@@ -305,8 +302,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
305302
const auto& record = ev->Get()->Record;
306303
const auto tabletId = record.GetShardTabletId();
307304

308-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
309-
"Received TEvStatisticsResponse TabletId: " << tabletId);
305+
SA_LOG_D("Received TEvStatisticsResponse TabletId: " << tabletId);
310306

311307
const auto round = ev->Cookie;
312308
if (IsNotCurrentRound(round)) {
@@ -334,8 +330,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
334330
const auto round = record.GetRound();
335331

336332
if (IsNotCurrentRound(round)) {
337-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
338-
"Skip TEvAggregateKeepAliveAck");
333+
SA_LOG_D("Skip TEvAggregateKeepAliveAck");
339334
return;
340335
}
341336

@@ -345,8 +340,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
345340
void Handle(TEvPrivate::TEvKeepAliveAckTimeout::TPtr& ev) {
346341
const auto round = ev->Get()->Round;
347342
if (IsNotCurrentRound(round)) {
348-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
349-
"Skip TEvKeepAliveAckTimeout");
343+
SA_LOG_D("Skip TEvKeepAliveAckTimeout");
350344
return;
351345
}
352346

@@ -361,8 +355,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
361355

362356
// the parent node is unavailable
363357
// invalidate the subtree with the root in the current node
364-
LOG_INFO_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
365-
"Parent node " << AggregationStatistics.ParentNode.NodeId() << " is unavailable");
358+
SA_LOG_I("Parent node " << AggregationStatistics.ParentNode.NodeId() << " is unavailable");
366359

367360

368361
ResetAggregationStatistics();
@@ -371,8 +364,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
371364
void Handle(TEvPrivate::TEvDispatchKeepAlive::TPtr& ev) {
372365
const auto round = ev->Get()->Round;
373366
if (IsNotCurrentRound(round)) {
374-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
375-
"Skip TEvDispatchKeepAlive");
367+
SA_LOG_D("Skip TEvDispatchKeepAlive");
376368
return;
377369
}
378370

@@ -386,17 +378,15 @@ class TStatService : public TActorBootstrapped<TStatService> {
386378
const auto round = ev->Get()->Round;
387379

388380
if (IsNotCurrentRound(round)) {
389-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
390-
"Skip TEvKeepAliveTimeout");
381+
SA_LOG_D("Skip TEvKeepAliveTimeout");
391382
return;
392383
}
393384

394385
const auto nodeId = ev->Get()->NodeId;
395386
auto node = AggregationStatistics.GetProcessingChildNode(nodeId);
396387

397388
if (node == nullptr) {
398-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
399-
"Skip TEvKeepAliveTimeout");
389+
SA_LOG_D("Skip TEvKeepAliveTimeout");
400390
return;
401391
}
402392

@@ -411,8 +401,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
411401

412402
node->Status = TAggregationStatistics::TNode::EStatus::Unavailable;
413403
++AggregationStatistics.PprocessedNodes;
414-
LOG_INFO_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
415-
"Node " << nodeId << " is unavailable");
404+
SA_LOG_I("Node " << nodeId << " is unavailable");
416405

417406
if (AggregationStatistics.IsCompleted()) {
418407
OnAggregateStatisticsFinished();
@@ -424,17 +413,15 @@ class TStatService : public TActorBootstrapped<TStatService> {
424413
const auto round = record.GetRound();
425414

426415
if (IsNotCurrentRound(round)) {
427-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
428-
"Skip TEvAggregateKeepAlive");
416+
SA_LOG_D("Skip TEvAggregateKeepAlive");
429417
return;
430418
}
431419

432420
const auto nodeId = ev->Sender.NodeId();
433421
auto node = AggregationStatistics.GetProcessingChildNode(nodeId);
434422

435423
if (node == nullptr) {
436-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
437-
"Skip TEvAggregateKeepAlive");
424+
SA_LOG_D( "Skip TEvAggregateKeepAlive");
438425
return;
439426
}
440427

@@ -446,24 +433,21 @@ class TStatService : public TActorBootstrapped<TStatService> {
446433
}
447434

448435
void Handle(TEvStatistics::TEvAggregateStatisticsResponse::TPtr& ev) {
449-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
450-
"Received TEvAggregateStatisticsResponse SenderNodeId: " << ev->Sender.NodeId());
436+
SA_LOG_D("Received TEvAggregateStatisticsResponse SenderNodeId: " << ev->Sender.NodeId());
451437

452438
const auto& record = ev->Get()->Record;
453439
const auto round = record.GetRound();
454440

455441
if (IsNotCurrentRound(round)) {
456-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
457-
"Skip TEvAggregateStatisticsResponse");
442+
SA_LOG_D("Skip TEvAggregateStatisticsResponse");
458443
return;
459444
}
460445

461446
const auto nodeId = ev->Sender.NodeId();
462447
auto node = AggregationStatistics.GetProcessingChildNode(nodeId);
463448

464449
if (node == nullptr) {
465-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
466-
"Skip TEvAggregateStatisticsResponse");
450+
SA_LOG_D("Skip TEvAggregateStatisticsResponse");
467451
return;
468452
}
469453

@@ -503,8 +487,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
503487
}
504488

505489
void SendAggregateStatisticsResponse() {
506-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
507-
"Send aggregate statistics response to node: " << AggregationStatistics.ParentNode.NodeId());
490+
SA_LOG_D("Send aggregate statistics response to node: " << AggregationStatistics.ParentNode.NodeId());
508491

509492
auto response = std::make_unique<TEvStatistics::TEvAggregateStatisticsResponse>();
510493
auto& record = response->Record;
@@ -589,8 +572,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
589572
const auto& record = ev->Get()->Record;
590573
const auto round = record.GetRound();
591574

592-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
593-
"Received TEvAggregateStatistics from node: " << ev->Sender.NodeId()
575+
SA_LOG_D("Received TEvAggregateStatistics from node: " << ev->Sender.NodeId()
594576
<< ", Round: " << round << ", current Round: " << AggregationStatistics.Round);
595577

596578
// reset previous state
@@ -669,8 +651,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
669651
return;
670652
}
671653

672-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
673-
"Handle TEvStatistics::TEvGetStatistics, request id = " << requestId
654+
SA_LOG_D("Handle TEvStatistics::TEvGetStatistics, request id = " << requestId
674655
<< ", ReplyToActorId = " << request.ReplyToActorId
675656
<< ", StatRequests.size() = " << request.StatRequests.size());
676657

@@ -714,8 +695,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
714695

715696
auto cookie = navigate->Cookie;
716697

717-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
718-
"Handle TEvTxProxySchemeCache::TEvNavigateKeySetResult, request id = " << cookie);
698+
SA_LOG_D("Handle TEvTxProxySchemeCache::TEvNavigateKeySetResult, request id = " << cookie);
719699

720700
if (cookie == ResolveSACookie) {
721701
Y_ABORT_UNLESS(navigate->ResultSet.size() == 1);
@@ -731,7 +711,14 @@ class TStatService : public TActorBootstrapped<TStatService> {
731711
ConnectToSA();
732712
SyncNode();
733713
} else {
734-
ReplyAllFailed();
714+
for (auto it = InFlight.begin(); it != InFlight.end();) {
715+
if (EStatType::COUNT_MIN_SKETCH == it->second.StatType) {
716+
++it;
717+
continue;
718+
}
719+
ReplyFailed(it->first, false);
720+
it = InFlight.erase(it);
721+
}
735722
}
736723
return;
737724
}
@@ -837,8 +824,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
837824
}
838825

839826
void Handle(TEvStatistics::TEvPropagateStatistics::TPtr& ev) {
840-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
841-
"EvPropagateStatistics, node id = " << SelfId().NodeId());
827+
SA_LOG_D("EvPropagateStatistics, node id = " << SelfId().NodeId());
842828

843829
Send(ev->Sender, new TEvStatistics::TEvPropagateStatisticsResponse);
844830

@@ -922,21 +908,18 @@ class TStatService : public TActorBootstrapped<TStatService> {
922908
void Handle(TEvPrivate::TEvStatisticsRequestTimeout::TPtr& ev) {
923909
const auto round = ev->Get()->Round;
924910
if (IsNotCurrentRound(round)) {
925-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
926-
"Skip TEvStatisticsRequestTimeout");
911+
SA_LOG_D("Skip TEvStatisticsRequestTimeout");
927912
return;
928913
}
929914

930915
const auto tabletId = ev->Get()->TabletId;
931916
auto tabletPipe = AggregationStatistics.LocalTablets.TabletsPipes.find(tabletId);
932917
if (tabletPipe == AggregationStatistics.LocalTablets.TabletsPipes.end()) {
933-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
934-
"Tablet " << tabletId << " has already been processed");
918+
SA_LOG_D("Tablet " << tabletId << " has already been processed");
935919
return;
936920
}
937921

938-
LOG_ERROR_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
939-
"No result was received from the tablet " << tabletId);
922+
SA_LOG_E("No result was received from the tablet " << tabletId);
940923

941924
auto clientId = tabletPipe->second;
942925
OnTabletError(tabletId);
@@ -961,15 +944,13 @@ class TStatService : public TActorBootstrapped<TStatService> {
961944
NTabletPipe::SendData(SelfId(), clientId, request.release(), round);
962945
Schedule(Settings.StatisticsRequestTimeout, new TEvPrivate::TEvStatisticsRequestTimeout(round, tabletId));
963946

964-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
965-
"TEvStatisticsRequest send"
947+
SA_LOG_D("TEvStatisticsRequest send"
966948
<< ", client id = " << clientId
967949
<< ", path = " << *path);
968950
}
969951

970952
void OnTabletError(ui64 tabletId) {
971-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
972-
"Tablet " << tabletId << " is not local.");
953+
SA_LOG_D("Tablet " << tabletId << " is not local.");
973954

974955
const auto error = NKikimrStat::TEvAggregateStatisticsResponse::TYPE_NON_LOCAL_TABLET;
975956
AggregationStatistics.FailedTablets.emplace_back(tabletId, 0, error);
@@ -987,8 +968,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
987968
const auto& clientId = ev->Get()->ClientId;
988969
const auto& tabletId = ev->Get()->TabletId;
989970

990-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
991-
"EvClientConnected"
971+
SA_LOG_D("EvClientConnected"
992972
<< ", node id = " << ev->Get()->ClientId.NodeId()
993973
<< ", client id = " << clientId
994974
<< ", server id = " << ev->Get()->ServerId
@@ -1017,16 +997,14 @@ class TStatService : public TActorBootstrapped<TStatService> {
1017997
return;
1018998
}
1019999

1020-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1021-
"Skip EvClientConnected");
1000+
SA_LOG_D("Skip EvClientConnected");
10221001
}
10231002

10241003
void Handle(TEvTabletPipe::TEvClientDestroyed::TPtr& ev) {
10251004
const auto& clientId = ev->Get()->ClientId;
10261005
const auto& tabletId = ev->Get()->TabletId;
10271006

1028-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1029-
"EvClientDestroyed"
1007+
SA_LOG_D("EvClientDestroyed"
10301008
<< ", node id = " << ev->Get()->ClientId.NodeId()
10311009
<< ", client id = " << clientId
10321010
<< ", server id = " << ev->Get()->ServerId
@@ -1048,8 +1026,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
10481026
return;
10491027
}
10501028

1051-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1052-
"Skip EvClientDestroyed");
1029+
SA_LOG_D("Skip EvClientDestroyed");
10531030
}
10541031

10551032
void Handle(TEvStatistics::TEvStatisticsIsDisabled::TPtr&) {
@@ -1059,13 +1036,19 @@ class TStatService : public TActorBootstrapped<TStatService> {
10591036

10601037
void Handle(TEvStatistics::TEvLoadStatisticsQueryResponse::TPtr& ev) {
10611038
ui64 cookie = ev->Get()->Cookie;
1062-
10631039
auto itLoadQuery = LoadQueriesInFlight.find(cookie);
10641040
Y_ABORT_UNLESS(itLoadQuery != LoadQueriesInFlight.end());
10651041
auto [requestId, requestIndex] = itLoadQuery->second;
10661042

1043+
SA_LOG_D("TEvLoadStatisticsQueryResponse, request id = " << requestId);
1044+
10671045
auto itRequest = InFlight.find(requestId);
1068-
Y_ABORT_UNLESS(itRequest != InFlight.end());
1046+
if (InFlight.end() == itRequest) {
1047+
SA_LOG_E("TEvLoadStatisticsQueryResponse, request id = " << requestId
1048+
<< ". Request not found in InFlight");
1049+
return;
1050+
}
1051+
10691052
auto& request = itRequest->second;
10701053

10711054
auto& response = request.StatResponses[requestIndex];
@@ -1092,8 +1075,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
10921075
}
10931076

10941077
void Handle(TEvPrivate::TEvRequestTimeout::TPtr& ev) {
1095-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1096-
"EvRequestTimeout"
1078+
SA_LOG_D("EvRequestTimeout"
10971079
<< ", pipe client id = " << ev->Get()->PipeClientId
10981080
<< ", schemeshard count = " << ev->Get()->NeedSchemeShards.size());
10991081

@@ -1125,8 +1107,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
11251107
NTabletPipe::TClientConfig pipeConfig{policy};
11261108
SAPipeClientId = Register(NTabletPipe::CreateClient(SelfId(), StatisticsAggregatorId, pipeConfig));
11271109

1128-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1129-
"ConnectToSA(), pipe client id = " << SAPipeClientId);
1110+
SA_LOG_D("ConnectToSA(), pipe client id = " << SAPipeClientId);
11301111
}
11311112

11321113
void SyncNode() {
@@ -1155,8 +1136,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
11551136
Schedule(RequestTimeout, timeout.release());
11561137
}
11571138

1158-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1159-
"SyncNode(), pipe client id = " << SAPipeClientId);
1139+
SA_LOG_D("SyncNode(), pipe client id = " << SAPipeClientId);
11601140
}
11611141

11621142
void ReplySuccess(ui64 requestId, bool eraseRequest) {
@@ -1166,8 +1146,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
11661146
}
11671147
auto& request = itRequest->second;
11681148

1169-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1170-
"ReplySuccess(), request id = " << requestId
1149+
SA_LOG_D("ReplySuccess(), request id = " << requestId
11711150
<< ", ReplyToActorId = " << request.ReplyToActorId
11721151
<< ", StatRequests.size() = " << request.StatRequests.size());
11731152

@@ -1213,8 +1192,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
12131192
}
12141193
auto& request = itRequest->second;
12151194

1216-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1217-
"ReplyFailed(), request id = " << requestId);
1195+
SA_LOG_D("ReplyFailed(), request id = " << requestId);
12181196

12191197
auto result = std::make_unique<TEvStatistics::TEvGetStatisticsResult>();
12201198
result->Success = false;

0 commit comments

Comments
 (0)