diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_indexed_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_indexed_table.cpp index f3e87356a746..214f9db30b19 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_indexed_table.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_indexed_table.cpp @@ -199,6 +199,15 @@ TVector CreateIndexedTable(TOperationId nextId, const TTxTr scheme.MutableAlterUserAttributes()->CopyFrom(tx.GetAlterUserAttributes()); } + if (baseTableDescription.HasTemporary() && baseTableDescription.GetTemporary()) { + if (!context.SS->EnableTempTables) { + TString msg = TStringBuilder() << "It is not allowed to create temp table: " + << baseTableDescription.GetName(); + return {CreateReject(nextId, NKikimrScheme::EStatus::StatusPreconditionFailed, msg)}; + } + *scheme.MutableTempTableOwnerActorId() = tx.GetTempTableOwnerActorId(); + } + result.push_back(CreateNewTable(NextPartId(nextId, result), scheme, sequences)); } diff --git a/ydb/core/tx/schemeshard/ut_background_cleaning/ut_background_cleaning.cpp b/ydb/core/tx/schemeshard/ut_background_cleaning/ut_background_cleaning.cpp index 74846466524f..1e3584854f6c 100644 --- a/ydb/core/tx/schemeshard/ut_background_cleaning/ut_background_cleaning.cpp +++ b/ydb/core/tx/schemeshard/ut_background_cleaning/ut_background_cleaning.cpp @@ -99,7 +99,7 @@ void CheckTable( bool checkExists = true) { TVector shards; - auto description = DescribePrivatePath(runtime, schemeshardId, fullPath, true, true); + auto description = DescribePrivatePath(runtime, schemeshardId, fullPath, true, true); if (!checkExists) { UNIT_ASSERT(description.GetStatus() == NKikimrScheme::EStatus::StatusPathDoesNotExist); return; @@ -377,4 +377,50 @@ Y_UNIT_TEST_SUITE(TSchemeshardBackgroundCleaningTest) { TestLs(runtime, "/MyRoot/TempTable/ValueIndex", TDescribeOptionsBuilder().SetShowPrivateTable(true), NLs::PathNotExist); } + + Y_UNIT_TEST(SchemeshardBackgroundCleaningTestSimpleCleanIndex) { + TTestBasicRuntime runtime(3); + TTestEnv env(runtime); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); + + SetBackgroundCleaning(runtime, env, TTestTxConfig::SchemeShard); + env.SimulateSleep(runtime, TDuration::Seconds(30)); + + auto ownerActorId = runtime.AllocateEdgeActor(1); + + ui64 txId = 100; + TestCreateTempTable(runtime, txId, "/MyRoot", R"( + TableDescription { + Name: "TempTable" + Columns { Name: "key" Type: "Uint64" } + Columns { Name: "value" Type: "Utf8" } + KeyColumnNames: ["key"] + } + IndexDescription { + Name: "ValueIndex" + KeyColumnNames: ["value"] + } + )", ownerActorId, { NKikimrScheme::StatusAccepted }, 1); + + env.TestWaitNotification(runtime, txId); + + CheckTable(runtime, "/MyRoot/TempTable"); + + TestLs(runtime, "/MyRoot/TempTable/ValueIndex", TDescribeOptionsBuilder().SetShowPrivateTable(true), NLs::PathExist); + + const TActorId proxy = runtime.GetInterconnectProxy(1, 0); + runtime.Send(new IEventHandle(proxy, TActorId(), new TEvInterconnect::TEvDisconnect(), 0, 0), 1, true); + TDispatchOptions options; + options.FinalEvents.emplace_back(TEvInterconnect::EvNodeDisconnected); + runtime.DispatchEvents(options); + + env.SimulateSleep(runtime, TDuration::Seconds(50)); + + CheckTable(runtime, "/MyRoot/TempTable", TTestTxConfig::SchemeShard, false); + + TestLs(runtime, "/MyRoot/TempTable/ValueIndex", TDescribeOptionsBuilder().SetShowPrivateTable(true), NLs::PathNotExist); + } };