Skip to content

Commit da0e694

Browse files
authored
fixed the count-min request deletion error (#10427)
1 parent b390c9d commit da0e694

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

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

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

226224
void HandleConfig(NConsole::TEvConsole::TEvConfigNotificationRequest::TPtr& ev) {
@@ -240,8 +238,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
240238

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

309-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
310-
"Received TEvStatisticsResponse TabletId: " << tabletId);
306+
SA_LOG_D("Received TEvStatisticsResponse TabletId: " << tabletId);
311307

312308
const auto round = ev->Cookie;
313309
if (IsNotCurrentRound(round)) {
@@ -335,8 +331,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
335331
const auto round = record.GetRound();
336332

337333
if (IsNotCurrentRound(round)) {
338-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
339-
"Skip TEvAggregateKeepAliveAck");
334+
SA_LOG_D("Skip TEvAggregateKeepAliveAck");
340335
return;
341336
}
342337

@@ -346,8 +341,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
346341
void Handle(TEvPrivate::TEvKeepAliveAckTimeout::TPtr& ev) {
347342
const auto round = ev->Get()->Round;
348343
if (IsNotCurrentRound(round)) {
349-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
350-
"Skip TEvKeepAliveAckTimeout");
344+
SA_LOG_D("Skip TEvKeepAliveAckTimeout");
351345
return;
352346
}
353347

@@ -362,8 +356,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
362356

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

368361

369362
ResetAggregationStatistics();
@@ -372,8 +365,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
372365
void Handle(TEvPrivate::TEvDispatchKeepAlive::TPtr& ev) {
373366
const auto round = ev->Get()->Round;
374367
if (IsNotCurrentRound(round)) {
375-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
376-
"Skip TEvDispatchKeepAlive");
368+
SA_LOG_D("Skip TEvDispatchKeepAlive");
377369
return;
378370
}
379371

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

389381
if (IsNotCurrentRound(round)) {
390-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
391-
"Skip TEvKeepAliveTimeout");
382+
SA_LOG_D("Skip TEvKeepAliveTimeout");
392383
return;
393384
}
394385

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

398389
if (node == nullptr) {
399-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
400-
"Skip TEvKeepAliveTimeout");
390+
SA_LOG_D("Skip TEvKeepAliveTimeout");
401391
return;
402392
}
403393

@@ -412,8 +402,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
412402

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

418407
if (AggregationStatistics.IsCompleted()) {
419408
OnAggregateStatisticsFinished();
@@ -425,17 +414,15 @@ class TStatService : public TActorBootstrapped<TStatService> {
425414
const auto round = record.GetRound();
426415

427416
if (IsNotCurrentRound(round)) {
428-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
429-
"Skip TEvAggregateKeepAlive");
417+
SA_LOG_D("Skip TEvAggregateKeepAlive");
430418
return;
431419
}
432420

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

436424
if (node == nullptr) {
437-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
438-
"Skip TEvAggregateKeepAlive");
425+
SA_LOG_D( "Skip TEvAggregateKeepAlive");
439426
return;
440427
}
441428

@@ -447,24 +434,21 @@ class TStatService : public TActorBootstrapped<TStatService> {
447434
}
448435

449436
void Handle(TEvStatistics::TEvAggregateStatisticsResponse::TPtr& ev) {
450-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
451-
"Received TEvAggregateStatisticsResponse SenderNodeId: " << ev->Sender.NodeId());
437+
SA_LOG_D("Received TEvAggregateStatisticsResponse SenderNodeId: " << ev->Sender.NodeId());
452438

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

456442
if (IsNotCurrentRound(round)) {
457-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
458-
"Skip TEvAggregateStatisticsResponse");
443+
SA_LOG_D("Skip TEvAggregateStatisticsResponse");
459444
return;
460445
}
461446

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

465450
if (node == nullptr) {
466-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
467-
"Skip TEvAggregateStatisticsResponse");
451+
SA_LOG_D("Skip TEvAggregateStatisticsResponse");
468452
return;
469453
}
470454

@@ -504,8 +488,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
504488
}
505489

