Skip to content

Commit 1d8a147

Browse files
tiers info initialization fix (#5060)
1 parent ca8e9f1 commit 1d8a147

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

ydb/core/kqp/ut/olap/indexes_ut.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ Y_UNIT_TEST_SUITE(KqpOlapIndexes) {
136136
filler(1100000, 300100000, 10000);
137137

138138
}
139+
const ui64 initCount = csController->GetActualizationRefreshSchemeCount().Val();
140+
AFL_VERIFY(initCount == 3)("started_value", initCount);
139141

140142
for (ui32 i = 0; i < 10; ++i) {
141143
auto alterQuery = TStringBuilder() <<
@@ -144,8 +146,8 @@ Y_UNIT_TEST_SUITE(KqpOlapIndexes) {
144146
auto alterResult = session.ExecuteSchemeQuery(alterQuery).GetValueSync();
145147
UNIT_ASSERT_VALUES_EQUAL_C(alterResult.GetStatus(), NYdb::EStatus::SUCCESS, alterResult.GetIssues().ToString());
146148
}
147-
const ui64 startCount = csController->GetActualizationRefreshSchemeCount().Val();
148-
AFL_VERIFY(startCount == 30);
149+
const ui64 updatesCount = csController->GetActualizationRefreshSchemeCount().Val();
150+
AFL_VERIFY(updatesCount == 30 + initCount)("after_modification", updatesCount);
149151

150152
for (auto&& i : csController->GetShardActualIds()) {
151153
kikimr.GetTestServer().GetRuntime()->Send(MakePipePerNodeCacheID(false), NActors::TActorId(), new TEvPipeCache::TEvForward(
@@ -165,8 +167,8 @@ Y_UNIT_TEST_SUITE(KqpOlapIndexes) {
165167
CompareYson(result, R"([[20000u;]])");
166168
}
167169

168-
AFL_VERIFY(startCount + 3 /*tables count*/ * 3 /*2 * normalizers + main_load*/ ==
169-
(ui64)csController->GetActualizationRefreshSchemeCount().Val())("start", startCount)("count", csController->GetActualizationRefreshSchemeCount().Val());
170+
AFL_VERIFY(updatesCount + 3 /*tablets count*/ * 3 /*2 * normalizers + main_load*/ ==
171+
(ui64)csController->GetActualizationRefreshSchemeCount().Val())("updates", updatesCount)("count", csController->GetActualizationRefreshSchemeCount().Val());
170172
}
171173

172174
Y_UNIT_TEST(Indexes) {
@@ -308,7 +310,8 @@ Y_UNIT_TEST_SUITE(KqpOlapIndexes) {
308310
CompareYson(result, R"([[1u;]])");
309311
}
310312

311-
AFL_VERIFY(csController->GetIndexesApprovedOnSelect().Val() < 0.20 * csController->GetIndexesSkippingOnSelect().Val());
313+
AFL_VERIFY(csController->GetIndexesApprovedOnSelect().Val() < 0.20 * csController->GetIndexesSkippingOnSelect().Val())
314+
("approved", csController->GetIndexesApprovedOnSelect().Val())("skipped", csController->GetIndexesSkippingOnSelect().Val());
312315

313316
}
314317

ydb/core/tx/columnshard/columnshard_impl.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void TColumnShard::RunEnsureTable(const NKikimrTxColumnShard::TCreateTable& tabl
393393
tableVerProto.SetSchemaPresetId(preset.GetId());
394394

395395
if (TablesManager.RegisterSchemaPreset(preset, db)) {
396-
TablesManager.AddSchemaVersion(tableProto.GetSchemaPreset().GetId(), version, tableProto.GetSchemaPreset().GetSchema(), db);
396+
TablesManager.AddSchemaVersion(tableProto.GetSchemaPreset().GetId(), version, tableProto.GetSchemaPreset().GetSchema(), db, Tiers);
397397
}
398398
} else {
399399
Y_ABORT_UNLESS(tableProto.HasSchema(), "Tables has either schema or preset");
@@ -442,7 +442,7 @@ void TColumnShard::RunAlterTable(const NKikimrTxColumnShard::TAlterTable& alterP
442442
NKikimrTxColumnShard::TTableVersionInfo tableVerProto;
443443
if (alterProto.HasSchemaPreset()) {
444444
tableVerProto.SetSchemaPresetId(alterProto.GetSchemaPreset().GetId());
445-
TablesManager.AddSchemaVersion(alterProto.GetSchemaPreset().GetId(), version, alterProto.GetSchemaPreset().GetSchema(), db);
445+
TablesManager.AddSchemaVersion(alterProto.GetSchemaPreset().GetId(), version, alterProto.GetSchemaPreset().GetSchema(), db, Tiers);
446446
} else if (alterProto.HasSchema()) {
447447
*tableVerProto.MutableSchema() = alterProto.GetSchema();
448448
}
@@ -501,7 +501,7 @@ void TColumnShard::RunAlterStore(const NKikimrTxColumnShard::TAlterStore& proto,
501501
if (!TablesManager.HasPreset(presetProto.GetId())) {
502502
continue; // we don't update presets that we don't use
503503
}
504-
TablesManager.AddSchemaVersion(presetProto.GetId(), version, presetProto.GetSchema(), db);
504+
TablesManager.AddSchemaVersion(presetProto.GetId(), version, presetProto.GetSchema(), db, Tiers);
505505
}
506506
}
507507

@@ -751,14 +751,15 @@ bool TColumnShard::SetupTtl(const THashMap<ui64, NOlap::TTiering>& pathTtls) {
751751
ACFL_DEBUG("background", "ttl")("path", i.first)("info", i.second.GetDebugString());
752752
}
753753

754-
auto actualIndexInfo = std::make_shared<NOlap::TVersionedIndex>(TablesManager.GetPrimaryIndex()->GetVersionedIndex());
755754
const ui64 memoryUsageLimit = HasAppData() ? AppDataVerified().ColumnShardConfig.GetTieringsMemoryLimit() : ((ui64)512 * 1024 * 1024);
756755
std::vector<std::shared_ptr<NOlap::TTTLColumnEngineChanges>> indexChanges = TablesManager.MutablePrimaryIndex().StartTtl(eviction, DataLocksManager, memoryUsageLimit);
757756

758757
if (indexChanges.empty()) {
759758
ACFL_DEBUG("background", "ttl")("skip_reason", "no_changes");
760759
return false;
761760
}
761+
762+
auto actualIndexInfo = std::make_shared<NOlap::TVersionedIndex>(TablesManager.GetPrimaryIndex()->GetVersionedIndex());
762763
for (auto&& i : indexChanges) {
763764
const TString externalTaskId = i->GetTaskIdentifier();
764765
const bool needWrites = i->NeedConstruction();

ydb/core/tx/columnshard/tables_manager.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ bool TTablesManager::RegisterSchemaPreset(const TSchemaPreset& schemaPreset, NIc
269269
return true;
270270
}
271271

272-
void TTablesManager::AddSchemaVersion(const ui32 presetId, const NOlap::TSnapshot& version, const NKikimrSchemeOp::TColumnTableSchema& schema, NIceDb::TNiceDb& db) {
272+
void TTablesManager::AddSchemaVersion(const ui32 presetId, const NOlap::TSnapshot& version, const NKikimrSchemeOp::TColumnTableSchema& schema, NIceDb::TNiceDb& db, std::shared_ptr<TTiersManager>& manager) {
273273
Y_ABORT_UNLESS(SchemaPresetsIds.contains(presetId));
274274

275275
TSchemaPreset::TSchemaPresetVersionInfo versionInfo;
@@ -285,6 +285,9 @@ void TTablesManager::AddSchemaVersion(const ui32 presetId, const NOlap::TSnapsho
285285
for (auto&& i : Tables) {
286286
PrimaryIndex->RegisterTable(i.first);
287287
}
288+
if (manager->IsReady()) {
289+
PrimaryIndex->OnTieringModified(manager, Ttl, {});
290+
}
288291
} else {
289292
PrimaryIndex->RegisterSchemaVersion(version, schema);
290293
}
@@ -310,10 +313,10 @@ void TTablesManager::AddTableVersion(const ui64 pathId, const NOlap::TSnapshot&
310313
if (SchemaPresetsIds.empty()) {
311314
TSchemaPreset fakePreset;
312315
Y_ABORT_UNLESS(RegisterSchemaPreset(fakePreset, db));
313-
AddSchemaVersion(fakePreset.GetId(), version, versionInfo.GetSchema(), db);
316+
AddSchemaVersion(fakePreset.GetId(), version, versionInfo.GetSchema(), db, manager);
314317
} else {
315318
Y_ABORT_UNLESS(SchemaPresetsIds.contains(fakePreset.GetId()));
316-
AddSchemaVersion(fakePreset.GetId(), version, versionInfo.GetSchema(), db);
319+
AddSchemaVersion(fakePreset.GetId(), version, versionInfo.GetSchema(), db, manager);
317320
}
318321
}
319322

ydb/core/tx/columnshard/tables_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class TTablesManager {
239239
void RegisterTable(TTableInfo&& table, NIceDb::TNiceDb& db);
240240
bool RegisterSchemaPreset(const TSchemaPreset& schemaPreset, NIceDb::TNiceDb& db);
241241

242-
void AddSchemaVersion(const ui32 presetId, const NOlap::TSnapshot& version, const NKikimrSchemeOp::TColumnTableSchema& schema, NIceDb::TNiceDb& db);
242+
void AddSchemaVersion(const ui32 presetId, const NOlap::TSnapshot& version, const NKikimrSchemeOp::TColumnTableSchema& schema, NIceDb::TNiceDb& db, std::shared_ptr<TTiersManager>& manager);
243243
void AddTableVersion(const ui64 pathId, const NOlap::TSnapshot& version, const NKikimrTxColumnShard::TTableVersionInfo& versionInfo, NIceDb::TNiceDb& db, std::shared_ptr<TTiersManager>& manager);
244244
bool FillMonitoringReport(NTabletFlatExecutor::TTransactionContext& txc, NJson::TJsonValue& json);
245245

0 commit comments

Comments
 (0)