diff options
author | ivanmorozov333 <ivanmorozov@ydb.tech> | 2024-06-03 12:04:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-03 12:04:46 +0300 |
commit | 1d8a147046f8d762e6e0f8ef14537d253f9a6459 (patch) | |
tree | ad70dc5654a62ca49421897071b0cd1b405ab9d0 | |
parent | ca8e9f111e802a293622edd956d6f7c841f42d8e (diff) | |
download | ydb-1d8a147046f8d762e6e0f8ef14537d253f9a6459.tar.gz |
tiers info initialization fix (#5060)
-rw-r--r-- | ydb/core/kqp/ut/olap/indexes_ut.cpp | 13 | ||||
-rw-r--r-- | ydb/core/tx/columnshard/columnshard_impl.cpp | 9 | ||||
-rw-r--r-- | ydb/core/tx/columnshard/tables_manager.cpp | 9 | ||||
-rw-r--r-- | ydb/core/tx/columnshard/tables_manager.h | 2 |
4 files changed, 20 insertions, 13 deletions
diff --git a/ydb/core/kqp/ut/olap/indexes_ut.cpp b/ydb/core/kqp/ut/olap/indexes_ut.cpp index c1a370231c..e85b3f5a7f 100644 --- a/ydb/core/kqp/ut/olap/indexes_ut.cpp +++ b/ydb/core/kqp/ut/olap/indexes_ut.cpp @@ -136,6 +136,8 @@ Y_UNIT_TEST_SUITE(KqpOlapIndexes) { filler(1100000, 300100000, 10000); } + const ui64 initCount = csController->GetActualizationRefreshSchemeCount().Val(); + AFL_VERIFY(initCount == 3)("started_value", initCount); for (ui32 i = 0; i < 10; ++i) { auto alterQuery = TStringBuilder() << @@ -144,8 +146,8 @@ Y_UNIT_TEST_SUITE(KqpOlapIndexes) { auto alterResult = session.ExecuteSchemeQuery(alterQuery).GetValueSync(); UNIT_ASSERT_VALUES_EQUAL_C(alterResult.GetStatus(), NYdb::EStatus::SUCCESS, alterResult.GetIssues().ToString()); } - const ui64 startCount = csController->GetActualizationRefreshSchemeCount().Val(); - AFL_VERIFY(startCount == 30); + const ui64 updatesCount = csController->GetActualizationRefreshSchemeCount().Val(); + AFL_VERIFY(updatesCount == 30 + initCount)("after_modification", updatesCount); for (auto&& i : csController->GetShardActualIds()) { kikimr.GetTestServer().GetRuntime()->Send(MakePipePerNodeCacheID(false), NActors::TActorId(), new TEvPipeCache::TEvForward( @@ -165,8 +167,8 @@ Y_UNIT_TEST_SUITE(KqpOlapIndexes) { CompareYson(result, R"([[20000u;]])"); } - AFL_VERIFY(startCount + 3 /*tables count*/ * 3 /*2 * normalizers + main_load*/ == - (ui64)csController->GetActualizationRefreshSchemeCount().Val())("start", startCount)("count", csController->GetActualizationRefreshSchemeCount().Val()); + AFL_VERIFY(updatesCount + 3 /*tablets count*/ * 3 /*2 * normalizers + main_load*/ == + (ui64)csController->GetActualizationRefreshSchemeCount().Val())("updates", updatesCount)("count", csController->GetActualizationRefreshSchemeCount().Val()); } Y_UNIT_TEST(Indexes) { @@ -308,7 +310,8 @@ Y_UNIT_TEST_SUITE(KqpOlapIndexes) { CompareYson(result, R"([[1u;]])"); } - AFL_VERIFY(csController->GetIndexesApprovedOnSelect().Val() < 0.20 * csController->GetIndexesSkippingOnSelect().Val()); + AFL_VERIFY(csController->GetIndexesApprovedOnSelect().Val() < 0.20 * csController->GetIndexesSkippingOnSelect().Val()) + ("approved", csController->GetIndexesApprovedOnSelect().Val())("skipped", csController->GetIndexesSkippingOnSelect().Val()); } diff --git a/ydb/core/tx/columnshard/columnshard_impl.cpp b/ydb/core/tx/columnshard/columnshard_impl.cpp index 755b281699..5bd3586b80 100644 --- a/ydb/core/tx/columnshard/columnshard_impl.cpp +++ b/ydb/core/tx/columnshard/columnshard_impl.cpp @@ -393,7 +393,7 @@ void TColumnShard::RunEnsureTable(const NKikimrTxColumnShard::TCreateTable& tabl tableVerProto.SetSchemaPresetId(preset.GetId()); if (TablesManager.RegisterSchemaPreset(preset, db)) { - TablesManager.AddSchemaVersion(tableProto.GetSchemaPreset().GetId(), version, tableProto.GetSchemaPreset().GetSchema(), db); + TablesManager.AddSchemaVersion(tableProto.GetSchemaPreset().GetId(), version, tableProto.GetSchemaPreset().GetSchema(), db, Tiers); } } else { Y_ABORT_UNLESS(tableProto.HasSchema(), "Tables has either schema or preset"); @@ -442,7 +442,7 @@ void TColumnShard::RunAlterTable(const NKikimrTxColumnShard::TAlterTable& alterP NKikimrTxColumnShard::TTableVersionInfo tableVerProto; if (alterProto.HasSchemaPreset()) { tableVerProto.SetSchemaPresetId(alterProto.GetSchemaPreset().GetId()); - TablesManager.AddSchemaVersion(alterProto.GetSchemaPreset().GetId(), version, alterProto.GetSchemaPreset().GetSchema(), db); + TablesManager.AddSchemaVersion(alterProto.GetSchemaPreset().GetId(), version, alterProto.GetSchemaPreset().GetSchema(), db, Tiers); } else if (alterProto.HasSchema()) { *tableVerProto.MutableSchema() = alterProto.GetSchema(); } @@ -501,7 +501,7 @@ void TColumnShard::RunAlterStore(const NKikimrTxColumnShard::TAlterStore& proto, if (!TablesManager.HasPreset(presetProto.GetId())) { continue; // we don't update presets that we don't use } - TablesManager.AddSchemaVersion(presetProto.GetId(), version, presetProto.GetSchema(), db); + TablesManager.AddSchemaVersion(presetProto.GetId(), version, presetProto.GetSchema(), db, Tiers); } } @@ -751,7 +751,6 @@ bool TColumnShard::SetupTtl(const THashMap<ui64, NOlap::TTiering>& pathTtls) { ACFL_DEBUG("background", "ttl")("path", i.first)("info", i.second.GetDebugString()); } - auto actualIndexInfo = std::make_shared<NOlap::TVersionedIndex>(TablesManager.GetPrimaryIndex()->GetVersionedIndex()); const ui64 memoryUsageLimit = HasAppData() ? AppDataVerified().ColumnShardConfig.GetTieringsMemoryLimit() : ((ui64)512 * 1024 * 1024); std::vector<std::shared_ptr<NOlap::TTTLColumnEngineChanges>> indexChanges = TablesManager.MutablePrimaryIndex().StartTtl(eviction, DataLocksManager, memoryUsageLimit); @@ -759,6 +758,8 @@ bool TColumnShard::SetupTtl(const THashMap<ui64, NOlap::TTiering>& pathTtls) { ACFL_DEBUG("background", "ttl")("skip_reason", "no_changes"); return false; } + + auto actualIndexInfo = std::make_shared<NOlap::TVersionedIndex>(TablesManager.GetPrimaryIndex()->GetVersionedIndex()); for (auto&& i : indexChanges) { const TString externalTaskId = i->GetTaskIdentifier(); const bool needWrites = i->NeedConstruction(); diff --git a/ydb/core/tx/columnshard/tables_manager.cpp b/ydb/core/tx/columnshard/tables_manager.cpp index f86e8bd42b..d9ca24f919 100644 --- a/ydb/core/tx/columnshard/tables_manager.cpp +++ b/ydb/core/tx/columnshard/tables_manager.cpp @@ -269,7 +269,7 @@ bool TTablesManager::RegisterSchemaPreset(const TSchemaPreset& schemaPreset, NIc return true; } -void TTablesManager::AddSchemaVersion(const ui32 presetId, const NOlap::TSnapshot& version, const NKikimrSchemeOp::TColumnTableSchema& schema, NIceDb::TNiceDb& db) { +void TTablesManager::AddSchemaVersion(const ui32 presetId, const NOlap::TSnapshot& version, const NKikimrSchemeOp::TColumnTableSchema& schema, NIceDb::TNiceDb& db, std::shared_ptr<TTiersManager>& manager) { Y_ABORT_UNLESS(SchemaPresetsIds.contains(presetId)); TSchemaPreset::TSchemaPresetVersionInfo versionInfo; @@ -285,6 +285,9 @@ void TTablesManager::AddSchemaVersion(const ui32 presetId, const NOlap::TSnapsho for (auto&& i : Tables) { PrimaryIndex->RegisterTable(i.first); } + if (manager->IsReady()) { + PrimaryIndex->OnTieringModified(manager, Ttl, {}); + } } else { PrimaryIndex->RegisterSchemaVersion(version, schema); } @@ -310,10 +313,10 @@ void TTablesManager::AddTableVersion(const ui64 pathId, const NOlap::TSnapshot& if (SchemaPresetsIds.empty()) { TSchemaPreset fakePreset; Y_ABORT_UNLESS(RegisterSchemaPreset(fakePreset, db)); - AddSchemaVersion(fakePreset.GetId(), version, versionInfo.GetSchema(), db); + AddSchemaVersion(fakePreset.GetId(), version, versionInfo.GetSchema(), db, manager); } else { Y_ABORT_UNLESS(SchemaPresetsIds.contains(fakePreset.GetId())); - AddSchemaVersion(fakePreset.GetId(), version, versionInfo.GetSchema(), db); + AddSchemaVersion(fakePreset.GetId(), version, versionInfo.GetSchema(), db, manager); } } diff --git a/ydb/core/tx/columnshard/tables_manager.h b/ydb/core/tx/columnshard/tables_manager.h index 72606173c5..1481882e41 100644 --- a/ydb/core/tx/columnshard/tables_manager.h +++ b/ydb/core/tx/columnshard/tables_manager.h @@ -239,7 +239,7 @@ public: void RegisterTable(TTableInfo&& table, NIceDb::TNiceDb& db); bool RegisterSchemaPreset(const TSchemaPreset& schemaPreset, NIceDb::TNiceDb& db); - void AddSchemaVersion(const ui32 presetId, const NOlap::TSnapshot& version, const NKikimrSchemeOp::TColumnTableSchema& schema, NIceDb::TNiceDb& db); + void AddSchemaVersion(const ui32 presetId, const NOlap::TSnapshot& version, const NKikimrSchemeOp::TColumnTableSchema& schema, NIceDb::TNiceDb& db, std::shared_ptr<TTiersManager>& manager); void AddTableVersion(const ui64 pathId, const NOlap::TSnapshot& version, const NKikimrTxColumnShard::TTableVersionInfo& versionInfo, NIceDb::TNiceDb& db, std::shared_ptr<TTiersManager>& manager); bool FillMonitoringReport(NTabletFlatExecutor::TTransactionContext& txc, NJson::TJsonValue& json); |