aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Efimov <xeno@ydb.tech>2025-04-14 12:07:20 +0200
committerGitHub <noreply@github.com>2025-04-14 13:07:20 +0300
commit501536af30e05202f18d53b9fd2523918fa89494 (patch)
tree2000c4fa349894fc9ec4a92ef6be67ce81de9f0b
parentf020a4ad91e5dabe24229ef4007d6991b3589e7c (diff)
downloadydb-501536af30e05202f18d53b9fd2523918fa89494.tar.gz
fix tablets filters (#17157)
-rw-r--r--ydb/core/mind/hive/hive_impl.cpp11
-rw-r--r--ydb/core/protos/hive.proto3
-rw-r--r--ydb/core/viewer/json_pipe_req.cpp18
-rw-r--r--ydb/core/viewer/json_pipe_req.h2
-rw-r--r--ydb/core/viewer/tests/canondata/result.json24
-rw-r--r--ydb/core/viewer/viewer_nodes.h11
-rw-r--r--ydb/core/viewer/viewer_tabletinfo.h6
7 files changed, 50 insertions, 25 deletions
diff --git a/ydb/core/mind/hive/hive_impl.cpp b/ydb/core/mind/hive/hive_impl.cpp
index e7e98b6e269..ad4ebe60464 100644
--- a/ydb/core/mind/hive/hive_impl.cpp
+++ b/ydb/core/mind/hive/hive_impl.cpp
@@ -2076,9 +2076,18 @@ void THive::Handle(TEvHive::TEvRequestHiveNodeStats::TPtr& ev) {
}
}
} else {
+ std::optional<TSubDomainKey> filterObjectDomain;
+ if (request.HasFilterTabletsByObjectDomain()) {
+ filterObjectDomain = TSubDomainKey(request.GetFilterTabletsByObjectDomain());
+ }
for (const auto& [state, set] : node.Tablets) {
std::vector<ui32> tabletTypeToCount;
for (const TTabletInfo* tablet : set) {
+ if (filterObjectDomain) {
+ if (tablet->NodeFilter.ObjectDomain != *filterObjectDomain) {
+ continue;
+ }
+ }
TTabletTypes::EType type = tablet->GetTabletType();
if (static_cast<size_t>(type) >= tabletTypeToCount.size()) {
tabletTypeToCount.resize(type + 1);
@@ -3546,7 +3555,7 @@ void THive::Handle(TEvPrivate::TEvUpdateFollowers::TPtr&) {
void THive::MakeScaleRecommendation() {
BLOG_D("[MSR] Started");
-
+
if (AreWeRootHive()) {
return;
}
diff --git a/ydb/core/protos/hive.proto b/ydb/core/protos/hive.proto
index f168bb40474..7bb49b9ac13 100644
--- a/ydb/core/protos/hive.proto
+++ b/ydb/core/protos/hive.proto
@@ -323,6 +323,7 @@ message TEvRequestHiveNodeStats {
// The next 2 fields should always be used together
optional uint64 FilterTabletsByPathId = 7;
optional uint64 FilterTabletsBySchemeShardId = 8;
+ optional NKikimrSubDomains.TDomainKey FilterTabletsByObjectDomain = 9;
}
message THiveNodeStats {
@@ -616,7 +617,7 @@ message TScaleRecommenderPolicies {
message TScaleRecommenderPolicy {
message TTargetTrackingPolicy {
oneof Target {
- uint32 AverageCpuUtilizationPercent = 1;
+ uint32 AverageCpuUtilizationPercent = 1;
}
}
diff --git a/ydb/core/viewer/json_pipe_req.cpp b/ydb/core/viewer/json_pipe_req.cpp
index cbea3eea89b..4c4d0a27835 100644
--- a/ydb/core/viewer/json_pipe_req.cpp
+++ b/ydb/core/viewer/json_pipe_req.cpp
@@ -451,8 +451,16 @@ TViewerPipeClient::TRequestResponse<TEvHive::TEvResponseHiveNodeStats> TViewerPi
TActorId pipeClient = ConnectTabletPipe(hiveId);
auto response = MakeRequestToPipe<TEvHive::TEvResponseHiveNodeStats>(pipeClient, request, hiveId);
if (response.Span) {
- auto hive_id = "#" + ::ToString(hiveId);
- response.Span.Attribute("hive_id", hive_id);
+ response.Span.Attribute("hive_id", TStringBuilder() << '#' << hiveId);
+ if (request->Record.GetFilterTabletsBySchemeShardId()) {
+ response.Span.Attribute("schemeshard_id", TStringBuilder() << '#' << request->Record.GetFilterTabletsBySchemeShardId());
+ }
+ if (request->Record.GetFilterTabletsByPathId()) {
+ response.Span.Attribute("path_id", TStringBuilder() << '#' << request->Record.GetFilterTabletsByPathId());
+ }
+ if (request->Record.HasFilterTabletsByObjectDomain()) {
+ response.Span.Attribute("object_domain", TStringBuilder() << TSubDomainKey(request->Record.GetFilterTabletsByObjectDomain()));
+ }
}
return response;
}
@@ -737,6 +745,7 @@ THolder<NSchemeCache::TSchemeCacheNavigate> TViewerPipeClient::SchemeCacheNaviga
) {
THolder<NSchemeCache::TSchemeCacheNavigate> request = MakeHolder<NSchemeCache::TSchemeCacheNavigate>();
entry.RedirectRequired = false;
+ entry.ShowPrivatePath = true;
entry.Operation = NSchemeCache::TSchemeCacheNavigate::EOp::OpPath;
request->ResultSet.emplace_back(std::move(entry));
return request;
@@ -763,6 +772,7 @@ TViewerPipeClient::TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResu
NSchemeCache::TSchemeCacheNavigate::TEntry entry;
entry.Path = SplitPath(path);
entry.RedirectRequired = false;
+ entry.ShowPrivatePath = true;
entry.Operation = NSchemeCache::TSchemeCacheNavigate::EOp::OpPath;
request->ResultSet.emplace_back(entry);
auto response = MakeRequest<TEvTxProxySchemeCache::TEvNavigateKeySetResult>(MakeSchemeCacheID(), new TEvTxProxySchemeCache::TEvNavigateKeySet(request.Release()), 0 /*flags*/, cookie);
@@ -778,6 +788,7 @@ TViewerPipeClient::TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResu
entry.TableId.PathId = pathId;
entry.RequestType = NSchemeCache::TSchemeCacheNavigate::TEntry::ERequestType::ByTableId;
entry.RedirectRequired = false;
+ entry.ShowPrivatePath = true;
entry.Operation = NSchemeCache::TSchemeCacheNavigate::EOp::OpPath;
request->ResultSet.emplace_back(entry);
auto response = MakeRequest<TEvTxProxySchemeCache::TEvNavigateKeySetResult>(MakeSchemeCacheID(), new TEvTxProxySchemeCache::TEvNavigateKeySet(request.Release()), 0 /*flags*/, cookie);
@@ -822,9 +833,10 @@ TViewerPipeClient::TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResu
return response;
}
-void TViewerPipeClient::RequestTxProxyDescribe(const TString& path) {
+void TViewerPipeClient::RequestTxProxyDescribe(const TString& path, const NKikimrSchemeOp::TDescribeOptions& options) {
THolder<TEvTxUserProxy::TEvNavigate> request(new TEvTxUserProxy::TEvNavigate());
request->Record.MutableDescribePath()->SetPath(path);
+ request->Record.MutableDescribePath()->MutableOptions()->CopyFrom(options);
if (Event && !Event->Get()->UserToken.empty()) {
request->Record.SetUserToken(Event->Get()->UserToken);
}
diff --git a/ydb/core/viewer/json_pipe_req.h b/ydb/core/viewer/json_pipe_req.h
index 5e185a27f22..bf475ae549f 100644
--- a/ydb/core/viewer/json_pipe_req.h
+++ b/ydb/core/viewer/json_pipe_req.h
@@ -318,7 +318,7 @@ protected:
const TString& path, bool showPrivate, ui32 access, ui64 cookie = 0);
TRequestResponse<TEvViewer::TEvViewerResponse> MakeRequestViewer(TNodeId nodeId, TEvViewer::TEvViewerRequest* request, ui32 flags = 0);
- void RequestTxProxyDescribe(const TString& path);
+ void RequestTxProxyDescribe(const TString& path, const NKikimrSchemeOp::TDescribeOptions& options = {});
void RequestStateStorageEndpointsLookup(const TString& path);
void RequestStateStorageMetadataCacheEndpointsLookup(const TString& path);
TRequestResponse<TEvStateStorage::TEvBoardInfo> MakeRequestStateStorageEndpointsLookup(const TString& path, ui64 cookie = 0);
diff --git a/ydb/core/viewer/tests/canondata/result.json b/ydb/core/viewer/tests/canondata/result.json
index 786307c6410..6fbf17c7347 100644
--- a/ydb/core/viewer/tests/canondata/result.json
+++ b/ydb/core/viewer/tests/canondata/result.json
@@ -3277,33 +3277,23 @@
},
"Tablets": [
{
- "Count": 4,
- "State": "Green",
- "Type": "Coordinator"
- },
- {
"Count": 1,
"State": "Green",
- "Type": "Hive"
+ "Type": "Coordinator"
},
{
- "Count": 6,
+ "Count": 3,
"State": "Green",
"Type": "Mediator"
},
{
- "Count": 2,
+ "Count": 1,
"State": "Green",
"Type": "SchemeShard"
},
{
"Count": 1,
"State": "Green",
- "Type": "StatisticsAggregator"
- },
- {
- "Count": 2,
- "State": "Green",
"Type": "SysViewProcessor"
}
],
@@ -3478,7 +3468,7 @@
},
"Tablets": [
{
- "Count": 4,
+ "Count": 3,
"State": "Green",
"Type": "Coordinator"
},
@@ -3488,12 +3478,12 @@
"Type": "Hive"
},
{
- "Count": 6,
+ "Count": 3,
"State": "Green",
"Type": "Mediator"
},
{
- "Count": 2,
+ "Count": 1,
"State": "Green",
"Type": "SchemeShard"
},
@@ -3503,7 +3493,7 @@
"Type": "StatisticsAggregator"
},
{
- "Count": 2,
+ "Count": 1,
"State": "Green",
"Type": "SysViewProcessor"
}
diff --git a/ydb/core/viewer/viewer_nodes.h b/ydb/core/viewer/viewer_nodes.h
index 9cfa1943835..ffc21f9939e 100644
--- a/ydb/core/viewer/viewer_nodes.h
+++ b/ydb/core/viewer/viewer_nodes.h
@@ -1892,6 +1892,10 @@ public:
HivesToAsk.push_back(entry.DomainInfo->Params.GetHive());
}
}
+ } else {
+ FilterPathId = TPathId(InvalidOwnerId - 1, InvalidLocalPathId - 1); // invalid path id for sys view tables
+ AskHiveAboutPaths = true;
+ HivesToAsk.push_back(AppData()->DomainsInfo->GetHive());
}
}
} else {
@@ -1958,6 +1962,8 @@ public:
if (AskHiveAboutPaths) {
request->Record.SetFilterTabletsBySchemeShardId(FilterPathId.OwnerId);
request->Record.SetFilterTabletsByPathId(FilterPathId.LocalPathId);
+ } else if (FilterSubDomainKey) {
+ request->Record.MutableFilterTabletsByObjectDomain()->CopyFrom(SubDomainKey);
}
HiveNodeStats.emplace(hiveId, MakeRequestHiveNodeStats(hiveId, request.release()));
}
@@ -1980,8 +1986,8 @@ public:
viewerTablet.SetType(NKikimrTabletBase::TTabletTypes::EType_Name(stateStats.GetTabletType()));
viewerTablet.SetCount(stateStats.GetCount());
viewerTablet.SetState(GetFlagFromTabletState(stateStats.GetVolatileState()));
- FieldsAvailable.set(+ENodeFields::Tablets);
}
+ FieldsAvailable.set(+ENodeFields::Tablets);
}
if (nodeStats.HasLastAliveTimestamp()) {
node->SystemState.SetDisconnectTime(std::max(node->SystemState.GetDisconnectTime(), nodeStats.GetLastAliveTimestamp())); // milliseconds
@@ -2148,6 +2154,9 @@ public:
request->AddFieldsRequired(-1);
}
request->SetGroupBy("Type,State");
+ if (FilterSubDomainKey) {
+ request->MutableFilterTenantId()->CopyFrom(SubDomainKey);
+ }
}
template<>
diff --git a/ydb/core/viewer/viewer_tabletinfo.h b/ydb/core/viewer/viewer_tabletinfo.h
index 144eca31700..80fc3e6688e 100644
--- a/ydb/core/viewer/viewer_tabletinfo.h
+++ b/ydb/core/viewer/viewer_tabletinfo.h
@@ -123,7 +123,11 @@ public:
if (params.Has("path")) {
TBase::RequestSettings.Timeout = FromStringWithDefault<ui32>(params.Get("timeout"), 10000);
IsBase64Encode = FromStringWithDefault<bool>(params.Get("base64"), IsBase64Encode);
- RequestTxProxyDescribe(params.Get("path"));
+ NKikimrSchemeOp::TDescribeOptions options;
+ options.SetReturnBoundaries(true);
+ options.SetReturnIndexTableBoundaries(true);
+ options.SetShowPrivateTable(true);
+ RequestTxProxyDescribe(params.Get("path"), options);
Become(&TThis::StateRequestedDescribe, TDuration::MilliSeconds(TBase::RequestSettings.Timeout), new TEvents::TEvWakeup());
} else {
TBase::Bootstrap();