Skip to content

Commit 5d6cf52

Browse files
authored
add subdomain key to required fiels for non-database requests (#15341)
1 parent a01e65f commit 5d6cf52

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

ydb/core/viewer/json_handlers_viewer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void InitViewerHealthCheckJsonHandler(TJsonHandlers& handlers) {
246246
}
247247

248248
void InitViewerNodesJsonHandler(TJsonHandlers& handlers) {
249-
handlers.AddHandler("/viewer/nodes", new TJsonHandler<TJsonNodes>(TJsonNodes::GetSwagger()), 14);
249+
handlers.AddHandler("/viewer/nodes", new TJsonHandler<TJsonNodes>(TJsonNodes::GetSwagger()), 15);
250250
}
251251

252252
void InitViewerACLJsonHandler(TJsonHandlers &jsonHandlers) {

ydb/core/viewer/protos/viewer.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,12 @@ message TNodeInfo {
561561
repeated NKikimrWhiteboard.TNodeStateInfo ReversePeers = 55;
562562
}
563563

564+
message TNodeBatch {
565+
repeated uint32 NodesToAskFor = 1;
566+
repeated uint32 NodesToAskAbout = 2;
567+
optional bool HasStaticNodes = 3;
568+
}
569+
564570
message TNodesInfo {
565571
uint32 Version = 1;
566572
optional uint64 TotalNodes = 2;
@@ -578,6 +584,7 @@ message TNodesInfo {
578584
optional uint64 MaximumSlotsPerDisk = 51;
579585
optional bool NoDC = 60;
580586
optional bool NoRack = 61;
587+
repeated TNodeBatch OriginalNodeBatches = 62;
581588
}
582589

583590
enum ENodeType {

ydb/core/viewer/tests/canondata/result.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,7 +2969,7 @@
29692969
"test.test_viewer_nodes_issue_14992": {
29702970
"response_group": {
29712971
"FieldsAvailable": "0000000110111110111111100000111",
2972-
"FieldsRequired": "0000000001000000010000000000101",
2972+
"FieldsRequired": "0000000001100000010000000000101",
29732973
"FoundNodes": "3",
29742974
"MaximumDisksPerNode": "1",
29752975
"Nodes": [
@@ -3190,7 +3190,7 @@
31903190
},
31913191
"response_group_by": {
31923192
"FieldsAvailable": "0000000110111110111111100000111",
3193-
"FieldsRequired": "0000000001000000010000000000101",
3193+
"FieldsRequired": "0000000001100000010000000000101",
31943194
"FoundNodes": "3",
31953195
"MaximumDisksPerNode": "1",
31963196
"NodeGroups": [

ydb/core/viewer/viewer_nodes.h

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ class TJsonNodes : public TViewerPipeClient {
181181
ui32 SpaceUsageProblem = 90; // %
182182
bool OffloadMerge = true;
183183
size_t OffloadMergeAttempts = 2;
184+
size_t OffloadMergeBatchSize = 200;
184185

185186
using TGroupSortKey = std::variant<TString, ui64, float, int>;
186187

@@ -748,6 +749,8 @@ class TJsonNodes : public TViewerPipeClient {
748749
std::vector<TNodeGroup> NodeGroups;
749750
std::unordered_map<TNodeId, TNode*> NodesByNodeId;
750751
std::unordered_map<TNodeId, TNodeBatch> NodeBatches;
752+
std::vector<TNodeBatch> OriginalNodeBatches;
753+
bool DumpOriginalNodeBatches = false;
751754

752755
TFieldsType FieldsRequired;
753756
TFieldsType FieldsAvailable;
@@ -953,8 +956,10 @@ class TJsonNodes : public TViewerPipeClient {
953956
}
954957
}
955958

956-
OffloadMerge = FromStringWithDefault<bool>(params.Get("offload_merge"), OffloadMerge);
957-
OffloadMergeAttempts = FromStringWithDefault<bool>(params.Get("offload_merge_attempts"), OffloadMergeAttempts);
959+
OffloadMerge = FromStringWithDefault(params.Get("offload_merge"), OffloadMerge);
960+
OffloadMergeAttempts = FromStringWithDefault(params.Get("offload_merge_attempts"), OffloadMergeAttempts);
961+
OffloadMergeBatchSize = FromStringWithDefault(params.Get("offload_merge_batch_size"), OffloadMergeBatchSize);
962+
DumpOriginalNodeBatches = FromStringWithDefault(params.Get("dump_original_node_batches"), DumpOriginalNodeBatches);
958963
Direct = FromStringWithDefault<bool>(params.Get("direct"), Direct);
959964
TString filterStoragePool = params.Get("pool");
960965
if (filterStoragePool.empty()) {
@@ -1078,6 +1083,9 @@ class TJsonNodes : public TViewerPipeClient {
10781083
request->Record.AddFieldsRequired(-1);
10791084
NodeStateResponse = MakeWhiteboardRequest(TActivationContext::ActorSystem()->NodeId, request.release());
10801085
}
1086+
if (!FilterDatabase && OffloadMerge && FieldsNeeded(FieldsSystemState)) {
1087+
FieldsRequired.set(+ENodeFields::SubDomainKey);
1088+
}
10811089
if (!FilterStoragePools.empty() || !FilterGroupIds.empty()) {
10821090
FilterDatabase = false; // we disable database filter if we're filtering by pool or group
10831091
}
@@ -1571,8 +1579,6 @@ class TJsonNodes : public TViewerPipeClient {
15711579
ApplyLimit();
15721580
}
15731581

1574-
static constexpr size_t BATCH_SIZE = 200;
1575-
15761582
void BuildCandidates(TNodeBatch& batch, std::vector<TNode*>& candidates) {
15771583
auto itCandidate = candidates.begin();
15781584
for (; itCandidate != candidates.end() && batch.NodesToAskFor.size() < OffloadMergeAttempts; ++itCandidate) {
@@ -1591,9 +1597,9 @@ class TJsonNodes : public TViewerPipeClient {
15911597
std::sort(candidates.begin(), candidates.end(), [](TNode* a, TNode* b) {
15921598
return a->GetCandidateScore() > b->GetCandidateScore();
15931599
});
1594-
while (nodeBatch.NodesToAskAbout.size() > BATCH_SIZE) {
1600+
while (nodeBatch.NodesToAskAbout.size() > OffloadMergeBatchSize) {
15951601
TNodeBatch newBatch;
1596-
size_t splitSize = std::min(BATCH_SIZE, nodeBatch.NodesToAskAbout.size() / 2);
1602+
size_t splitSize = std::min(OffloadMergeBatchSize, nodeBatch.NodesToAskAbout.size() / 2);
15971603
newBatch.NodesToAskAbout.reserve(splitSize);
15981604
for (size_t i = 0; i < splitSize; ++i) {
15991605
newBatch.NodesToAskAbout.push_back(nodeBatch.NodesToAskAbout.back());
@@ -2105,6 +2111,9 @@ class TJsonNodes : public TViewerPipeClient {
21052111
FieldsRequired.set(+ENodeFields::SystemState);
21062112
}
21072113
std::vector<TNodeBatch> batches = BatchNodes(NodeView);
2114+
if (DumpOriginalNodeBatches) {
2115+
OriginalNodeBatches = batches;
2116+
}
21082117
if (FilterPeerRole == EPeerRole::Static || FilterPeerRole == EPeerRole::Other) {
21092118
for (TNodeBatch& batch : batches) {
21102119
batch.FieldsRequested.set(+ENodeFields::Peers);
@@ -3101,6 +3110,16 @@ class TJsonNodes : public TViewerPipeClient {
31013110
AddEvent("ReplyAndPassAway");
31023111
ApplyEverything();
31033112
NKikimrViewer::TNodesInfo json;
3113+
for (const auto& batch : OriginalNodeBatches) {
3114+
auto* jsonBatch = json.AddOriginalNodeBatches();
3115+
for (const auto& node : batch.NodesToAskFor) {
3116+
jsonBatch->AddNodesToAskFor(node->GetNodeId());
3117+
}
3118+
for (const auto& node : batch.NodesToAskAbout) {
3119+
jsonBatch->AddNodesToAskAbout(node->GetNodeId());
3120+
}
3121+
jsonBatch->SetHasStaticNodes(batch.HasStaticNodes);
3122+
}
31043123
json.SetVersion(Viewer->GetCapabilityVersion("/viewer/nodes"));
31053124
json.SetFieldsAvailable(FieldsAvailable.to_string());
31063125
json.SetFieldsRequired(FieldsRequired.to_string());

0 commit comments

Comments
 (0)