From 70d3ccd75d66ce8afc8de66c8ee1a7d02ed3094e Mon Sep 17 00:00:00 2001 From: Valerii Mironov Date: Thu, 19 Sep 2024 09:32:37 +0000 Subject: [PATCH] WIP --- ydb/core/protos/flat_scheme_op.proto | 2 +- ydb/core/protos/flat_tx_scheme.proto | 2 +- ...hemeshard__operation_apply_build_index.cpp | 20 ++++++++++--- ...emeshard__operation_create_build_index.cpp | 1 + .../schemeshard_build_index__progress.cpp | 8 ----- .../tx/schemeshard/schemeshard_info_types.h | 29 +++++++++---------- .../tx/schemeshard/schemeshard_tx_infly.h | 8 +++++ ydb/core/tx/tx_proxy/schemereq.cpp | 4 ++- 8 files changed, 44 insertions(+), 30 deletions(-) diff --git a/ydb/core/protos/flat_scheme_op.proto b/ydb/core/protos/flat_scheme_op.proto index c5e25cdd5717..3d695289335d 100644 --- a/ydb/core/protos/flat_scheme_op.proto +++ b/ydb/core/protos/flat_scheme_op.proto @@ -33,7 +33,7 @@ message TMkDir { enum EDropWaitPolicy { EDropFailOnChanges = 0; - EDropAbortChanges = 1; //depricated + EDropAbortChanges = 1; //deprecated EDropWaitChanges = 2; } diff --git a/ydb/core/protos/flat_tx_scheme.proto b/ydb/core/protos/flat_tx_scheme.proto index 84026ae9f41d..575eab171f49 100644 --- a/ydb/core/protos/flat_tx_scheme.proto +++ b/ydb/core/protos/flat_tx_scheme.proto @@ -53,7 +53,7 @@ message TEvModifySchemeTransaction { optional uint64 TxId = 2; optional uint64 TabletId = 3; optional string Owner = 5; - optional bool FailOnExist = 6; // depricated, TModifyScheme.FailOnExist is recomended + optional bool FailOnExist = 6; // deprecated, TModifyScheme.FailOnExist is recomended optional string UserToken = 7 [(Ydb.sensitive) = true]; // serialized NACLib::TUserToken optional string PeerName = 8; } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_apply_build_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_apply_build_index.cpp index f78e4bc21e3f..5269cc30cdc0 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_apply_build_index.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_apply_build_index.cpp @@ -28,7 +28,7 @@ ISubOperation::TPtr FinalizeIndexImplTable(TOperationContext& context, const TPa return CreateFinalizeBuildIndexImplTable(partId, transaction); } -ISubOperation::TPtr DropIndexImplTable(TOperationContext& /*context*/, const TPath& index, const TOperationId& nextId, const TOperationId& partId, const TString& name, const TPathId& pathId) { +ISubOperation::TPtr DropIndexImplTable(const TPath& index, const TOperationId& nextId, const TOperationId& partId, const TString& name, const TPathId& pathId, bool& rejected) { TPath implTable = index.Child(name); Y_ABORT_UNLESS(implTable->PathId == pathId); Y_ABORT_UNLESS(implTable.LeafName() == name); @@ -41,8 +41,10 @@ ISubOperation::TPtr DropIndexImplTable(TOperationContext& /*context*/, const TPa .NotUnderDeleting() .NotUnderOperation(); if (!checks) { - return {CreateReject(nextId, checks.GetStatus(), checks.GetError())}; + rejected = true; + return CreateReject(nextId, checks.GetStatus(), checks.GetError()); } + rejected = false; auto transaction = TransactionTemplate(index.PathString(), NKikimrSchemeOp::EOperationType::ESchemeOpDropTable); auto operation = transaction.MutableDrop(); operation->SetName(name); @@ -93,7 +95,12 @@ TVector ApplyBuildIndex(TOperationId nextId, const TTxTrans const auto& indexImplTableName = indexChildItems.first; const auto partId = NextPartId(nextId, result); if (NTableIndex::IsTmpImplTable(indexImplTableName)) { - result.push_back(DropIndexImplTable(context, index, nextId, partId, indexImplTableName, indexChildItems.second)); + bool rejected = false; + auto op = DropIndexImplTable(index, nextId, partId, indexImplTableName, indexChildItems.second, rejected); + if (rejected) { + return {std::move(op)}; + } + result.push_back(std::move(op)); } else { result.push_back(FinalizeIndexImplTable(context, index, partId, indexImplTableName, indexChildItems.second)); } @@ -143,7 +150,12 @@ TVector CancelBuildIndex(TOperationId nextId, const TTxTran Y_ABORT_UNLESS(index.Base()->GetChildren().size() >= 1); for (auto& indexChildItems : index.Base()->GetChildren()) { const auto partId = NextPartId(nextId, result); - result.push_back(DropIndexImplTable(context, index, nextId, partId, indexChildItems.first, indexChildItems.second)); + bool rejected = false; + auto op = DropIndexImplTable(index, nextId, partId, indexChildItems.first, indexChildItems.second, rejected); + if (rejected) { + return {std::move(op)}; + } + result.push_back(std::move(op)); } } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_build_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_build_index.cpp index b346d48d9bc7..19bacf412ed9 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_build_index.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_build_index.cpp @@ -59,6 +59,7 @@ TVector CreateBuildIndex(TOperationId opId, const TTxTransa .NotResolved(); } + // TODO(mbkkt) less than necessary for vector index checks .IsValidLeafName() .PathsLimit(2) // index and impl-table diff --git a/ydb/core/tx/schemeshard/schemeshard_build_index__progress.cpp b/ydb/core/tx/schemeshard/schemeshard_build_index__progress.cpp index 0277b09cbfd3..8e64e4b2fb32 100644 --- a/ydb/core/tx/schemeshard/schemeshard_build_index__progress.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_build_index__progress.cpp @@ -232,14 +232,6 @@ THolder LockPropose( modifyScheme.SetWorkingDir(path.Parent().PathString()); modifyScheme.MutableLockConfig()->SetName(path.LeafName()); - if (buildInfo.IsBuildIndex()) { - buildInfo.SerializeToProto(ss, modifyScheme.MutableInitiateIndexBuild()); - } else if (buildInfo.IsBuildColumns()) { - buildInfo.SerializeToProto(ss, modifyScheme.MutableInitiateColumnBuild()); - } else { - Y_ABORT("Unknown operation kind while building LockPropose"); - } - return propose; } diff --git a/ydb/core/tx/schemeshard/schemeshard_info_types.h b/ydb/core/tx/schemeshard/schemeshard_info_types.h index 0ddcdcbd2caa..811044388103 100644 --- a/ydb/core/tx/schemeshard/schemeshard_info_types.h +++ b/ydb/core/tx/schemeshard/schemeshard_info_types.h @@ -2988,30 +2988,29 @@ struct TIndexBuildInfo: public TSimpleRefCount { bool CancelRequested = false; - TTxId AlterMainTableTxId = TTxId(); - NKikimrScheme::EStatus AlterMainTableTxStatus = NKikimrScheme::StatusSuccess; bool AlterMainTableTxDone = false; - - TTxId LockTxId = TTxId(); - NKikimrScheme::EStatus LockTxStatus = NKikimrScheme::StatusSuccess; bool LockTxDone = false; - - TTxId InitiateTxId = TTxId(); - NKikimrScheme::EStatus InitiateTxStatus = NKikimrScheme::StatusSuccess; bool InitiateTxDone = false; + bool ApplyTxDone = false; + bool UnlockTxDone = false; - TStepId SnapshotStep; - TTxId SnapshotTxId; + bool BillingEventIsScheduled = false; + TTxId AlterMainTableTxId = TTxId(); + TTxId LockTxId = TTxId(); + TTxId InitiateTxId = TTxId(); TTxId ApplyTxId = TTxId(); - NKikimrScheme::EStatus ApplyTxStatus = NKikimrScheme::StatusSuccess; - bool ApplyTxDone = false; - TTxId UnlockTxId = TTxId(); + + NKikimrScheme::EStatus AlterMainTableTxStatus = NKikimrScheme::StatusSuccess; + NKikimrScheme::EStatus LockTxStatus = NKikimrScheme::StatusSuccess; + NKikimrScheme::EStatus InitiateTxStatus = NKikimrScheme::StatusSuccess; + NKikimrScheme::EStatus ApplyTxStatus = NKikimrScheme::StatusSuccess; NKikimrScheme::EStatus UnlockTxStatus = NKikimrScheme::StatusSuccess; - bool UnlockTxDone = false; - bool BillingEventIsScheduled = false; + TStepId SnapshotStep; + TTxId SnapshotTxId; + TDuration ReBillPeriod = TDuration::Seconds(10); struct TShardStatus { diff --git a/ydb/core/tx/schemeshard/schemeshard_tx_infly.h b/ydb/core/tx/schemeshard/schemeshard_tx_infly.h index aab23b08df34..1d78a1493abc 100644 --- a/ydb/core/tx/schemeshard/schemeshard_tx_infly.h +++ b/ydb/core/tx/schemeshard/schemeshard_tx_infly.h @@ -739,6 +739,14 @@ struct TTxState { case NKikimrSchemeOp::ESchemeOpCreateResourcePool: return TxCreateResourcePool; case NKikimrSchemeOp::ESchemeOpAlterResourcePool: return TxAlterResourcePool; case NKikimrSchemeOp::ESchemeOpDropResourcePool: return TxDropResourcePool; + case NKikimrSchemeOp::ESchemeOpAlterExtSubDomainCreateHive: return TxInvalid; + case NKikimrSchemeOp::ESchemeOpDropExternalTable: return TxInvalid; + case NKikimrSchemeOp::ESchemeOpDropExternalDataSource: return TxInvalid; + case NKikimrSchemeOp::ESchemeOpCreateColumnBuild: return TxInvalid; + case NKikimrSchemeOp::ESchemeOpCreateContinuousBackup: return TxInvalid; + case NKikimrSchemeOp::ESchemeOpAlterContinuousBackup: return TxInvalid; + case NKikimrSchemeOp::ESchemeOpDropContinuousBackup: return TxInvalid; + case NKikimrSchemeOp::ESchemeOpRestoreIncrementalBackup: return TxInvalid; default: return TxInvalid; } } diff --git a/ydb/core/tx/tx_proxy/schemereq.cpp b/ydb/core/tx/tx_proxy/schemereq.cpp index 99fa357a3fb2..851bbd97ac1f 100644 --- a/ydb/core/tx/tx_proxy/schemereq.cpp +++ b/ydb/core/tx/tx_proxy/schemereq.cpp @@ -213,8 +213,10 @@ struct TBaseSchemeReq: public TActorBootstrapped { return *modifyScheme.MutableUpgradeSubDomain()->MutableName(); case NKikimrSchemeOp::ESchemeOpCreateColumnBuild: + Y_ABORT("no implementation for ESchemeOpCreateColumnBuild"); + case NKikimrSchemeOp::ESchemeOpCreateIndexBuild: - Y_ABORT("no implementation for ESchemeOpCreateIndexBuild/ESchemeOpCreateColumnBuild"); + Y_ABORT("no implementation for ESchemeOpCreateIndexBuild"); case NKikimrSchemeOp::ESchemeOpInitiateBuildIndexMainTable: Y_ABORT("no implementation for ESchemeOpInitiateBuildIndexMainTable");