Skip to content

Commit e48e086

Browse files
committed
fix handling of schema elements in .sys directory (ydb-platform#7429)
1 parent abb0092 commit e48e086

File tree

3 files changed

+50
-21
lines changed

3 files changed

+50
-21
lines changed

ydb/core/viewer/viewer_acl.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,21 @@ class TJsonACL : public TViewerPipeClient {
158158
NKikimrViewer::TMetaInfo metaInfo;
159159
NKikimrViewer::TMetaCommonInfo& pbCommon = *metaInfo.MutableCommon();
160160
pbCommon.SetPath(CanonizePath(entry.Path));
161-
pbCommon.SetOwner(entry.Self->Info.GetOwner());
162-
if (entry.Self->Info.HasACL()) {
163-
NACLib::TACL acl(entry.Self->Info.GetACL());
164-
for (const NACLibProto::TACE& ace : acl.GetACE()) {
165-
auto& pbAce = *pbCommon.AddACL();
166-
FillACE(ace, pbAce);
161+
if (entry.Self) {
162+
pbCommon.SetOwner(entry.Self->Info.GetOwner());
163+
if (entry.Self->Info.HasACL()) {
164+
NACLib::TACL acl(entry.Self->Info.GetACL());
165+
for (const NACLibProto::TACE& ace : acl.GetACE()) {
166+
auto& pbAce = *pbCommon.AddACL();
167+
FillACE(ace, pbAce);
168+
}
167169
}
168-
}
169-
if (entry.Self->Info.HasEffectiveACL()) {
170-
NACLib::TACL acl(entry.Self->Info.GetEffectiveACL());
171-
for (const NACLibProto::TACE& ace : acl.GetACE()) {
172-
auto& pbAce = *pbCommon.AddEffectiveACL();
173-
FillACE(ace, pbAce);
170+
if (entry.Self->Info.HasEffectiveACL()) {
171+
NACLib::TACL acl(entry.Self->Info.GetEffectiveACL());
172+
for (const NACLibProto::TACE& ace : acl.GetACE()) {
173+
auto& pbAce = *pbCommon.AddEffectiveACL();
174+
FillACE(ace, pbAce);
175+
}
174176
}
175177
}
176178

ydb/core/viewer/viewer_describe.h

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ class TJsonDescribe : public TViewerPipeClient {
117117

118118
void FillDescription(NKikimrSchemeOp::TDirEntry* descr, ui64 schemeShardId) {
119119
descr->SetSchemeshardId(schemeShardId);
120-
descr->SetPathId(InvalidLocalPathId);
121-
descr->SetParentPathId(InvalidLocalPathId);
122120
descr->SetCreateFinished(true);
123121
descr->SetCreateTxId(0);
124122
descr->SetCreateStep(0);
@@ -177,11 +175,21 @@ class TJsonDescribe : public TViewerPipeClient {
177175
result->SetReason(record.GetReason());
178176
result->SetPath(record.GetPath());
179177
result->MutablePathDescription()->CopyFrom(record.GetPathDescription());
180-
result->SetPathId(record.GetPathId());
178+
if (record.GetPathId() != 0 && record.GetPathId() != InvalidLocalPathId) {
179+
result->SetPathId(record.GetPathId());
180+
}
181+
if (result->MutablePathDescription()->GetSelf().GetPathId() == 0 || result->MutablePathDescription()->GetSelf().GetPathId() == InvalidLocalPathId) {
182+
result->MutablePathDescription()->MutableSelf()->ClearPathId();
183+
}
184+
if (result->MutablePathDescription()->GetSelf().GetParentPathId() == 0 || result->MutablePathDescription()->GetSelf().GetParentPathId() == InvalidLocalPathId) {
185+
result->MutablePathDescription()->MutableSelf()->ClearParentPathId();
186+
}
181187
result->SetLastExistedPrefixPath(record.GetLastExistedPrefixPath());
182188
result->SetLastExistedPrefixPathId(record.GetLastExistedPrefixPathId());
183189
result->MutableLastExistedPrefixDescription()->CopyFrom(record.GetLastExistedPrefixDescription());
184-
result->SetPathOwnerId(record.GetPathOwnerId());
190+
if (record.GetPathOwnerId() != 0 && record.GetPathOwnerId() != InvalidOwnerId) {
191+
result->SetPathOwnerId(record.GetPathOwnerId());
192+
}
185193
result->SetSource(NKikimrViewer::TEvDescribeSchemeInfo::SchemeShard);
186194

187195
return result;
@@ -194,13 +202,23 @@ class TJsonDescribe : public TViewerPipeClient {
194202

195203
TAutoPtr<NKikimrViewer::TEvDescribeSchemeInfo> result(new NKikimrViewer::TEvDescribeSchemeInfo());
196204
result->SetPath(path);
197-
result->SetPathId(entry.Self->Info.GetPathId());
198-
result->SetPathOwnerId(entry.Self->Info.GetSchemeshardId());
199-
200205
auto* pathDescription = result->MutablePathDescription();
201206
auto* self = pathDescription->MutableSelf();
202-
203-
self->CopyFrom(entry.Self->Info);
207+
if (entry.Self) {
208+
self->CopyFrom(entry.Self->Info);
209+
if (self->GetPathId() == 0 || self->GetPathId() == InvalidLocalPathId) {
210+
self->ClearPathId();
211+
}
212+
if (self->GetParentPathId() == 0 || self->GetParentPathId() == InvalidLocalPathId) {
213+
self->ClearParentPathId();
214+
}
215+
if (entry.Self->Info.GetPathId() != 0 && entry.Self->Info.GetPathId() != InvalidLocalPathId) {
216+
result->SetPathId(entry.Self->Info.GetPathId());
217+
}
218+
if (entry.Self->Info.GetSchemeshardId() != 0 && entry.Self->Info.GetSchemeshardId() != InvalidOwnerId) {
219+
result->SetPathOwnerId(entry.Self->Info.GetSchemeshardId());
220+
}
221+
}
204222
FillDescription(self, schemeShardId);
205223

206224
if (entry.ListNodeEntry) {
@@ -255,6 +273,14 @@ class TJsonDescribe : public TViewerPipeClient {
255273
PassAway();
256274
return;
257275
}
276+
for (auto& child : *DescribeResult->MutablePathDescription()->MutableChildren()) {
277+
if (child.GetPathId() == InvalidLocalPathId) {
278+
child.ClearPathId();
279+
}
280+
if (child.GetParentPathId() == InvalidLocalPathId) {
281+
child.ClearParentPathId();
282+
}
283+
}
258284
TProtoToJson::ProtoToJson(json, *DescribeResult, JsonSettings);
259285
DecodeExternalTableContent(json);
260286
} else {

ydb/core/viewer/viewer_hotkeys.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class TJsonHotkeys : public TViewerPipeClient {
7171
const auto& pathDescription = pbRecord.GetPathDescription();
7272
const auto& partitions = pathDescription.GetTablePartitions();
7373
const auto& metrics = pathDescription.GetTablePartitionMetrics();
74+
7475
if (!metrics.empty()) {
7576
TVector<std::pair<ui64, int>> tabletsOrder;
7677

0 commit comments

Comments
 (0)