Skip to content

Commit c165555

Browse files
authored
24-1 Prevent from using B-Tree index with incorrect configuration (#4925)
1 parent 62b7bff commit c165555

File tree

3 files changed

+5
-92
lines changed

3 files changed

+5
-92
lines changed

ydb/core/tablet_flat/flat_executor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4321,7 +4321,7 @@ ui64 TExecutor::BeginCompaction(THolder<NTable::TCompactionParams> params)
43214321

43224322
comp->Epoch = snapshot->Subset->Epoch(); /* narrows requested to actual */
43234323
comp->Layout.Final = comp->Params->IsFinal;
4324-
comp->Layout.WriteBTreeIndex = AppData()->FeatureFlags.GetEnableLocalDBBtreeIndex();
4324+
comp->Layout.WriteBTreeIndex = false; // will be in 24-2: AppData()->FeatureFlags.GetEnableLocalDBBtreeIndex();
43254325
comp->Writer.StickyFlatIndex = !comp->Layout.WriteBTreeIndex;
43264326
comp->Layout.MaxRows = snapshot->Subset->MaxRows();
43274327
comp->Layout.ByKeyFilter = tableInfo->ByKeyFilter;

ydb/core/tablet_flat/flat_executor_ut.cpp

+3-90
Original file line numberDiff line numberDiff line change
@@ -5491,7 +5491,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) {
54915491
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 288);
54925492
}
54935493

5494-
Y_UNIT_TEST(UseBtreeIndex_True) {
5494+
Y_UNIT_TEST(UseBtreeIndex_True) { // forcibly disabled in 24-1, uses FlatIndex
54955495
TMyEnvBase env;
54965496
TRowsModel rows;
54975497

@@ -5512,8 +5512,8 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) {
55125512
env.SendSync(new NFake::TEvCompact(TRowsModel::TableId));
55135513
env.WaitFor<NFake::TEvCompacted>();
55145514

5515-
// all pages are always kept in shared cache (except flat index)
5516-
UNIT_ASSERT_VALUES_EQUAL(counters->ActivePages->Val(), 334);
5515+
// all pages are always kept in shared cache
5516+
UNIT_ASSERT_VALUES_EQUAL(counters->ActivePages->Val(), 290);
55175517

55185518
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(readRows, failedAttempts) });
55195519
UNIT_ASSERT_VALUES_EQUAL(readRows, 1000);
@@ -5526,96 +5526,9 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) {
55265526
// after restart we have no pages in private cache
55275527
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(readRows, failedAttempts) }, true);
55285528
UNIT_ASSERT_VALUES_EQUAL(readRows, 1000);
5529-
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 332);
5530-
}
5531-
5532-
Y_UNIT_TEST(UseBtreeIndex_True_TurnOff) {
5533-
TMyEnvBase env;
5534-
TRowsModel rows;
5535-
5536-
auto &appData = env->GetAppData();
5537-
appData.FeatureFlags.SetEnableLocalDBBtreeIndex(true);
5538-
auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters());
5539-
int readRows = 0, failedAttempts = 0;
5540-
5541-
env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
5542-
5543-
auto policy = MakeIntrusive<TCompactionPolicy>();
5544-
policy->MinBTreeIndexNodeSize = 128;
5545-
env.SendSync(rows.MakeScheme(std::move(policy)));
5546-
5547-
env.SendSync(rows.VersionTo(TRowVersion(1, 10)).RowTo(0).MakeRows(1000, 950));
5548-
env.SendSync(rows.VersionTo(TRowVersion(2, 20)).RowTo(0).MakeRows(1000, 950));
5549-
5550-
env.SendSync(new NFake::TEvCompact(TRowsModel::TableId));
5551-
env.WaitFor<NFake::TEvCompacted>();
5552-
5553-
// all pages are always kept in shared cache (except flat index)
5554-
UNIT_ASSERT_VALUES_EQUAL(counters->ActivePages->Val(), 334);
5555-
5556-
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(readRows, failedAttempts) });
5557-
UNIT_ASSERT_VALUES_EQUAL(readRows, 1000);
5558-
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 0);
5559-
5560-
// restart tablet, turn off setting
5561-
env.SendSync(new TEvents::TEvPoison, false, true);
5562-
appData.FeatureFlags.SetEnableLocalDBBtreeIndex(false);
5563-
env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
5564-
5565-
// after restart we have no pages in private cache
5566-
// but use only flat index
5567-
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(readRows, failedAttempts) }, true);
5568-
UNIT_ASSERT_VALUES_EQUAL(readRows, 1000);
55695529
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 288);
55705530
}
55715531