506490
void SendAggregateStatisticsResponse() {
507-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
508-
"Send aggregate statistics response to node: " << AggregationStatistics.ParentNode.NodeId());
491+
SA_LOG_D("Send aggregate statistics response to node: " << AggregationStatistics.ParentNode.NodeId());
509492

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

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

597579
// reset previous state
@@ -670,8 +652,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
670652
return;
671653
}
672654

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

@@ -715,8 +696,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
715696

716697
auto cookie = navigate->Cookie;
717698

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

721701
if (cookie == ResolveSACookie) {
722702
Y_ABORT_UNLESS(navigate->ResultSet.size() == 1);
@@ -732,7 +712,14 @@ class TStatService : public TActorBootstrapped<TStatService> {
732712
ConnectToSA();
733713
SyncNode();
734714
} else {
735-
ReplyAllFailed();
715+
for (auto it = InFlight.begin(); it != InFlight.end();) {
716+
if (EStatType::COUNT_MIN_SKETCH == it->second.StatType) {
717+
++it;
718+
continue;
719+
}
720+
ReplyFailed(it->first, false);
721+
it = InFlight.erase(it);
722+
}
736723
}
737724
return;
738725
}
@@ -838,8 +825,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
838825
}
839826

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

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

@@ -923,21 +909,18 @@ class TStatService : public TActorBootstrapped<TStatService> {
923909
void Handle(TEvPrivate::TEvStatisticsRequestTimeout::TPtr& ev) {
924910
const auto round = ev->Get()->Round;
925911
if (IsNotCurrentRound(round)) {
926-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
927-
"Skip TEvStatisticsRequestTimeout");
912+
SA_LOG_D("Skip TEvStatisticsRequestTimeout");
928913
return;
929914
}
930915

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

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

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

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

971953
void OnTabletError(ui64 tabletId) {
972-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
973-
"Tablet " << tabletId << " is not local.");
954+
SA_LOG_D("Tablet " << tabletId << " is not local.");
974955

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

991-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
992-
"EvClientConnected"
972+
SA_LOG_D("EvClientConnected"
993973
<< ", node id = " << ev->Get()->ClientId.NodeId()
994974
<< ", client id = " << clientId
995975
<< ", server id = " << ev->Get()->ServerId
@@ -1018,16 +998,14 @@ class TStatService : public TActorBootstrapped<TStatService> {
1018998
return;
1019999
}
10201000

1021-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1022-
"Skip EvClientConnected");
1001+
SA_LOG_D("Skip EvClientConnected");
10231002
}
10241003

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

1029-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1030-
"EvClientDestroyed"
1008+
SA_LOG_D("EvClientDestroyed"
10311009
<< ", node id = " << ev->Get()->ClientId.NodeId()
10321010
<< ", client id = " << clientId
10331011
<< ", server id = " << ev->Get()->ServerId
@@ -1049,8 +1027,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
10491027
return;
10501028
}
10511029

1052-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1053-
"Skip EvClientDestroyed");
1030+
SA_LOG_D("Skip EvClientDestroyed");
10541031
}
10551032

10561033
void Handle(TEvStatistics::TEvStatisticsIsDisabled::TPtr&) {
@@ -1060,13 +1037,19 @@ class TStatService : public TActorBootstrapped<TStatService> {
10601037

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

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

10721055
auto& response = request.StatResponses[requestIndex];
@@ -1093,8 +1076,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
10931076
}
10941077

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

@@ -1126,8 +1108,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
11261108
NTabletPipe::TClientConfig pipeConfig{.RetryPolicy = policy};
11271109
SAPipeClientId = Register(NTabletPipe::CreateClient(SelfId(), StatisticsAggregatorId, pipeConfig));
11281110

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

11331114
void SyncNode() {
@@ -1156,8 +1137,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
11561137
Schedule(RequestTimeout, timeout.release());
11571138
}
11581139

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

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

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

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

1217-
LOG_DEBUG_S(TlsActivationContext->AsActorContext(), NKikimrServices::STATISTICS,
1218-
"ReplyFailed(), request id = " << requestId);
1196+
SA_LOG_D("ReplyFailed(), request id = " << requestId);
12191197

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

0 commit comments

Comments
 (0)