@@ -1332,4 +1332,108 @@ Y_UNIT_TEST_SUITE(VectorIndexBuildTest) {
1332
1332
UNIT_ASSERT_STRING_CONTAINS (buildIndexOperation.DebugString (), " Processed: UploadRows: 0 UploadBytes: 0 ReadRows: 0 ReadBytes: 0" );
1333
1333
}
1334
1334
}
1335
+
1336
+ Y_UNIT_TEST (UnknownState) {
1337
+ TTestBasicRuntime runtime;
1338
+ TTestEnv env (runtime);
1339
+ ui64 txId = 100 ;
1340
+
1341
+ runtime.SetLogPriority (NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE);
1342
+ runtime.SetLogPriority (NKikimrServices::BUILD_INDEX, NLog::PRI_TRACE);
1343
+
1344
+ TestCreateTable (runtime, ++txId, " /MyRoot" , R"(
1345
+ Name: "vectors"
1346
+ Columns { Name: "id" Type: "Uint64" }
1347
+ Columns { Name: "embedding" Type: "String" }
1348
+ KeyColumnNames: [ "id" ]
1349
+ )" );
1350
+ env.TestWaitNotification (runtime, txId);
1351
+
1352
+ NYdb::NTable::TGlobalIndexSettings globalIndexSettings;
1353
+
1354
+ std::unique_ptr<NYdb::NTable::TKMeansTreeSettings> kmeansTreeSettings;
1355
+ {
1356
+ Ydb::Table::KMeansTreeSettings proto;
1357
+ UNIT_ASSERT (google::protobuf::TextFormat::ParseFromString (R"(
1358
+ settings {
1359
+ metric: DISTANCE_COSINE
1360
+ vector_type: VECTOR_TYPE_FLOAT
1361
+ vector_dimension: 1024
1362
+ }
1363
+ levels: 5
1364
+ clusters: 4
1365
+ )" , &proto));
1366
+ using T = NYdb::NTable::TKMeansTreeSettings;
1367
+ kmeansTreeSettings = std::make_unique<T>(T::FromProto (proto));
1368
+ }
1369
+
1370
+ TBlockEvents<TEvDataShard::TEvLocalKMeansRequest> kmeansBlocker (runtime, [&](const auto & ) {
1371
+ return true ;
1372
+ });
1373
+
1374
+ const ui64 buildIndexTx = ++txId;
1375
+ AsyncBuildVectorIndex (runtime, buildIndexTx, TTestTxConfig::SchemeShard, " /MyRoot" , " /MyRoot/vectors" , " index1" , {" embedding" });
1376
+
1377
+ runtime.WaitFor (" LocalKMeansRequest" , [&]{ return kmeansBlocker.size (); });
1378
+
1379
+ {
1380
+ // set unknown State value
1381
+ TString writeQuery = Sprintf (R"(
1382
+ (
1383
+ (let key '( '('Id (Uint64 '%lu)) ) )
1384
+ (let value '('('State (Uint32 '999999)) ) )
1385
+ (return (AsList (UpdateRow 'IndexBuild key value) ))
1386
+ )
1387
+ )" , buildIndexTx);
1388
+ NKikimrMiniKQL::TResult result;
1389
+ TString err;
1390
+ NKikimrProto::EReplyStatus status = LocalMiniKQL (runtime, TTestTxConfig::SchemeShard, writeQuery, result, err);
1391
+ UNIT_ASSERT_VALUES_EQUAL_C (status, NKikimrProto::EReplyStatus::OK, err);
1392
+ }
1393
+
1394
+ Cerr << " ... rebooting scheme shard" << Endl;
1395
+ RebootTablet (runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor ());
1396
+ kmeansBlocker.Stop ().Unblock ();
1397
+
1398
+ {
1399
+ auto buildIndexOperation = TestGetBuildIndex (runtime, TTestTxConfig::SchemeShard, " /MyRoot" , buildIndexTx);
1400
+ auto buildIndexHtml = TestGetBuildIndexHtml (runtime, TTestTxConfig::SchemeShard, buildIndexTx);
1401
+ UNIT_ASSERT_VALUES_EQUAL_C (
1402
+ buildIndexOperation.GetIndexBuild ().GetState (), Ydb::Table::IndexBuildState::STATE_UNSPECIFIED,
1403
+ buildIndexOperation.DebugString ()
1404
+ );
1405
+ UNIT_ASSERT_STRING_CONTAINS (buildIndexOperation.DebugString (), " Unknown build state" );
1406
+ UNIT_ASSERT_STRING_CONTAINS (buildIndexHtml, " IsBroken: 1" );
1407
+ }
1408
+
1409
+ {
1410
+ // set a known State but unknown BuildKind
1411
+ TString writeQuery = Sprintf (R"(
1412
+ (
1413
+ (let key '( '('Id (Uint64 '%lu)) ) )
1414
+ (let value '('('State (Uint32 '40)) '('BuildKind (Uint32 '999999)) ) )
1415
+ (return (AsList (UpdateRow 'IndexBuild key value) ))
1416
+ )
1417
+ )" , buildIndexTx);
1418
+ NKikimrMiniKQL::TResult result;
1419
+ TString err;
1420
+ NKikimrProto::EReplyStatus status = LocalMiniKQL (runtime, TTestTxConfig::SchemeShard, writeQuery, result, err);
1421
+ UNIT_ASSERT_VALUES_EQUAL_C (status, NKikimrProto::EReplyStatus::OK, err);
1422
+ }
1423
+
1424
+ Cerr << " ... rebooting scheme shard" << Endl;
1425
+ RebootTablet (runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor ());
1426
+
1427
+ {
1428
+ auto buildIndexOperation = TestGetBuildIndex (runtime, TTestTxConfig::SchemeShard, " /MyRoot" , buildIndexTx);
1429
+ auto buildIndexHtml = TestGetBuildIndexHtml (runtime, TTestTxConfig::SchemeShard, buildIndexTx);
1430
+ UNIT_ASSERT_VALUES_EQUAL_C (
1431
+ buildIndexOperation.GetIndexBuild ().GetState (), Ydb::Table::IndexBuildState::STATE_TRANSFERING_DATA,
1432
+ buildIndexOperation.DebugString ()
1433
+ );
1434
+ UNIT_ASSERT_STRING_CONTAINS (buildIndexOperation.DebugString (), " Unknown build kind" );
1435
+ UNIT_ASSERT_STRING_CONTAINS (buildIndexHtml, " IsBroken: 1" );
1436
+ }
1437
+ }
1438
+
1335
1439
}
0 commit comments