Skip to content

Commit 062c51a

Browse files
committed
fix tablets filters (#17157)
1 parent e2e900a commit 062c51a

File tree

6 files changed

+43
-8
lines changed

6 files changed

+43
-8
lines changed

ydb/core/mind/hive/hive_impl.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2065,9 +2065,18 @@ void THive::Handle(TEvHive::TEvRequestHiveNodeStats::TPtr& ev) {
20652065
}
20662066
}
20672067
} else {
2068+
std::optional<TSubDomainKey> filterObjectDomain;
2069+
if (request.HasFilterTabletsByObjectDomain()) {
2070+
filterObjectDomain = TSubDomainKey(request.GetFilterTabletsByObjectDomain());
2071+
}
20682072
for (const auto& [state, set] : node.Tablets) {
20692073
std::vector<ui32> tabletTypeToCount;
20702074
for (const TTabletInfo* tablet : set) {
2075+
if (filterObjectDomain) {
2076+
if (tablet->NodeFilter.ObjectDomain != *filterObjectDomain) {
2077+
continue;
2078+
}
2079+
}
20712080
TTabletTypes::EType type = tablet->GetTabletType();
20722081
if (static_cast<size_t>(type) >= tabletTypeToCount.size()) {
20732082
tabletTypeToCount.resize(type + 1);
@@ -3523,7 +3532,7 @@ void THive::Handle(TEvPrivate::TEvUpdateFollowers::TPtr&) {
35233532

35243533
void THive::MakeScaleRecommendation() {
35253534
BLOG_D("[MSR] Started");
3526-
3535+
35273536
if (AreWeRootHive()) {
35283537
return;
35293538
}

ydb/core/protos/hive.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ message TEvRequestHiveNodeStats {
323323
// The next 2 fields should always be used together
324324
optional uint64 FilterTabletsByPathId = 7;
325325
optional uint64 FilterTabletsBySchemeShardId = 8;
326+
optional NKikimrSubDomains.TDomainKey FilterTabletsByObjectDomain = 9;
326327
}
327328

328329
message THiveNodeStats {
@@ -616,7 +617,7 @@ message TScaleRecommenderPolicies {
616617
message TScaleRecommenderPolicy {
617618
message TTargetTrackingPolicy {
618619
oneof Target {
619-
uint32 AverageCpuUtilizationPercent = 1;
620+
uint32 AverageCpuUtilizationPercent = 1;
620621
}
621622
}
622623

ydb/core/viewer/json_pipe_req.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,16 @@ TViewerPipeClient::TRequestResponse<TEvHive::TEvResponseHiveNodeStats> TViewerPi
451451
TActorId pipeClient = ConnectTabletPipe(hiveId);
452452
auto response = MakeRequestToPipe<TEvHive::TEvResponseHiveNodeStats>(pipeClient, request, hiveId);
453453
if (response.Span) {
454-
auto hive_id = "#" + ::ToString(hiveId);
455-
response.Span.Attribute("hive_id", hive_id);
454+
response.Span.Attribute("hive_id", TStringBuilder() << '#' << hiveId);
455+
if (request->Record.GetFilterTabletsBySchemeShardId()) {
456+
response.Span.Attribute("schemeshard_id", TStringBuilder() << '#' << request->Record.GetFilterTabletsBySchemeShardId());
457+
}
458+
if (request->Record.GetFilterTabletsByPathId()) {
459+
response.Span.Attribute("path_id", TStringBuilder() << '#' << request->Record.GetFilterTabletsByPathId());
460+
}
461+
if (request->Record.HasFilterTabletsByObjectDomain()) {
462+
response.Span.Attribute("object_domain", TStringBuilder() << TSubDomainKey(request->Record.GetFilterTabletsByObjectDomain()));
463+
}
456464
}
457465
return response;
458466
}
@@ -737,6 +745,7 @@ THolder<NSchemeCache::TSchemeCacheNavigate> TViewerPipeClient::SchemeCacheNaviga
737745
) {
738746
THolder<NSchemeCache::TSchemeCacheNavigate> request = MakeHolder<NSchemeCache::TSchemeCacheNavigate>();
739747
entry.RedirectRequired = false;
748+
entry.ShowPrivatePath = true;
740749
entry.Operation = NSchemeCache::TSchemeCacheNavigate::EOp::OpPath;
741750
request->ResultSet.emplace_back(std::move(entry));
742751
return request;
@@ -763,6 +772,7 @@ TViewerPipeClient::TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResu
763772
NSchemeCache::TSchemeCacheNavigate::TEntry entry;
764773
entry.Path = SplitPath(path);
765774
entry.RedirectRequired = false;
775+
entry.ShowPrivatePath = true;
766776
entry.Operation = NSchemeCache::TSchemeCacheNavigate::EOp::OpPath;
767777
request->ResultSet.emplace_back(entry);
768778
auto response = MakeRequest<TEvTxProxySchemeCache::TEvNavigateKeySetResult>(MakeSchemeCacheID(), new TEvTxProxySchemeCache::TEvNavigateKeySet(request.Release()), 0 /*flags*/, cookie);
@@ -778,6 +788,7 @@ TViewerPipeClient::TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResu
778788
entry.TableId.PathId = pathId;
779789
entry.RequestType = NSchemeCache::TSchemeCacheNavigate::TEntry::ERequestType::ByTableId;
780790
entry.RedirectRequired = false;
791+
entry.ShowPrivatePath = true;
781792
entry.Operation = NSchemeCache::TSchemeCacheNavigate::EOp::OpPath;
782793
request->ResultSet.emplace_back(entry);
783794
auto response = MakeRequest<TEvTxProxySchemeCache::TEvNavigateKeySetResult>(MakeSchemeCacheID(), new TEvTxProxySchemeCache::TEvNavigateKeySet(request.Release()), 0 /*flags*/, cookie);
@@ -823,9 +834,10 @@ TViewerPipeClient::TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResu
823834
return response;
824835
}
825836

826-
void TViewerPipeClient::RequestTxProxyDescribe(const TString& path) {
837+
void TViewerPipeClient::RequestTxProxyDescribe(const TString& path, const NKikimrSchemeOp::TDescribeOptions& options) {
827838
THolder<TEvTxUserProxy::TEvNavigate> request(new TEvTxUserProxy::TEvNavigate());
828839
request->Record.MutableDescribePath()->SetPath(path);
840+
request->Record.MutableDescribePath()->MutableOptions()->CopyFrom(options);
829841
if (Event && !Event->Get()->UserToken.empty()) {
830842
request->Record.SetUserToken(Event->Get()->UserToken);
831843
}

ydb/core/viewer/json_pipe_req.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class TViewerPipeClient : public TActorBootstrapped<TViewerPipeClient> {
318318
const TString& path, bool showPrivate, ui32 access, ui64 cookie = 0);
319319

320320
TRequestResponse<TEvViewer::TEvViewerResponse> MakeRequestViewer(TNodeId nodeId, TEvViewer::TEvViewerRequest* request, ui32 flags = 0);
321-
void RequestTxProxyDescribe(const TString& path);
321+
void RequestTxProxyDescribe(const TString& path, const NKikimrSchemeOp::TDescribeOptions& options = {});
322322
void RequestStateStorageEndpointsLookup(const TString& path);
323323
void RequestStateStorageMetadataCacheEndpointsLookup(const TString& path);
324324
TRequestResponse<TEvStateStorage::TEvBoardInfo> MakeRequestStateStorageEndpointsLookup(const TString& path, ui64 cookie = 0);

ydb/core/viewer/viewer_nodes.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,10 @@ class TJsonNodes : public TViewerPipeClient {
18921892
HivesToAsk.push_back(entry.DomainInfo->Params.GetHive());
18931893
}
18941894
}
1895+
} else {
1896+
FilterPathId = TPathId(InvalidOwnerId - 1, InvalidLocalPathId - 1); // invalid path id for sys view tables
1897+
AskHiveAboutPaths = true;
1898+
HivesToAsk.push_back(AppData()->DomainsInfo->GetHive());
18951899
}
18961900
}
18971901
} else {
@@ -1958,6 +1962,8 @@ class TJsonNodes : public TViewerPipeClient {
19581962
if (AskHiveAboutPaths) {
19591963
request->Record.SetFilterTabletsBySchemeShardId(FilterPathId.OwnerId);
19601964
request->Record.SetFilterTabletsByPathId(FilterPathId.LocalPathId);
1965+
} else if (FilterSubDomainKey) {
1966+
request->Record.MutableFilterTabletsByObjectDomain()->CopyFrom(SubDomainKey);
19611967
}
19621968
HiveNodeStats.emplace(hiveId, MakeRequestHiveNodeStats(hiveId, request.release()));
19631969
}
@@ -1980,8 +1986,8 @@ class TJsonNodes : public TViewerPipeClient {
19801986
viewerTablet.SetType(NKikimrTabletBase::TTabletTypes::EType_Name(stateStats.GetTabletType()));
19811987
viewerTablet.SetCount(stateStats.GetCount());
19821988
viewerTablet.SetState(GetFlagFromTabletState(stateStats.GetVolatileState()));
1983-
FieldsAvailable.set(+ENodeFields::Tablets);
19841989
}
1990+
FieldsAvailable.set(+ENodeFields::Tablets);
19851991
}
19861992
if (nodeStats.HasLastAliveTimestamp()) {
19871993
node->SystemState.SetDisconnectTime(std::max(node->SystemState.GetDisconnectTime(), nodeStats.GetLastAliveTimestamp())); // milliseconds
@@ -2148,6 +2154,9 @@ class TJsonNodes : public TViewerPipeClient {
21482154
request->AddFieldsRequired(-1);
21492155
}
21502156
request->SetGroupBy("Type,State");
2157+
if (FilterSubDomainKey) {
2158+
request->MutableFilterTenantId()->CopyFrom(SubDomainKey);
2159+
}
21512160
}
21522161

21532162
template<>

ydb/core/viewer/viewer_tabletinfo.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ class TJsonTabletInfo : public TJsonWhiteboardRequest<TEvWhiteboard::TEvTabletSt
123123
if (params.Has("path")) {
124124
TBase::RequestSettings.Timeout = FromStringWithDefault<ui32>(params.Get("timeout"), 10000);
125125
IsBase64Encode = FromStringWithDefault<bool>(params.Get("base64"), IsBase64Encode);
126-
RequestTxProxyDescribe(params.Get("path"));
126+
NKikimrSchemeOp::TDescribeOptions options;
127+
options.SetReturnBoundaries(true);
128+
options.SetReturnIndexTableBoundaries(true);
129+
options.SetShowPrivateTable(true);
130+
RequestTxProxyDescribe(params.Get("path"), options);
127131
Become(&TThis::StateRequestedDescribe, TDuration::MilliSeconds(TBase::RequestSettings.Timeout), new TEvents::TEvWakeup());
128132
} else {
129133
TBase::Bootstrap();

0 commit comments

Comments
 (0)