Skip to content

separate schema caches by tenant (#17729) #18110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ namespace NKikimr::NColumnShard {
}

void SetupSchema(TTestBasicRuntime& runtime, TActorId& sender, const TString& txBody, const NOlap::TSnapshot& snapshot, bool succeed) {

auto controller = NYDBTest::TControllers::GetControllerAs<NYDBTest::NColumnShard::TController>();
while (controller && !controller->IsActiveTablet(TTestTxConfig::TxTablet0)) {
runtime.SimulateSleep(TDuration::Seconds(1));
Expand Down Expand Up @@ -477,7 +476,6 @@ namespace NKikimr::NColumnShard {
SetupSchema(runtime, sender, txBody, snapshot, true);
}


void PrepareTablet(TTestBasicRuntime& runtime, const ui64 tableId, const std::vector<NArrow::NTest::TTestColumn>& schema, const ui32 keySize) {
using namespace NTxUT;
CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::ColumnShard), &CreateColumnShard);
Expand Down
24 changes: 20 additions & 4 deletions ydb/core/tx/columnshard/test_helper/columnshard_ut_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,17 @@ struct TTestSchema {
NKikimrTxColumnShard::TSchemaTxBody tx;
auto* table = tx.MutableInitShard()->AddTables();
tx.MutableInitShard()->SetOwnerPath(ownerPath);
tx.MutableInitShard()->SetOwnerPathId(pathId);
table->SetPathId(pathId);

InitSchema(columns, pk, specials, table->MutableSchema());
{ // preset
auto* preset = table->MutableSchemaPreset();
preset->SetId(1);
preset->SetName("default");

// schema
InitSchema(columns, pk, specials, preset->MutableSchema());
}
InitTiersAndTtl(specials, table->MutableTtlSettings());

Cerr << "CreateInitShard: " << tx << "\n";
Expand All @@ -308,9 +316,11 @@ struct TTestSchema {
}

static TString CreateStandaloneTableTxBody(ui64 pathId, const std::vector<NArrow::NTest::TTestColumn>& columns,
const std::vector<NArrow::NTest::TTestColumn>& pk, const TTableSpecials& specials = {}) {
const std::vector<NArrow::NTest::TTestColumn>& pk, const TTableSpecials& specials = {}, const TString& path = "/Root/olap") {
NKikimrTxColumnShard::TSchemaTxBody tx;
auto* table = tx.MutableEnsureTables()->AddTables();
auto* table = tx.MutableInitShard()->AddTables();
tx.MutableInitShard()->SetOwnerPath(path);
tx.MutableInitShard()->SetOwnerPathId(pathId);
table->SetPathId(pathId);

InitSchema(columns, pk, specials, table->MutableSchema());
Expand All @@ -323,12 +333,18 @@ struct TTestSchema {
return out;
}

static TString AlterTableTxBody(ui64 pathId, ui32 version, const TTableSpecials& specials) {
static TString AlterTableTxBody(ui64 pathId, ui32 version, const std::vector<NArrow::NTest::TTestColumn>& columns,
const std::vector<NArrow::NTest::TTestColumn>& pk, const TTableSpecials& specials) {
NKikimrTxColumnShard::TSchemaTxBody tx;
auto* table = tx.MutableAlterTable();
table->SetPathId(pathId);
tx.MutableSeqNo()->SetRound(version);

auto* preset = table->MutableSchemaPreset();
preset->SetId(1);
preset->SetName("default");
InitSchema(columns, pk, specials, preset->MutableSchema());

auto* ttlSettings = table->MutableTtlSettings();
if (!InitTiersAndTtl(specials, ttlSettings)) {
ttlSettings->MutableDisabled();
Expand Down
21 changes: 10 additions & 11 deletions ydb/core/tx/columnshard/ut_schema/ut_columnshard_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {},
spec.EvictAfter = TDuration::Seconds(ttlSec);
}
SetupSchema(runtime, sender,
TTestSchema::AlterTableTxBody(tableId, 2, spec),
TTestSchema::AlterTableTxBody(tableId, 2, ydbSchema, testYdbPk, spec),
NOlap::TSnapshot(++planStep, ++txId));
if (spec.HasTiers()) {
csControllerGuard->OverrideTierConfigs(runtime, sender, TTestSchema::BuildSnapshot(spec));
Expand All @@ -314,9 +314,8 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {},
}

// Disable TTL
auto ok = ProposeSchemaTx(runtime, sender,
TTestSchema::AlterTableTxBody(tableId, 3, TTestSchema::TTableSpecials()),
NOlap::TSnapshot(++planStep, ++txId));
auto ok = ProposeSchemaTx(runtime, sender, TTestSchema::AlterTableTxBody(tableId, 3, ydbSchema, testYdbPk, TTestSchema::TTableSpecials()),
NOlap::TSnapshot(++planStep, ++txId));
UNIT_ASSERT(ok);
if (spec.HasTiers()) {
csControllerGuard->OverrideTierConfigs(runtime, sender, TTestSchema::BuildSnapshot(TTestSchema::TTableSpecials()));
Expand Down Expand Up @@ -630,8 +629,7 @@ std::vector<std::pair<ui32, ui64>> TestTiers(bool reboots, const std::vector<TSt
}
if (i) {
const ui32 version = 2 * i + 1;
SetupSchema(runtime, sender,
TTestSchema::AlterTableTxBody(tableId, version, specs[i]),
SetupSchema(runtime, sender, TTestSchema::AlterTableTxBody(tableId, version, testYdbSchema, testYdbPk, specs[i]),
NOlap::TSnapshot(++planStep, ++txId));
}
if (specs[i].HasTiers() || reboots) {
Expand Down Expand Up @@ -970,7 +968,7 @@ void TestDrop(bool reboots) {
ui64 planStep = 1000000000; // greater then delays
ui64 txId = 100;

SetupSchema(runtime, sender, TTestSchema::CreateTableTxBody(tableId, testYdbSchema, testYdbPk),
SetupSchema(runtime, sender, TTestSchema::CreateInitShardTxBody(tableId, testYdbSchema, testYdbPk),
NOlap::TSnapshot(++planStep, ++txId));
//

Expand Down Expand Up @@ -1039,7 +1037,7 @@ void TestDropWriteRace() {
NLongTxService::TLongTxId longTxId;
UNIT_ASSERT(longTxId.ParseString("ydb://long-tx/01ezvvxjdk2hd4vdgjs68knvp8?node_id=1"));

SetupSchema(runtime, sender, TTestSchema::CreateTableTxBody(tableId, testYdbSchema, testYdbPk),
SetupSchema(runtime, sender, TTestSchema::CreateInitShardTxBody(tableId, testYdbSchema, testYdbPk),
NOlap::TSnapshot(++planStep, ++txId));
TString data = MakeTestBlob({0, 100}, testYdbSchema);
UNIT_ASSERT(data.size() < NColumnShard::TLimits::MIN_BYTES_TO_INSERT);
Expand Down Expand Up @@ -1080,7 +1078,7 @@ void TestCompaction(std::optional<ui32> numWrites = {}) {
ui64 planStep = 100;
ui64 txId = 100;

SetupSchema(runtime, sender, TTestSchema::CreateTableTxBody(tableId, testYdbSchema, testYdbPk),
SetupSchema(runtime, sender, TTestSchema::CreateInitShardTxBody(tableId, testYdbSchema, testYdbPk),
NOlap::TSnapshot(++planStep, ++txId));
// Set tiering

Expand All @@ -1097,8 +1095,8 @@ void TestCompaction(std::optional<ui32> numWrites = {}) {
spec.Tiers.back().EvictAfter = allow;
spec.Tiers.back().S3 = TTestSchema::TStorageTier::FakeS3();

SetupSchema(runtime, sender, TTestSchema::AlterTableTxBody(tableId, 1, spec),
NOlap::TSnapshot(++planStep, ++txId));
SetupSchema(
runtime, sender, TTestSchema::AlterTableTxBody(tableId, 1, testYdbSchema, testYdbPk, spec), NOlap::TSnapshot(++planStep, ++txId));
csControllerGuard->OverrideTierConfigs(runtime, sender, TTestSchema::BuildSnapshot(spec));

// Writes
Expand Down Expand Up @@ -1176,6 +1174,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestSchema) {
ui64 txId = 100;
ui64 generation = 0;

SetupSchema(runtime, sender, TTestSchema::CreateInitShardTxBody(tableId++, schema, pk), NOlap::TSnapshot(planStep++, txId++));
for (auto& ydbType : intTypes) {
schema[0].SetType(TTypeInfo(ydbType));
pk[0].SetType(TTypeInfo(ydbType));
Expand Down
Loading