Skip to content

Commit 0e1fdd6

Browse files
authored
fix loading ttl settings (#14393)
1 parent 4b90b10 commit 0e1fdd6

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class TTieringTestHelper {
1919
std::optional<TLocalHelper> OlapHelper;
2020
std::optional<NYDBTest::TControllers::TGuard<NOlap::TWaitCompactionController>> CsController;
2121

22+
YDB_ACCESSOR(TString, TablePath, "/Root/olapStore/olapTable");
23+
2224
public:
2325
TTieringTestHelper() {
2426
CsController.emplace(NYDBTest::TControllers::RegisterCSControllerGuard<NOlap::TWaitCompactionController>());
@@ -53,8 +55,8 @@ class TTieringTestHelper {
5355

5456
void WriteSampleData() {
5557
for (ui64 i = 0; i < 100; ++i) {
56-
WriteTestData(TestHelper->GetKikimr(), "/Root/olapStore/olapTable", 0, 3600000000 + i * 10000, 1000);
57-
WriteTestData(TestHelper->GetKikimr(), "/Root/olapStore/olapTable", 0, 3600000000 + i * 10000, 1000);
58+
WriteTestData(TestHelper->GetKikimr(), TablePath, 0, 3600000000 + i * 10000, 1000);
59+
WriteTestData(TestHelper->GetKikimr(), TablePath, 0, 3600000000 + i * 10000, 1000);
5860
}
5961
}
6062

@@ -65,7 +67,7 @@ class TTieringTestHelper {
6567
selectQuery << R"(
6668
SELECT
6769
TierName, SUM(ColumnRawBytes) AS RawBytes, SUM(Rows) AS Rows
68-
FROM `/Root/olapStore/olapTable/.sys/primary_index_portion_stats`)";
70+
FROM `)" << TablePath << R"(/.sys/primary_index_portion_stats`)";
6971
if (onlyActive) {
7072
selectQuery << " WHERE Activity == 1";
7173
}
@@ -127,6 +129,29 @@ Y_UNIT_TEST_SUITE(KqpOlapTiering) {
127129
tieringHelper.CheckAllDataInTier("__DEFAULT");
128130
}
129131

132+
Y_UNIT_TEST(LoadTtlSettings) {
133+
TTieringTestHelper tieringHelper;
134+
auto& csController = tieringHelper.GetCsController();
135+
auto& olapHelper = tieringHelper.GetOlapHelper();
136+
auto& testHelper = tieringHelper.GetTestHelper();
137+
tieringHelper.SetTablePath("/Root/olapTable");
138+
139+
olapHelper.CreateTestOlapTableWithoutStore();
140+
testHelper.CreateTier("tier1");
141+
testHelper.SetTiering("/Root/olapTable", "/Root/tier1", "timestamp");
142+
{
143+
const TString query = R"(ALTER TABLE `/Root/olapTable` ADD COLUMN f Int32)";
144+
auto result = testHelper.GetSession().ExecuteSchemeQuery(query).GetValueSync();
145+
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), NYdb::EStatus::SUCCESS, result.GetIssues().ToOneLineString());
146+
}
147+
testHelper.RebootTablets("/Root/olapTable");
148+
149+
tieringHelper.WriteSampleData();
150+
csController->WaitCompactions(TDuration::Seconds(5));
151+
csController->WaitActualization(TDuration::Seconds(5));
152+
tieringHelper.CheckAllDataInTier("/Root/tier1");
153+
}
154+
130155
Y_UNIT_TEST(EvictionWithStrippedEdsPath) {
131156
TTieringTestHelper tieringHelper;
132157
auto& csController = tieringHelper.GetCsController();

ydb/core/tx/columnshard/columnshard_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,16 +455,16 @@ void TColumnShard::RunAlterTable(const NKikimrTxColumnShard::TAlterTable& alterP
455455
schema = alterProto.GetSchema();
456456
}
457457

458-
THashSet<NTiers::TExternalStorageId> usedTiers;
459458
if (alterProto.HasTtlSettings()) {
460459
const auto& ttlSettings = alterProto.GetTtlSettings();
461460
*tableVerProto.MutableTtlSettings() = ttlSettings;
462461

462+
THashSet<NTiers::TExternalStorageId> usedTiers;
463463
if (ttlSettings.HasEnabled()) {
464464
usedTiers = NOlap::TTiering::GetUsedTiers(ttlSettings.GetEnabled());
465465
}
466+
ActivateTiering(pathId, usedTiers);
466467
}
467-
ActivateTiering(pathId, usedTiers);
468468

469469
tableVerProto.SetSchemaPresetVersionAdj(alterProto.GetSchemaPresetVersionAdj());
470470
TablesManager.AddTableVersion(pathId, version, tableVerProto, schema, db);

ydb/core/tx/columnshard/tables_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ bool TTablesManager::InitFromDB(NIceDb::TNiceDb& db) {
126126
AFL_VERIFY(preset);
127127
AFL_VERIFY(preset->Id == versionInfo.GetSchemaPresetId())("preset", preset->Id)("table", versionInfo.GetSchemaPresetId());
128128

129-
if (!table.IsDropped()) {
129+
if (!table.IsDropped() && versionInfo.HasTtlSettings()) {
130130
auto& ttlSettings = versionInfo.GetTtlSettings();
131131
auto vIt = lastVersion.find(pathId);
132132
if (vIt == lastVersion.end()) {

0 commit comments

Comments
 (0)