Skip to content

Commit

Permalink
return grandchildren flag
Browse files Browse the repository at this point in the history
  • Loading branch information
adameat committed Jan 13, 2025
1 parent 0ae852e commit 0e0efc8
Show file tree
Hide file tree
Showing 44 changed files with 238 additions and 6 deletions.
1 change: 1 addition & 0 deletions ydb/core/protos/flat_scheme_op.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,7 @@ message TDirEntry {
optional uint64 PathVersion = 13;
optional EPathSubType PathSubType = 14;
optional TPathVersion Version = 15;
optional bool ChildrenExist = 16;

optional uint64 BalancerTabletID = 999; //temporary optimization for old PQ read/write protocol. Must be removed later
}
Expand Down
4 changes: 4 additions & 0 deletions ydb/core/tx/schemeshard/olap/operations/create_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ class TCreateOlapStore: public TSubOperation {
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
4 changes: 4 additions & 0 deletions ydb/core/tx/schemeshard/olap/operations/create_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,10 @@ class TCreateColumnTable: public TSubOperation {
}
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState(!!storeInfo));
return result;
}
Expand Down
7 changes: 7 additions & 0 deletions ydb/core/tx/schemeshard/olap/operations/drop_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ class TPropose: public TSubOperationState {
domainInfo->DecPathsInside();
parentDir->DecAliveChildren();

if (parentDir->GetChildren().size() == 0 && !parentDir->IsDomainRoot()) { // for correct discard of ChildrenExist prop
auto grandParentDir = context.SS->PathsById.at(parentDir->ParentPathId);
++grandParentDir->DirAlterVersion;
context.SS->ClearDescribePathCaches(grandParentDir);
context.OnComplete.PublishToSchemeBoard(OperationId, grandParentDir->PathId);
}

context.SS->TabletCounters->Simple()[COUNTER_USER_ATTRIBUTES_COUNT].Sub(path->UserAttrs->Size());
context.SS->PersistUserAttributes(db, path->PathId, path->UserAttrs, nullptr);

Expand Down
7 changes: 7 additions & 0 deletions ydb/core/tx/schemeshard/olap/operations/drop_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ class TPropose: public TSubOperationState {
domainInfo->DecPathsInside();
parentDir->DecAliveChildren();

if (parentDir->GetChildren().size() == 0 && !parentDir->IsDomainRoot()) { // for correct discard of ChildrenExist prop
auto grandParentDir = context.SS->PathsById.at(parentDir->ParentPathId);
++grandParentDir->DirAlterVersion;
context.SS->ClearDescribePathCaches(grandParentDir);
context.OnComplete.PublishToSchemeBoard(OperationId, grandParentDir->PathId);
}

context.SS->TabletCounters->Simple()[COUNTER_USER_ATTRIBUTES_COUNT].Sub(path->UserAttrs->Size());
context.SS->PersistUserAttributes(db, path->PathId, path->UserAttrs, nullptr);

Expand Down
8 changes: 6 additions & 2 deletions ydb/core/tx/schemeshard/schemeshard__operation_blob_depot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace NKikimr::NSchemeShard {

return !txState->ShardsInProgress;
}

TString DebugHint() const override {
return TStringBuilder() << "TConfigureBlobDepotParts id# " << OperationId;
}
Expand Down Expand Up @@ -379,8 +379,12 @@ namespace NKikimr::NSchemeShard {
dstPath->IncShardsInside();
parentPath->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(TTxState::CreateParts);

auto resp = MakeHolder<TProposeResponse>(NKikimrScheme::StatusAccepted, txId, ssId);
resp->SetPathId(pathId.LocalPathId);
return resp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,10 @@ class TCopySequence: public TSubOperation {
domainInfo->IncPathsInside();
parentPath->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ class TCreateBackupCollection : public TSubOperation {

UpdatePathSizeCounts(rootPath, dstPath);

if (rootPath.Base()->GetChildren().size() == 1 && !rootPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, rootPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
4 changes: 4 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation_create_bsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ class TCreateBlockStoreVolume: public TSubOperation {
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ class TNewCdcStream: public TSubOperation {
streamPath.DomainInfo()->IncPathsInside();
tablePath.Base()->IncAliveChildren();

if (tablePath.Base()->GetChildren().size() == 1 && !tablePath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, tablePath, context.SS, context.OnComplete);
}

context.OnComplete.ActivateTx(OperationId);

SetState(NextState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ class TCreateExternalDataSource : public TSubOperation {

UpdatePathSizeCounts(parentPath, dstPath);

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ class TCreateExternalTable: public TSubOperation {

UpdatePathSizeCounts(parentPath, dstPath);

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ class TCreateExtSubDomain: public TSubOperation {
parentPath.DomainInfo()->IncPathsInside();
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
4 changes: 4 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation_create_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ THolder<TProposeResponse> TCreateFileStore::Propose(
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ class TCreateTableIndex: public TSubOperation {
dstPath.DomainInfo()->IncPathsInside();
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ class TCreateKesus: public TSubOperation {
dstPath.Base()->IncShardsInside();
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
4 changes: 4 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ class TCreatePQ: public TSubOperation {
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ class TCreateReplication: public TSubOperation {
parentPath->IncAliveChildren();
parentPath.DomainInfo()->IncPathsInside();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

if (desc.GetConfig().GetSrcConnectionParams().GetCredentialsCase() == NKikimrReplication::TConnectionParams::CREDENTIALS_NOT_SET) {
desc.MutableConfig()->MutableSrcConnectionParams()->MutableOAuthToken()->SetToken(BUILTIN_ACL_ROOT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ class TCreateResourcePool : public TSubOperation {

UpdatePathSizeCounts(parentPath, dstPath);

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ class TCreateRTMR: public TSubOperation {
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,10 @@ class TCreateSequence : public TSubOperation {
domainInfo->IncPathsInside();
parentPath->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ class TCreateSolomon: public TSubOperation {
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ class TCreateSubDomain: public TSubOperation {
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

SetState(NextState());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,10 @@ class TCreateTable: public TSubOperation {
dstPath.Base()->IncShardsInside(shardsToCreate);
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

LOG_TRACE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
"TCreateTable Propose creating new table"
<< " opId# " << OperationId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ class TCreateView: public TSubOperation {
dstPath.MaterializeLeaf(owner, viewPathId);
dstPath.DomainInfo()->IncPathsInside();
parentPath.Base()->IncAliveChildren();

if (parentPath.Base()->GetChildren().size() == 1 && !parentPath.IsDomain()) { // for correct discard of ChildrenExist prop
IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, parentPath, context.SS, context.OnComplete);
}

result->SetPathId(viewPathId.LocalPathId);

TPathElement::TPtr viewPath = dstPath.Base();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class TPropose : public TSubOperationState {
parentDirPtr->DecAliveChildren();
context.SS->TabletCounters->Simple()[COUNTER_BACKUP_COLLECTION_COUNT].Sub(1);

if (parentDirPtr->GetChildren().size() == 0 && !parentDirPtr->IsDomainRoot()) { // for correct discard of ChildrenExist prop
auto grandParentDir = context.SS->PathsById.at(parentDirPtr->ParentPathId);
++grandParentDir->DirAlterVersion;
context.SS->ClearDescribePathCaches(grandParentDir);
context.OnComplete.PublishToSchemeBoard(OperationId, grandParentDir->PathId);
}

++parentDirPtr->DirAlterVersion;
context.SS->PersistPathDirAlterVersion(db, parentDirPtr);
context.SS->ClearDescribePathCaches(parentDirPtr);
Expand Down
9 changes: 8 additions & 1 deletion ydb/core/tx/schemeshard/schemeshard__operation_drop_bsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ class TPropose: public TSubOperationState {
domainInfo->DecPathsInside();
parentDir->DecAliveChildren();

if (parentDir->GetChildren().size() == 0 && !parentDir->IsDomainRoot()) { // for correct discard of ChildrenExist prop
auto grandParentDir = context.SS->PathsById.at(parentDir->ParentPathId);
++grandParentDir->DirAlterVersion;
context.SS->ClearDescribePathCaches(grandParentDir);
context.OnComplete.PublishToSchemeBoard(OperationId, grandParentDir->PathId);
}

// KIKIMR-13173
// Repeat it here for a while, delete it from TDeleteParts after
// Initiate asynchronous deletion of all shards
Expand Down Expand Up @@ -219,7 +226,7 @@ class TDropBlockStoreVolume: public TSubOperation {
double rate = 0;
double capacity = 0;
auto& attrs = domainDir->UserAttrs->Attrs;
if (TryFromString(attrs[RateLimiterRateAttrName], rate) &&
if (TryFromString(attrs[RateLimiterRateAttrName], rate) &&
TryFromString(attrs[RateLimiterCapacityAttrName], capacity))
{
rateLimiter.SetRate(rate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ class TPropose: public TSubOperationState {
context.SS->ResolveDomainInfo(pathId)->DecPathsInside();
parent->DecAliveChildren();

if (parent->GetChildren().size() == 0 && !parent->IsDomainRoot()) { // for correct discard of ChildrenExist prop
auto grandParentDir = context.SS->PathsById.at(parent->ParentPathId);
++grandParentDir->DirAlterVersion;
context.SS->ClearDescribePathCaches(grandParentDir);
context.OnComplete.PublishToSchemeBoard(OperationId, grandParentDir->PathId);
}

context.SS->ClearDescribePathCaches(path);
context.OnComplete.PublishToSchemeBoard(OperationId, pathId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class TPropose: public TSubOperationState {
domainInfo->DecPathsInside();
parentDir->DecAliveChildren();

if (parentDir->GetChildren().size() == 0 && !parentDir->IsDomainRoot()) { // for correct discard of ChildrenExist prop
auto grandParentDir = context.SS->PathsById.at(parentDir->ParentPathId);
++grandParentDir->DirAlterVersion;
context.SS->ClearDescribePathCaches(grandParentDir);
context.OnComplete.PublishToSchemeBoard(OperationId, grandParentDir->PathId);
}

context.SS->TabletCounters->Simple()[COUNTER_EXTERNAL_DATA_SOURCE_COUNT].Sub(1);
context.SS->PersistRemoveExternalDataSource(db, pathId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class TPropose: public TSubOperationState {
domainInfo->DecPathsInside();
parentDir->DecAliveChildren();

if (parentDir->GetChildren().size() == 0 && !parentDir->IsDomainRoot()) { // for correct discard of ChildrenExist prop
auto grandParentDir = context.SS->PathsById.at(parentDir->ParentPathId);
++grandParentDir->DirAlterVersion;
context.SS->ClearDescribePathCaches(grandParentDir);
context.OnComplete.PublishToSchemeBoard(OperationId, grandParentDir->PathId);
}

TExternalDataSourceInfo::TPtr externalDataSourceInfo = context.SS->ExternalDataSources.Value(dataSourcePathId, nullptr);
Y_ABORT_UNLESS(externalDataSourceInfo);
EraseIf(*externalDataSourceInfo->ExternalTableReferences.MutableReferences(), [pathId](const NKikimrSchemeOp::TExternalTableReferences::TReference& reference) { return TPathId::FromProto(reference.GetPathId()) == pathId; });
Expand Down
7 changes: 7 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ class TPropose: public TSubOperationState {
domainInfo->DecPathsInside();
parentDir->DecAliveChildren();

if (parentDir->GetChildren().size() == 0 && !parentDir->IsDomainRoot()) { // for correct discard of ChildrenExist prop
auto grandParentDir = context.SS->PathsById.at(parentDir->ParentPathId);
++grandParentDir->DirAlterVersion;
context.SS->ClearDescribePathCaches(grandParentDir);
context.OnComplete.PublishToSchemeBoard(OperationId, grandParentDir->PathId);
}

// KIKIMR-13173
// Repeat it here for a while, delete it from TDeleteParts after
// Initiate asynchronous deletion of all shards
Expand Down
Loading

0 comments on commit 0e0efc8

Please sign in to comment.