Skip to content

Commit 07fc231

Browse files
authored
Add reinit step for build vector index (#9176)
1 parent 06f4e89 commit 07fc231

15 files changed

+307
-70
lines changed

ydb/core/protos/flat_scheme_op.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ message TMkDir {
3434

3535
enum EDropWaitPolicy {
3636
EDropFailOnChanges = 0;
37-
EDropAbortChanges = 1; //depricated
37+
EDropAbortChanges = 1; //deprecated
3838
EDropWaitChanges = 2;
3939
}
4040

ydb/core/protos/flat_tx_scheme.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ message TEvModifySchemeTransaction {
5353
optional uint64 TxId = 2;
5454
optional uint64 TabletId = 3;
5555
optional string Owner = 5;
56-
optional bool FailOnExist = 6; // depricated, TModifyScheme.FailOnExist is recomended
56+
optional bool FailOnExist = 6; // deprecated, TModifyScheme.FailOnExist is recomended
5757
optional string UserToken = 7 [(Ydb.sensitive) = true]; // serialized NACLib::TUserToken
5858
optional string PeerName = 8;
5959
}

ydb/core/tx/schemeshard/schemeshard__operation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ TVector<ISubOperation::TPtr> TOperation::ConstructParts(const TTxTransaction& tx
13351335
Y_ABORT("multipart operations are handled before, also they require transaction details");
13361336

13371337
case NKikimrSchemeOp::EOperationType::ESchemeOpInitiateBuildIndexImplTable:
1338-
Y_ABORT("multipart operations are handled before, also they require transaction details");
1338+
return {CreateInitializeBuildIndexImplTable(NextPartId(), tx)};
13391339
case NKikimrSchemeOp::EOperationType::ESchemeOpFinalizeBuildIndexImplTable:
13401340
Y_ABORT("multipart operations are handled before, also they require transaction details");
13411341

ydb/core/tx/schemeshard/schemeshard__operation_apply_build_index.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ISubOperation::TPtr FinalizeIndexImplTable(TOperationContext& context, const TPa
2828
return CreateFinalizeBuildIndexImplTable(partId, transaction);
2929
}
3030

31-
ISubOperation::TPtr DropIndexImplTable(TOperationContext& /*context*/, const TPath& index, const TOperationId& nextId, const TOperationId& partId, const TString& name, const TPathId& pathId) {
31+
ISubOperation::TPtr DropIndexImplTable(const TPath& index, const TOperationId& nextId, const TOperationId& partId, const TString& name, const TPathId& pathId, bool& rejected) {
3232
TPath implTable = index.Child(name);
3333
Y_ABORT_UNLESS(implTable->PathId == pathId);
3434
Y_ABORT_UNLESS(implTable.LeafName() == name);
@@ -41,8 +41,10 @@ ISubOperation::TPtr DropIndexImplTable(TOperationContext& /*context*/, const TPa
4141
.NotUnderDeleting()
4242
.NotUnderOperation();
4343
if (!checks) {
44-
return {CreateReject(nextId, checks.GetStatus(), checks.GetError())};
44+
rejected = true;
45+
return CreateReject(nextId, checks.GetStatus(), checks.GetError());
4546
}
47+
rejected = false;
4648
auto transaction = TransactionTemplate(index.PathString(), NKikimrSchemeOp::EOperationType::ESchemeOpDropTable);
4749
auto operation = transaction.MutableDrop();
4850
operation->SetName(name);
@@ -93,7 +95,12 @@ TVector<ISubOperation::TPtr> ApplyBuildIndex(TOperationId nextId, const TTxTrans
9395
const auto& indexImplTableName = indexChildItems.first;
9496
const auto partId = NextPartId(nextId, result);
9597
if (NTableIndex::IsTmpImplTable(indexImplTableName)) {
96-
result.push_back(DropIndexImplTable(context, index, nextId, partId, indexImplTableName, indexChildItems.second));
98+
bool rejected = false;
99+
auto op = DropIndexImplTable(index, nextId, partId, indexImplTableName, indexChildItems.second, rejected);
100+
if (rejected) {
101+
return {std::move(op)};
102+
}
103+
result.push_back(std::move(op));
97104
} else {
98105
result.push_back(FinalizeIndexImplTable(context, index, partId, indexImplTableName, indexChildItems.second));
99106
}
@@ -143,7 +150,12 @@ TVector<ISubOperation::TPtr> CancelBuildIndex(TOperationId nextId, const TTxTran
143150
Y_ABORT_UNLESS(index.Base()->GetChildren().size() >= 1);
144151
for (auto& indexChildItems : index.Base()->GetChildren()) {
145152
const auto partId = NextPartId(nextId, result);
146-
result.push_back(DropIndexImplTable(context, index, nextId, partId, indexChildItems.first, indexChildItems.second));
153+
bool rejected = false;
154+
auto op = DropIndexImplTable(index, nextId, partId, indexChildItems.first, indexChildItems.second, rejected);
155+
if (rejected) {
156+
return {std::move(op)};
157+
}
158+
result.push_back(std::move(op));
147159
}
148160
}
149161

ydb/core/tx/schemeshard/schemeshard__operation_create_build_index.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ TVector<ISubOperation::TPtr> CreateBuildIndex(TOperationId opId, const TTxTransa
5959
.NotResolved();
6060
}
6161

62+
// TODO(mbkkt) less than necessary for vector index
6263
checks
6364
.IsValidLeafName()
6465
.PathsLimit(2) // index and impl-table

ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,14 @@ class TCreateTable: public TSubOperation {
447447

448448
if (checks) {
449449
if (parentPath.Base()->IsTableIndex()) {
450-
checks.IsInsideTableIndexPath()
451-
.IsUnderCreating(NKikimrScheme::StatusNameConflict)
452-
.IsUnderTheSameOperation(OperationId.GetTxId()); //allow only as part of creating base table
450+
checks.IsInsideTableIndexPath();
451+
// Not tmp index impl tables can be created only as part of create index
452+
// tmp index impl tables created multiple times during index construction
453+
if (!NTableIndex::IsTmpImplTable(name)) {
454+
checks
455+
.IsUnderCreating(NKikimrScheme::StatusNameConflict)
456+
.IsUnderTheSameOperation(OperationId.GetTxId());
457+
}
453458
} else if (!Transaction.GetAllowAccessToPrivatePaths()) {
454459
checks.IsCommonSensePath()
455460
.IsLikeDirectory();

ydb/core/tx/schemeshard/schemeshard__operation_drop_indexed_table.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,10 @@ TVector<ISubOperation::TPtr> CreateDropIndexedTable(TOperationId nextId, const T
396396
auto dropOperation = tx.GetDrop();
397397

398398
const TString parentPathStr = tx.GetWorkingDir();
399-
const TString name = dropOperation.GetName();
400399

401400
TPath table = dropOperation.HasId()
402401
? TPath::Init(TPathId(context.SS->TabletID(), dropOperation.GetId()), context.SS)
403-
: TPath::Resolve(parentPathStr, context.SS).Dive(name);
402+
: TPath::Resolve(parentPathStr, context.SS).Dive(dropOperation.GetName());
404403

405404
{
406405
TPath::TChecker checks = table.Check();
@@ -425,8 +424,10 @@ TVector<ISubOperation::TPtr> CreateDropIndexedTable(TOperationId nextId, const T
425424
checks
426425
.IsTable()
427426
.NotUnderDeleting()
428-
.NotUnderOperation()
429-
.IsCommonSensePath();
427+
.NotUnderOperation();
428+
if (!table.Parent()->IsTableIndex() || !NTableIndex::IsTmpImplTable(table.LeafName())) {
429+
checks.IsCommonSensePath();
430+
}
430431
}
431432
}
432433

ydb/core/tx/schemeshard/schemeshard__operation_drop_table.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ class TDropTable: public TSubOperation {
532532
.IsTableIndex()
533533
.IsInsideTableIndexPath();
534534
// Not tmp index impl tables can be dropped only as part of drop index
535+
// tmp index impl tables dropped multiple times during index construction
535536
if (!NTableIndex::IsTmpImplTable(name)) {
536537
checks
537538
.IsUnderDeleting()

0 commit comments

Comments
 (0)