@@ -43,6 +43,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
43
43
hFunc (TEvStatistics::TEvPropagateStatistics, Handle );
44
44
hFunc (TEvTabletPipe::TEvClientConnected, Handle );
45
45
hFunc (TEvTabletPipe::TEvClientDestroyed, Handle );
46
+ hFunc (TEvStatistics::TEvStatisticsIsDisabled, Handle );
46
47
cFunc (TEvents::TEvPoison::EventType, PassAway);
47
48
default :
48
49
LOG_CRIT_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
@@ -51,20 +52,21 @@ class TStatService : public TActorBootstrapped<TStatService> {
51
52
}
52
53
53
54
private:
54
- bool IsSAUnavailable () {
55
- return ResolveSAStage == RSA_FINISHED && StatisticsAggregatorId == 0 ;
56
- }
57
-
58
55
void HandleConfig (NConsole::TEvConfigsDispatcher::TEvSetConfigSubscriptionResponse::TPtr&) {
59
56
LOG_INFO_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
60
- " Subscribed for config changes" );
57
+ " Subscribed for config changes on node " << SelfId (). NodeId () );
61
58
}
62
59
63
60
void HandleConfig (NConsole::TEvConsole::TEvConfigNotificationRequest::TPtr& ev) {
64
61
const auto & record = ev->Get ()->Record ;
65
- const auto & featureFlags = record.GetConfig ().GetFeatureFlags ();
66
- EnableStatistics = featureFlags.GetEnableStatistics ();
67
-
62
+ const auto & config = record.GetConfig ();
63
+ if (config.HasFeatureFlags ()) {
64
+ const auto & featureFlags = config.GetFeatureFlags ();
65
+ EnableStatistics = featureFlags.GetEnableStatistics ();
66
+ if (!EnableStatistics) {
67
+ ReplyAllFailed ();
68
+ }
69
+ }
68
70
auto response = std::make_unique<NConsole::TEvConsole::TEvConfigNotificationResponse>(record);
69
71
Send (ev->Sender , response.release (), 0 , ev->Cookie );
70
72
}
@@ -77,7 +79,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
77
79
request.EvCookie = ev->Cookie ;
78
80
request.StatRequests .swap (ev->Get ()->StatRequests );
79
81
80
- if (!EnableStatistics || IsSAUnavailable () ) {
82
+ if (!EnableStatistics) {
81
83
ReplyFailed (requestId, true );
82
84
return ;
83
85
}
@@ -106,12 +108,12 @@ class TStatService : public TActorBootstrapped<TStatService> {
106
108
auto & entry = navigate->ResultSet .back ();
107
109
if (entry.Status != TNavigate::EStatus::Ok) {
108
110
StatisticsAggregatorId = 0 ;
109
- } else {
111
+ } else if (entry. DomainInfo -> Params . HasStatisticsAggregator ()) {
110
112
StatisticsAggregatorId = entry.DomainInfo ->Params .GetStatisticsAggregator ();
111
113
}
112
- ResolveSAStage = RSA_FINISHED;
114
+ ResolveSAStage = StatisticsAggregatorId ? RSA_FINISHED : RSA_INITIAL ;
113
115
114
- if (StatisticsAggregatorId != 0 ) {
116
+ if (StatisticsAggregatorId) {
115
117
ConnectToSA ();
116
118
SyncNode ();
117
119
} else {
@@ -127,15 +129,15 @@ class TStatService : public TActorBootstrapped<TStatService> {
127
129
}
128
130
auto & request = itRequest->second ;
129
131
130
- if (!EnableStatistics || IsSAUnavailable () ) {
132
+ if (!EnableStatistics) {
131
133
ReplyFailed (requestId, true );
132
134
return ;
133
135
}
134
136
135
137
std::unordered_set<ui64> ssIds;
136
138
bool isServerless = false ;
137
139
ui64 aggregatorId = 0 ;
138
- TPathId resourcesDomainKey;
140
+ TPathId domainKey, resourcesDomainKey;
139
141
for (const auto & entry : navigate->ResultSet ) {
140
142
if (entry.Status != TNavigate::EStatus::Ok) {
141
143
continue ;
@@ -144,6 +146,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
144
146
ssIds.insert (domainInfo->ExtractSchemeShard ());
145
147
aggregatorId = domainInfo->Params .GetStatisticsAggregator ();
146
148
isServerless = domainInfo->IsServerless ();
149
+ domainKey = domainInfo->DomainKey ;
147
150
resourcesDomainKey = domainInfo->ResourcesDomainKey ;
148
151
}
149
152
if (ssIds.size () != 1 ) {
@@ -157,22 +160,31 @@ class TStatService : public TActorBootstrapped<TStatService> {
157
160
return ;
158
161
}
159
162
163
+ auto navigateDomainKey = [this ] (TPathId domainKey) {
164
+ using TNavigate = NSchemeCache::TSchemeCacheNavigate;
165
+ auto navigate = std::make_unique<TNavigate>();
166
+ auto & entry = navigate->ResultSet .emplace_back ();
167
+ entry.TableId = TTableId (domainKey.OwnerId , domainKey.LocalPathId );
168
+ entry.Operation = TNavigate::EOp::OpPath;
169
+ entry.RequestType = TNavigate::TEntry::ERequestType::ByTableId;
170
+ entry.RedirectRequired = false ;
171
+ navigate->Cookie = ResolveSACookie;
172
+ Send (MakeSchemeCacheID (), new TEvTxProxySchemeCache::TEvNavigateKeySet (navigate.release ()));
173
+ ResolveSAStage = RSA_IN_FLIGHT;
174
+ };
175
+
160
176
switch (ResolveSAStage) {
161
- case RSA_NOT_RUN :
177
+ case RSA_INITIAL :
162
178
if (!isServerless) {
163
- StatisticsAggregatorId = aggregatorId;
164
- ResolveSAStage = RSA_FINISHED;
179
+ if (aggregatorId) {
180
+ StatisticsAggregatorId = aggregatorId;
181
+ ResolveSAStage = RSA_FINISHED;
182
+ } else {
183
+ navigateDomainKey (domainKey);
184
+ return ;
185
+ }
165
186
} else {
166
- using TNavigate = NSchemeCache::TSchemeCacheNavigate;
167
- auto navigate = std::make_unique<TNavigate>();
168
- auto & entry = navigate->ResultSet .emplace_back ();
169
- entry.TableId = TTableId (resourcesDomainKey.OwnerId , resourcesDomainKey.LocalPathId );
170
- entry.Operation = TNavigate::EOp::OpPath;
171
- entry.RequestType = TNavigate::TEntry::ERequestType::ByTableId;
172
- entry.RedirectRequired = false ;
173
- navigate->Cookie = ResolveSACookie;
174
- Send (MakeSchemeCacheID (), new TEvTxProxySchemeCache::TEvNavigateKeySet (navigate.release ()));
175
- ResolveSAStage = RSA_IN_FLIGHT;
187
+ navigateDomainKey (resourcesDomainKey);
176
188
return ;
177
189
}
178
190
break ;
@@ -182,7 +194,7 @@ class TStatService : public TActorBootstrapped<TStatService> {
182
194
break ;
183
195
}
184
196
185
- if (IsSAUnavailable () ) {
197
+ if (!StatisticsAggregatorId ) {
186
198
ReplyFailed (requestId, true );
187
199
return ;
188
200
}
@@ -303,6 +315,10 @@ class TStatService : public TActorBootstrapped<TStatService> {
303
315
SyncNode ();
304
316
}
305
317
318
+ void Handle (TEvStatistics::TEvStatisticsIsDisabled::TPtr&) {
319
+ ReplyAllFailed ();
320
+ }
321
+
306
322
void ConnectToSA () {
307
323
if (SAPipeClientId || !StatisticsAggregatorId) {
308
324
return ;
@@ -465,11 +481,11 @@ class TStatService : public TActorBootstrapped<TStatService> {
465
481
466
482
static const ui64 ResolveSACookie = std::numeric_limits<ui64>::max();
467
483
enum EResolveSAStage {
468
- RSA_NOT_RUN ,
484
+ RSA_INITIAL ,
469
485
RSA_IN_FLIGHT,
470
486
RSA_FINISHED
471
487
};
472
- EResolveSAStage ResolveSAStage = RSA_NOT_RUN ;
488
+ EResolveSAStage ResolveSAStage = RSA_INITIAL ;
473
489
};
474
490
475
491
THolder<IActor> CreateStatService () {
0 commit comments