Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shnikd committed Mar 26, 2024
1 parent 079f019 commit ef0b319
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ TVector<ISubOperation::TPtr> 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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void CheckTable(
bool checkExists = true)
{
TVector<ui64> 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;
Expand Down Expand Up @@ -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);
}
};

0 comments on commit ef0b319

Please sign in to comment.