5572-
Y_UNIT_TEST(UseBtreeIndex_True_Generations) {
5573-
TMyEnvBase env;
5574-
TRowsModel rows;
5575-
5576-
auto &appData = env->GetAppData();
5577-
appData.FeatureFlags.SetEnableLocalDBBtreeIndex(true);
5578-
auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters());
5579-
int readRows = 0, failedAttempts = 0;
5580-
5581-
env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
5582-
5583-
auto policy = MakeIntrusive<TCompactionPolicy>();
5584-
policy->MinBTreeIndexNodeSize = 128;
5585-
policy->Generations.push_back({100 * 1024, 2, 2, 200 * 1024, NLocalDb::LegacyQueueIdToTaskName(1), false});
5586-
for (auto& gen : policy->Generations) {
5587-
gen.ExtraCompactionPercent = 0;
5588-
gen.ExtraCompactionMinSize = 0;
5589-
gen.ExtraCompactionExpPercent = 0;
5590-
gen.ExtraCompactionExpMaxSize = 0;
5591-
gen.UpliftPartSize = 0;
5592-
}
5593-
env.SendSync(rows.MakeScheme(std::move(policy)));
5594-
5595-
env.SendSync(rows.VersionTo(TRowVersion(1, 10)).RowTo(0).MakeRows(1000, 950));
5596-
env.SendSync(rows.VersionTo(TRowVersion(2, 20)).RowTo(0).MakeRows(1000, 950));
5597-
5598-
env.SendSync(new NFake::TEvCompact(TRowsModel::TableId));
5599-
env.WaitFor<NFake::TEvCompacted>();
5600-
5601-
// gen 0 data pages are always kept in shared cache
5602-
// b-tree index pages are always kept in shared cache
5603-
UNIT_ASSERT_VALUES_EQUAL(counters->ActivePages->Val(), 48);
5604-
5605-
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(readRows, failedAttempts) });
5606-
UNIT_ASSERT_VALUES_EQUAL(readRows, 1000);
5607-
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 286);
5608-
5609-
// restart tablet
5610-
env.SendSync(new TEvents::TEvPoison, false, true);
5611-
env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
5612-
5613-
// after restart we have no pages in private cache
5614-
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(readRows, failedAttempts) }, true);
5615-
UNIT_ASSERT_VALUES_EQUAL(readRows, 1000);
5616-
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 332);
5617-
}
5618-
56195532
}
56205533

56215534
} // namespace NTabletFlatExecutor

ydb/core/tablet_flat/flat_part_loader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void TLoader::StageParseMeta() noexcept
7878

7979
BTreeGroupIndexes.clear();
8080
BTreeHistoricIndexes.clear();
81-
if (AppData()->FeatureFlags.GetEnableLocalDBBtreeIndex()) {
81+
if (false) { // will be in 24-2: AppData()->FeatureFlags.GetEnableLocalDBBtreeIndex()
8282
for (bool history : {false, true}) {
8383
for (const auto &meta : history ? layout.GetBTreeHistoricIndexes() : layout.GetBTreeGroupIndexes()) {
8484
NPage::TBtreeIndexMeta converted{{

0 commit comments

Comments
 (0)