diff --git a/ydb/core/protos/flat_scheme_op.proto b/ydb/core/protos/flat_scheme_op.proto index beb279f261db..d89282a9ac06 100644 --- a/ydb/core/protos/flat_scheme_op.proto +++ b/ydb/core/protos/flat_scheme_op.proto @@ -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 } diff --git a/ydb/core/tx/schemeshard/olap/operations/create_store.cpp b/ydb/core/tx/schemeshard/olap/operations/create_store.cpp index 6b700b29ee19..33c1f9c3b4ab 100644 --- a/ydb/core/tx/schemeshard/olap/operations/create_store.cpp +++ b/ydb/core/tx/schemeshard/olap/operations/create_store.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/olap/operations/create_table.cpp b/ydb/core/tx/schemeshard/olap/operations/create_table.cpp index a407a991689c..c1000c75733f 100644 --- a/ydb/core/tx/schemeshard/olap/operations/create_table.cpp +++ b/ydb/core/tx/schemeshard/olap/operations/create_table.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/olap/operations/drop_store.cpp b/ydb/core/tx/schemeshard/olap/operations/drop_store.cpp index 06c717e52a2a..d3a60071569c 100644 --- a/ydb/core/tx/schemeshard/olap/operations/drop_store.cpp +++ b/ydb/core/tx/schemeshard/olap/operations/drop_store.cpp @@ -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); diff --git a/ydb/core/tx/schemeshard/olap/operations/drop_table.cpp b/ydb/core/tx/schemeshard/olap/operations/drop_table.cpp index 08541ce5dd1f..d5bd77acccea 100644 --- a/ydb/core/tx/schemeshard/olap/operations/drop_table.cpp +++ b/ydb/core/tx/schemeshard/olap/operations/drop_table.cpp @@ -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); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_blob_depot.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_blob_depot.cpp index 3eb64d22637a..839a53a5d2db 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_blob_depot.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_blob_depot.cpp @@ -93,7 +93,7 @@ namespace NKikimr::NSchemeShard { return !txState->ShardsInProgress; } - + TString DebugHint() const override { return TStringBuilder() << "TConfigureBlobDepotParts id# " << OperationId; } @@ -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(NKikimrScheme::StatusAccepted, txId, ssId); resp->SetPathId(pathId.LocalPathId); return resp; diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_copy_sequence.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_copy_sequence.cpp index 9b81e766374e..c0fa1052c81d 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_copy_sequence.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_copy_sequence.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_backup_collection.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_backup_collection.cpp index 7e0010243c1e..321c1d3b30d2 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_backup_collection.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_backup_collection.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_bsv.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_bsv.cpp index 7ab9b02653f3..9a52d882aef7 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_bsv.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_bsv.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp index 05409e951742..a6e5673aff37 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp @@ -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()); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_external_data_source.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_external_data_source.cpp index 45bcc1f32a3d..4ce62971df24 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_external_data_source.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_external_data_source.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_external_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_external_table.cpp index 1663505e9e6b..224b1b9afe49 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_external_table.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_external_table.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_extsubdomain.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_extsubdomain.cpp index 7abcc6d3a6cb..cd7fca8e955a 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_extsubdomain.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_extsubdomain.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_fs.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_fs.cpp index 0bdd4b764ab5..3fe7181c8b6b 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_fs.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_fs.cpp @@ -433,6 +433,10 @@ THolder 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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp index 534bb2aaab7f..1fe1cea907ae 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_kesus.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_kesus.cpp index db0d4dfd3356..e768c474e876 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_kesus.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_kesus.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp index e90aa279943c..ae364153987d 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_replication.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_replication.cpp index 3757009b6f21..51ee9b2cd4bd 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_replication.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_replication.cpp @@ -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); } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_resource_pool.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_resource_pool.cpp index 46a1bda49550..fac621224ae6 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_resource_pool.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_resource_pool.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp index 4a3883dcacaa..d938d735e1a8 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp index 64fe469e5ae4..fa769c5487c0 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_solomon.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_solomon.cpp index 8eda2088b21b..e8d190ad8ffc 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_solomon.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_solomon.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_subdomain.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_subdomain.cpp index 7e5acedb4f50..18884333c8bb 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_subdomain.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_subdomain.cpp @@ -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; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp index 0e82a3af4f67..429af5eab7ac 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp @@ -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 diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_view.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_view.cpp index 470e1d1a8db9..436926080145 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_view.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_view.cpp @@ -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(); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_backup_collection.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_backup_collection.cpp index 733a0dec5e6c..91d8ef67df1d 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_backup_collection.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_backup_collection.cpp @@ -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); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_bsv.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_bsv.cpp index 849cc9dbfa6d..8d21b52332a0 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_bsv.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_bsv.cpp @@ -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 @@ -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); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp index 98e26d7e0098..b92c9e47103a 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp @@ -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); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_external_data_source.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_external_data_source.cpp index 6eee14346f20..cced3e30b1ee 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_external_data_source.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_external_data_source.cpp @@ -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); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_external_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_external_table.cpp index df6e6917438a..15725255f0b8 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_external_table.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_external_table.cpp @@ -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; }); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp index 4b662fb4c270..a5e7b7457e03 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_fs.cpp @@ -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 diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_indexed_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_indexed_table.cpp index f643fbae9df8..98ec6a1f95aa 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_indexed_table.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_indexed_table.cpp @@ -44,6 +44,13 @@ void DropPath(NIceDb::TNiceDb& db, TOperationContext& context, ++parentDir->DirAlterVersion; context.SS->PersistPathDirAlterVersion(db, parentDir.Base()); + 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->ClearDescribePathCaches(parentDir.Base()); context.SS->ClearDescribePathCaches(path.Base()); @@ -427,7 +434,7 @@ TVector CreateDropIndexedTable(TOperationId nextId, const T .NotUnderDeleting() .NotUnderOperation(); if (!table.Parent()->IsTableIndex() || !NTableIndex::IsBuildImplTable(table.LeafName())) { - checks.IsCommonSensePath(); + checks.IsCommonSensePath(); } } } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_kesus.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_kesus.cpp index f1476ead9642..08d7669828d9 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_kesus.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_kesus.cpp @@ -53,6 +53,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 diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp index e96f73c403bc..a7393f4f13b0 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_pq.cpp @@ -207,6 +207,13 @@ class TPropose: public TSubOperationState { 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); + } + if (!AppData()->DisableSchemeShardCleanupOnDropForTest) { context.SS->PersistRemovePersQueueGroup(db, pathId); } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_replication.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_replication.cpp index 41e48e6cf8e0..7dd036258ff7 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_replication.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_replication.cpp @@ -204,6 +204,13 @@ class TPropose: public TSubOperationState { context.SS->ResolveDomainInfo(pathId)->DecPathsInside(); parentPath->DecAliveChildren(); + if (parentPath->GetChildren().size() == 0 && !parentPath->IsDomainRoot()) { // for correct discard of ChildrenExist prop + auto grandParentDir = context.SS->PathsById.at(parentPath->ParentPathId); + ++grandParentDir->DirAlterVersion; + context.SS->ClearDescribePathCaches(grandParentDir); + context.OnComplete.PublishToSchemeBoard(OperationId, grandParentDir->PathId); + } + ++parentPath->DirAlterVersion; context.SS->PersistPathDirAlterVersion(db, parentPath); context.SS->ClearDescribePathCaches(parentPath); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_resource_pool.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_resource_pool.cpp index 49e4e0e2b11e..1de39078a785 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_resource_pool.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_resource_pool.cpp @@ -24,7 +24,7 @@ class TPropose : public TSubOperationState { const TPathId& pathId = txState->TargetPathId; const TPathElement::TPtr pathPtr = context.SS->PathsById.at(pathId); const TPathElement::TPtr parentDirPtr = context.SS->PathsById.at(pathPtr->ParentPathId); - + NIceDb::TNiceDb db(context.GetDB()); Y_ABORT_UNLESS(!pathPtr->Dropped()); @@ -37,6 +37,13 @@ class TPropose : public TSubOperationState { parentDirPtr->DecAliveChildren(); context.SS->TabletCounters->Simple()[COUNTER_RESOURCE_POOL_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); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_sequence.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_sequence.cpp index eceba236443e..950df68ba3ab 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_sequence.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_sequence.cpp @@ -173,6 +173,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].Add(-path->UserAttrs->Size()); context.SS->PersistUserAttributes(db, path->PathId, path->UserAttrs, nullptr); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_view.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_view.cpp index 0d2c2e21a38c..c4e5da2dd888 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_view.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_view.cpp @@ -59,6 +59,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_VIEW_COUNT].Sub(1); context.SS->PersistRemoveView(db, pathId); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_mkdir.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_mkdir.cpp index 22d527530aa6..a8f8d16c55da 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_mkdir.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_mkdir.cpp @@ -262,6 +262,10 @@ class TMkDir: 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); + } + context.OnComplete.ActivateTx(OperationId); SetState(NextState()); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_sequence.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_sequence.cpp index a08972ade11a..508a42cc0948 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_move_sequence.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_sequence.cpp @@ -26,6 +26,10 @@ void MarkSrcDropped(NIceDb::TNiceDb& db, srcPath.DomainInfo()->DecPathsInside(); IncParentDirAlterVersionWithRepublish(operationId, srcPath, context); + + if (srcPath.Base()->GetChildren().size() == 0 && !srcPath.IsDomain()) { // for correct discard of ChildrenExist prop + IncParentDirAlterVersionWithRepublishSafeWithUndo(operationId, srcPath, context.SS, context.OnComplete); + } } class TConfigureParts : public TSubOperationState { @@ -727,7 +731,7 @@ class TMoveSequence: public TSubOperation { case TTxState::ProposedMoveSequence: return TTxState::DropParts; case TTxState::DropParts: - return TTxState::Done; + return TTxState::Done; default: return TTxState::Invalid; } @@ -942,6 +946,10 @@ class TMoveSequence: public TSubOperation { dstParentPath->IncAliveChildren(); + if (dstParentPath.Base()->GetChildren().size() == 1 && !dstParentPath.IsDomain()) { // for correct discard of ChildrenExist prop + IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, dstParentPath, context.SS, context.OnComplete); + } + srcPath.Base()->PathState = TPathElement::EPathState::EPathStateMoving; srcPath.Base()->LastTxId = OperationId.GetTxId(); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp index f51bdcc97667..fead219e2e7e 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp @@ -153,6 +153,10 @@ void MarkSrcDropped(NIceDb::TNiceDb& db, context.SS->PersistUserAttributes(db, srcPath->PathId, srcPath->UserAttrs, nullptr); IncParentDirAlterVersionWithRepublish(operationId, srcPath, context); + + if (srcPath.Base()->GetChildren().size() == 0 && !srcPath.IsDomain()) { // for correct discard of ChildrenExist prop + IncParentDirAlterVersionWithRepublishSafeWithUndo(operationId, srcPath, context.SS, context.OnComplete); + } } class TPropose: public TSubOperationState { @@ -711,6 +715,10 @@ class TMoveTable: public TSubOperation { dstParent.Base()->IncAliveChildren(); + if (dstParent.Base()->GetChildren().size() == 1 && !dstParent.IsDomain()) { // for correct discard of ChildrenExist prop + IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, dstParent, context.SS, context.OnComplete); + } + // create tx state, do not catch shards right now TTxState& txState = context.SS->CreateTx(OperationId, TTxState::TxMoveTable, dstPath.Base()->PathId, srcPath.Base()->PathId); txState.State = TTxState::ConfigureParts; diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp index 84b10023b850..97e4e41036bb 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp @@ -25,6 +25,10 @@ void MarkSrcDropped(NIceDb::TNiceDb& db, srcPath.DomainInfo()->DecPathsInside(); IncParentDirAlterVersionWithRepublish(operationId, srcPath, context); + + if (srcPath.Base()->GetChildren().size() == 0 && !srcPath.IsDomain()) { // for correct discard of ChildrenExist prop + IncParentDirAlterVersionWithRepublishSafeWithUndo(operationId, srcPath, context.SS, context.OnComplete); + } } class TPropose: public TSubOperationState { @@ -521,6 +525,10 @@ class TMoveTableIndex: public TSubOperation { IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, dstPath, context.SS, context.OnComplete); IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, srcPath, context.SS, context.OnComplete); + if (dstParentPath.Base()->GetChildren().size() == 1 && !dstParentPath.IsDomain()) { // for correct discard of ChildrenExist prop + IncParentDirAlterVersionWithRepublishSafeWithUndo(OperationId, dstParentPath, context.SS, context.OnComplete); + } + context.OnComplete.ActivateTx(OperationId); SetState(NextState()); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_rmdir.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_rmdir.cpp index dce298dc57b6..0f86812dafc9 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_rmdir.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_rmdir.cpp @@ -160,6 +160,13 @@ class TRmDir: public TSubOperationBase { 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); + } + ++parentDir->DirAlterVersion; context.SS->PersistPathDirAlterVersion(db, parentDir); context.SS->ClearDescribePathCaches(parentDir); diff --git a/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp b/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp index cd40e51a8a99..0e4e511319c9 100644 --- a/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_path_describer.cpp @@ -176,6 +176,8 @@ void TPathDescriber::FillChildDescr(NKikimrSchemeOp::TDirEntry* descr, TPathElem descr->SetCreateStep(ui64(pathEl->StepCreated)); } + descr->SetChildrenExist(!pathEl->GetChildren().empty()); + if (pathEl->PathType == NKikimrSchemeOp::EPathTypePersQueueGroup) { auto it = Self->Topics.FindPtr(pathEl->PathId); Y_ABORT_UNLESS(it, "PersQueueGroup is not found");