Skip to content

Commit e9db455

Browse files
authored
Merge ec0e269 into 4fc63e1
2 parents 4fc63e1 + ec0e269 commit e9db455

File tree

8 files changed

+67
-7
lines changed

8 files changed

+67
-7
lines changed

ydb/core/grpc_services/rpc_rename_tables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class TRenameTablesRPC : public TRpcSchemeRequestActor<TRenameTablesRPC, TEvRena
3939
auto& transaction = *record.MutableTransaction();
4040

4141
if (req->tables().empty()) {
42-
Request_->RaiseIssue(NYql::TIssue("Emply move list"));
42+
Request_->RaiseIssue(NYql::TIssue("Empty move list"));
4343
return Reply(StatusIds::BAD_REQUEST, ctx);
4444
}
4545

ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@ TVector<ISubOperation::TPtr> CreateConsistentMoveIndex(TOperationId nextId, cons
599599
for(const auto& implTable : srcIndexPath.Base()->GetChildren()) {
600600
TString srcImplTableName = implTable.first;
601601
TPath srcImplTable = srcIndexPath.Child(srcImplTableName);
602+
if (srcImplTable.IsDeleted()) {
603+
continue;
604+
}
602605

603606
Y_ABORT_UNLESS(srcImplTable.Base()->PathId == implTable.second);
604607

ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ class TMoveTable: public TSubOperation {
632632

633633
if (dstParent.IsUnderOperation()) {
634634
dstPath = TPath::ResolveWithInactive(OperationId, dstPathStr, context.SS);
635+
dstParent = dstPath.Parent();
635636
}
636637

637638
{

ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ class TMoveTableIndex: public TSubOperation {
423423

424424
if (dstParentPath.IsUnderOperation()) {
425425
dstPath = TPath::ResolveWithInactive(OperationId, dstPathStr, context.SS);
426+
dstParentPath = dstPath.Parent();
426427
} else {
427428
Y_ABORT("NONO");
428429
}

ydb/core/tx/schemeshard/ut_helpers/helpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,11 +1828,11 @@ namespace NSchemeShardUT_Private {
18281828
}
18291829

18301830
void TestBuildVectorIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName,
1831-
const TString &src, const TString &name, TString column,
1831+
const TString &src, const TString &name, TVector<TString> columns,
18321832
Ydb::StatusIds::StatusCode expectedStatus)
18331833
{
18341834
TestBuildIndex(runtime, id, schemeShard, dbName, src, TBuildIndexConfig{
1835-
name, NKikimrSchemeOp::EIndexTypeGlobalVectorKmeansTree, {column}, {}
1835+
name, NKikimrSchemeOp::EIndexTypeGlobalVectorKmeansTree, columns, {}
18361836
}, expectedStatus);
18371837
}
18381838

ydb/core/tx/schemeshard/ut_helpers/helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ namespace NSchemeShardUT_Private {
397397
const TString &src, const TString& columnName, const Ydb::TypedValue& literal, Ydb::StatusIds::StatusCode expectedStatus);
398398
void TestBuildIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName, const TString &src, const TBuildIndexConfig &cfg, Ydb::StatusIds::StatusCode expectedStatus = Ydb::StatusIds::SUCCESS);
399399
void TestBuildIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName, const TString &src, const TString &name, TVector<TString> columns, Ydb::StatusIds::StatusCode expectedStatus = Ydb::StatusIds::SUCCESS);
400-
void TestBuildVectorIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName, const TString &src, const TString &name, TString column, Ydb::StatusIds::StatusCode expectedStatus = Ydb::StatusIds::SUCCESS);
400+
void TestBuildVectorIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName, const TString &src, const TString &name, TVector<TString> columns, Ydb::StatusIds::StatusCode expectedStatus = Ydb::StatusIds::SUCCESS);
401401
TEvIndexBuilder::TEvCancelRequest* CreateCancelBuildIndexRequest(const ui64 id, const TString& dbName, const ui64 buildIndexId);
402402
NKikimrIndexBuilder::TEvCancelResponse TestCancelBuildIndex(TTestActorRuntime& runtime, const ui64 id, const ui64 schemeShard, const TString &dbName, const ui64 buildIndexId, const TVector<Ydb::StatusIds::StatusCode>& expectedStatuses = {Ydb::StatusIds::SUCCESS});
403403
TEvIndexBuilder::TEvListRequest* ListBuildIndexRequest(const TString& dbName);

ydb/core/tx/schemeshard/ut_index_build/ut_vector_index_build.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(VectorIndexBuildTest) {
9393
{NLs::PathExist, NLs::IndexesCount(0), NLs::PathVersionEqual(3)});
9494

9595
ui64 buildIndexTx = ++txId;
96-
TestBuildVectorIndex(runtime, buildIndexTx, tenantSchemeShard, "/MyRoot/ServerLessDB", "/MyRoot/ServerLessDB/Table", "index1", "embedding");
96+
TestBuildVectorIndex(runtime, buildIndexTx, tenantSchemeShard, "/MyRoot/ServerLessDB", "/MyRoot/ServerLessDB/Table", "index1", {"embedding"});
9797
env.TestWaitNotification(runtime, buildIndexTx, tenantSchemeShard);
9898

9999
auto buildIndexOperations = TestListBuildIndex(runtime, tenantSchemeShard, "/MyRoot/ServerLessDB");
@@ -161,7 +161,7 @@ Y_UNIT_TEST_SUITE(VectorIndexBuildTest) {
161161

162162
WriteVectorTableRows(runtime, tenantSchemeShard, ++txId, "/MyRoot/ServerLessDB/Table", 0, 0, 200, {1, 5, 3, 4});
163163

164-
TestBuildVectorIndex(runtime, ++txId, tenantSchemeShard, "/MyRoot/ServerLessDB", "/MyRoot/ServerLessDB/Table", "index2", "embedding");
164+
TestBuildVectorIndex(runtime, ++txId, tenantSchemeShard, "/MyRoot/ServerLessDB", "/MyRoot/ServerLessDB/Table", "index2", {"embedding"});
165165
env.TestWaitNotification(runtime, txId, tenantSchemeShard);
166166

167167
TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/ServerLessDB/Table"),
@@ -423,7 +423,7 @@ Y_UNIT_TEST_SUITE(VectorIndexBuildTest) {
423423

424424
// Initiate index build:
425425
ui64 buildIndexTx = ++txId;
426-
TestBuildVectorIndex(runtime, buildIndexTx, tenantSchemeShard, "/MyRoot/CommonDB", "/MyRoot/CommonDB/Table", "index1", "embedding");
426+
TestBuildVectorIndex(runtime, buildIndexTx, tenantSchemeShard, "/MyRoot/CommonDB", "/MyRoot/CommonDB/Table", "index1", {"embedding"});
427427
{
428428
auto buildIndexOperations = TestListBuildIndex(runtime, tenantSchemeShard, "/MyRoot/CommonDB");
429429
UNIT_ASSERT_VALUES_EQUAL(buildIndexOperations.EntriesSize(), 1);

ydb/core/tx/schemeshard/ut_move/ut_move.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <ydb/core/tx/schemeshard/ut_helpers/helpers.h>
22

3+
#include <ydb/core/base/table_vector_index.h>
34
#include <ydb/core/kqp/ut/common/kqp_ut_common.h>
45
#include <ydb/core/tx/datashard/change_exchange.h>
56

@@ -9,6 +10,7 @@
910
using namespace NKikimr;
1011
using namespace NSchemeShard;
1112
using namespace NSchemeShardUT_Private;
13+
using namespace NKikimr::NTableIndex::NTableVectorKmeansTreeIndex;
1214

1315
void SetEnableMoveIndex(TTestActorRuntime &runtime, TTestEnv&, ui64 schemeShard, bool value) {
1416
auto request = MakeHolder<NConsole::TEvConsole::TEvConfigNotificationRequest>();
@@ -1022,6 +1024,59 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) {
10221024
NLs::IndexesCount(2)});
10231025
}
10241026

1027+
Y_UNIT_TEST(ReplaceVectorIndex) {
1028+
TTestBasicRuntime runtime;
1029+
TTestEnv env(runtime);
1030+
ui64 txId = 100;
1031+
1032+
TestCreateTable(runtime, ++txId, "/MyRoot", R"(
1033+
Name: "Table"
1034+
Columns { Name: "key" Type: "Uint32" }
1035+
Columns { Name: "embedding" Type: "String" }
1036+
Columns { Name: "prefix" Type: "Uint32" }
1037+
Columns { Name: "value" Type: "String" }
1038+
KeyColumnNames: ["key"]
1039+
)");
1040+
env.TestWaitNotification(runtime, txId);
1041+
1042+
TestBuildVectorIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index1", {"embedding"});
1043+
env.TestWaitNotification(runtime, txId);
1044+
1045+
TestBuildVectorIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index2", {"prefix", "embedding"});
1046+
env.TestWaitNotification(runtime, txId);
1047+
1048+
TestDescribeResult(DescribePath(runtime, "/MyRoot/Table"), {NLs::PathExist, NLs::PathVersionEqual(9), NLs::IndexesCount(2)});
1049+
1050+
TestMoveIndex(runtime, ++txId, "/MyRoot/Table", "index2", "index1", true);
1051+
env.TestWaitNotification(runtime, txId);
1052+
1053+
TestDescribeResult(DescribePath(runtime, "/MyRoot/Table/index2"), {NLs::PathNotExist});
1054+
TestDescribeResult(DescribePath(runtime, "/MyRoot/Table"), {NLs::PathExist, NLs::IndexesCount(1)});
1055+
TestDescribeResult(DescribePrivatePath(runtime, "/MyRoot/Table/index1/indexImplPrefixTable"),
1056+
{ NLs::PathExist, NLs::CheckColumns(PrefixTable, {"prefix", IdColumn}, {}, {"prefix", IdColumn}, true) });
1057+
TestDescribeResult(DescribePrivatePath(runtime, "/MyRoot/Table/index1/indexImplLevelTable"),
1058+
{ NLs::PathExist, NLs::CheckColumns(LevelTable, {ParentColumn, IdColumn, CentroidColumn}, {}, {ParentColumn, IdColumn}, true) });
1059+
TestDescribeResult(DescribePrivatePath(runtime, "/MyRoot/Table/index1/indexImplPostingTable"),
1060+
{ NLs::PathExist, NLs::CheckColumns(PostingTable, {ParentColumn, "key"}, {}, {ParentColumn, "key"}, true) });
1061+
1062+
// Replace again - it previously crashed here when Dec/IncAliveChildren were incorrect
1063+
1064+
TestBuildVectorIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index2", {"embedding"});
1065+
env.TestWaitNotification(runtime, txId);
1066+
1067+
TestMoveIndex(runtime, ++txId, "/MyRoot/Table", "index2", "index1", true);
1068+
env.TestWaitNotification(runtime, txId);
1069+
1070+
TestDescribeResult(DescribePath(runtime, "/MyRoot/Table/index2"), {NLs::PathNotExist});
1071+
TestDescribeResult(DescribePath(runtime, "/MyRoot/Table"), {NLs::PathExist, NLs::IndexesCount(1)});
1072+
TestDescribeResult(DescribePrivatePath(runtime, "/MyRoot/Table/index1/indexImplPrefixTable"), {NLs::PathNotExist});
1073+
TestDescribeResult(DescribePrivatePath(runtime, "/MyRoot/Table/index1/indexImplLevelTable"),
1074+
{ NLs::PathExist, NLs::CheckColumns(LevelTable, {ParentColumn, IdColumn, CentroidColumn}, {}, {ParentColumn, IdColumn}, true) });
1075+
TestDescribeResult(DescribePrivatePath(runtime, "/MyRoot/Table/index1/indexImplPostingTable"),
1076+
{ NLs::PathExist, NLs::CheckColumns(PostingTable, {ParentColumn, "key"}, {}, {ParentColumn, "key"}, true) });
1077+
}
1078+
1079+
10251080
Y_UNIT_TEST(AsyncIndexWithSyncInFly) {
10261081
TTestBasicRuntime runtime;
10271082
TTestEnv env(runtime);

0 commit comments

Comments
 (0)