diff options
author | kungasc <kungasc@yandex-team.com> | 2023-10-05 17:57:08 +0300 |
---|---|---|
committer | kungasc <kungasc@yandex-team.com> | 2023-10-05 18:23:03 +0300 |
commit | bcae19f0ae90c93d0ab978ef1b4e516053f19535 (patch) | |
tree | b0352894d0022e7a685037b87f0db26b1ff14257 | |
parent | 285a2e6cf4486a60ae508d931e38d5a4adc3c190 (diff) | |
download | ydb-bcae19f0ae90c93d0ab978ef1b4e516053f19535.tar.gz |
KIKIMR-19520 Make indexes non-sticky initially
-rw-r--r-- | ydb/core/tablet_flat/flat_executor_ut.cpp | 24 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_part_loader.cpp | 32 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_part_loader.h | 2 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_sausagecache.cpp | 9 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_table_part.h | 4 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_writer_blocks.h | 5 | ||||
-rw-r--r-- | ydb/core/tablet_flat/test/libs/table/test_store.h | 2 | ||||
-rw-r--r-- | ydb/core/tablet_flat/test/libs/table/test_writer.h | 3 |
8 files changed, 30 insertions, 51 deletions
diff --git a/ydb/core/tablet_flat/flat_executor_ut.cpp b/ydb/core/tablet_flat/flat_executor_ut.cpp index 209fb0fff82..1641c59c7e7 100644 --- a/ydb/core/tablet_flat/flat_executor_ut.cpp +++ b/ydb/core/tablet_flat/flat_executor_ut.cpp @@ -5156,15 +5156,17 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorStickyPages) { int failedAttempts = 0; env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }); - UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 20); // data pages only, 2 indexes are sticky + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 20); // 20 data pages, 2 index pages are sticky until restart // restart tablet env.SendSync(new TEvents::TEvPoison, false, true); env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - // should have the same behaviour env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true); - UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 20); + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 22); // 20 data pages and 2 index pages + + env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true); + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 20); // 20 data pages, 2 index pages are sticky again } Y_UNIT_TEST(TestSticky) { @@ -5219,15 +5221,17 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorStickyPages) { int failedAttempts = 0; env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }); - UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 12); // 1 groups[0], 1 historic[0], 10 historic[1] pages, 4 indexes are sticky + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 12); // 1 groups[0], 1 historic[0], 10 historic[1] pages, 3 index pages are sticky until restart // restart tablet env.SendSync(new TEvents::TEvPoison, false, true); env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - // should have the same behaviour env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true); - UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 12); + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 15); // 1 groups[0], 1 historic[0], 10 historic[1] pages, 3 index pages + + env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true); + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 12); // 1 groups[0], 1 historic[0], 10 historic[1] pages, 3 index pages are sticky again } Y_UNIT_TEST(TestStickyMain) { @@ -5284,15 +5288,17 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorStickyPages) { int failedAttempts = 0; env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }); - UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 2); // 1 groups[0], 1 historic[0], 4 indexes are sticky + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 2); // 1 groups[0], 1 historic[0], 3 index pages are sticky until restart // restart tablet env.SendSync(new TEvents::TEvPoison, false, true); env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - // should have the same behaviour env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true); - UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 2); + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 5); // 1 groups[0], 1 historic[0], 3 index pages + + env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true); + UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 2); // 1 groups[0], 1 historic[0], 3 index pages are sticky again } Y_UNIT_TEST(TestStickyAll) { diff --git a/ydb/core/tablet_flat/flat_part_loader.cpp b/ydb/core/tablet_flat/flat_part_loader.cpp index e6f33820d06..57aa1f5f46f 100644 --- a/ydb/core/tablet_flat/flat_part_loader.cpp +++ b/ydb/core/tablet_flat/flat_part_loader.cpp @@ -124,29 +124,18 @@ TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept Y_VERIFY(Packs && Packs.front()); TVector<TPageId> load; - for (auto page: { SchemeId, IndexId, GlobsId, + for (auto page: { SchemeId, GlobsId, SmallId, LargeId, ByKeyId, GarbageStatsId, TxIdStatsId }) { if (page != Max<TPageId>() && !Packs[0]->Lookup(page)) load.push_back(page); } - for (auto page : GroupIndexesIds) { - if (!Packs[0]->Lookup(page)) { - load.push_back(page); - } - } - for (auto page : HistoricIndexesIds) { - if (!Packs[0]->Lookup(page)) { - load.push_back(page); - } - } if (load) { return new NPageCollection::TFetch{ 0, Packs[0]->PageCollection, std::move(load) }; } auto *scheme = GetPage(SchemeId); - auto *index = GetPage(IndexId); auto *large = GetPage(LargeId); auto *small = GetPage(SmallId); auto *blobs = GetPage(GlobsId); @@ -154,28 +143,14 @@ TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept auto *garbageStats = GetPage(GarbageStatsId); auto *txIdStats = GetPage(TxIdStatsId); - if (scheme == nullptr || index == nullptr) { - Y_FAIL("One of scheme or index pages is not loaded"); + if (scheme == nullptr) { + Y_FAIL("Scheme page is not loaded"); } else if (ByKeyId != Max<TPageId>() && !byKey) { Y_FAIL("Filter page must be loaded if it exists"); } else if (small && Packs.size() != (1 + GroupIndexesIds.size() + 1)) { Y_Fail("TPart has small blobs, " << Packs.size() << " page collections"); } - // TODO: stop load indexes - for (auto pageId : GroupIndexesIds) { - auto* page = GetPage(pageId); - if (!page) { - Y_Fail("Missing group index page " << pageId); - } - } - for (auto pageId : HistoricIndexesIds) { - auto* page = GetPage(pageId); - if (!page) { - Y_Fail("Missing historic index page " << pageId); - } - } - const auto extra = BlobsLabelFor(Packs[0]->PageCollection->Label()); auto *stat = Root.HasStat() ? &Root.GetStat() : nullptr; @@ -202,7 +177,6 @@ TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept epoch, TPartScheme::Parse(*scheme, Rooted), { std::move(groupIndexesIds), HistoricIndexesIds }, - *index, blobs ? new NPage::TExtBlobs(*blobs, extra) : nullptr, byKey ? new NPage::TBloom(*byKey) : nullptr, large ? new NPage::TFrames(*large) : nullptr, diff --git a/ydb/core/tablet_flat/flat_part_loader.h b/ydb/core/tablet_flat/flat_part_loader.h index 1d6d2c7fa20..23901e695d0 100644 --- a/ydb/core/tablet_flat/flat_part_loader.h +++ b/ydb/core/tablet_flat/flat_part_loader.h @@ -83,7 +83,7 @@ namespace NTable { constexpr static bool NeedIn(EPage page) noexcept { return - page == EPage::Scheme || page == EPage::Index + page == EPage::Scheme || page == EPage::Frames || page == EPage::Globs || page == EPage::Schem2 || page == EPage::Bloom || page == EPage::GarbageStats diff --git a/ydb/core/tablet_flat/flat_sausagecache.cpp b/ydb/core/tablet_flat/flat_sausagecache.cpp index 3f7610900e9..cbde110cd06 100644 --- a/ydb/core/tablet_flat/flat_sausagecache.cpp +++ b/ydb/core/tablet_flat/flat_sausagecache.cpp @@ -519,6 +519,8 @@ void TPrivatePageCache::DropSharedBody(TInfo *info, ui32 pageId) { TPrivatePageCache::TPage::TWaitQueuePtr TPrivatePageCache::ProvideBlock( NSharedCache::TEvResult::TLoaded&& loaded, TInfo *info) { + using EPage = NTable::NPage::EPage; + Y_VERIFY_DEBUG(loaded.Page && loaded.Page.IsUsed()); TPage *page = info->EnsurePage(loaded.PageId); @@ -534,7 +536,12 @@ TPrivatePageCache::TPage::TWaitQueuePtr TPrivatePageCache::ProvideBlock( if (Y_UNLIKELY(page->SharedPending)) Stats.TotalSharedPending -= page->Size; - // N.B. we must be careful not to accidentally drop the sticky bit + // Note: for now we mark index pages sticky after we load them + if (!page->Sticky && EPage(info->PageCollection->Page(page->Id).Type) == EPage::Index) { + MarkSticky(page->Id, info); + } + + // Note: we must be careful not to accidentally drop the sticky bit page->Fill(std::move(loaded.Page), page->Sticky); Stats.TotalSharedBody += page->Size; Stats.TotalPinnedBody += page->Size; diff --git a/ydb/core/tablet_flat/flat_table_part.h b/ydb/core/tablet_flat/flat_table_part.h index 51c1a998402..aa92abe60ac 100644 --- a/ydb/core/tablet_flat/flat_table_part.h +++ b/ydb/core/tablet_flat/flat_table_part.h @@ -56,7 +56,6 @@ namespace NTable { TEpoch Epoch; TIntrusiveConstPtr<TPartScheme> Scheme; TIndexPages IndexPages; - TSharedData Index; TIntrusiveConstPtr<NPage::TExtBlobs> Blobs; TIntrusiveConstPtr<NPage::TBloom> ByKey; TIntrusiveConstPtr<NPage::TFrames> Large; @@ -85,7 +84,6 @@ namespace NTable { , Large(std::move(params.Large)) , Small(std::move(params.Small)) , IndexPages(std::move(params.IndexPages)) - , Index(std::move(params.Index)) , ByKey(std::move(params.ByKey)) , GarbageStats(std::move(params.GarbageStats)) , TxIdStats(std::move(params.TxIdStats)) @@ -140,7 +138,6 @@ namespace NTable { , Large(src.Large) , Small(src.Small) , IndexPages(src.IndexPages) - , Index(src.Index) , ByKey(src.ByKey) , GarbageStats(src.GarbageStats) , Stat(src.Stat) @@ -159,7 +156,6 @@ namespace NTable { const TIntrusiveConstPtr<NPage::TFrames> Large; const TIntrusiveConstPtr<NPage::TFrames> Small; const TIndexPages IndexPages; - const NPage::TIndex Index; const TIntrusiveConstPtr<NPage::TBloom> ByKey; const TIntrusiveConstPtr<NPage::TGarbageStats> GarbageStats; const TIntrusiveConstPtr<NPage::TTxIdStatsPage> TxIdStats; diff --git a/ydb/core/tablet_flat/flat_writer_blocks.h b/ydb/core/tablet_flat/flat_writer_blocks.h index 6f7bca85e43..1b7c144cb36 100644 --- a/ydb/core/tablet_flat/flat_writer_blocks.h +++ b/ydb/core/tablet_flat/flat_writer_blocks.h @@ -62,9 +62,10 @@ namespace NWriter { for (auto &glob : Writer.Grab()) Cone->Put(std::move(glob)); - if (NTable::TLoader::NeedIn(type)) { + // Note: for now we mark index pages sticky after we load them + if (NTable::TLoader::NeedIn(type) || type == EPage::Index) { Sticky.emplace_back(pageId, std::move(raw)); - } else if (bool(Cache) && type == EPage::DataPage) { + } else if (bool(Cache) && (type == EPage::DataPage)) { Regular.emplace_back(pageId, std::move(raw)); } diff --git a/ydb/core/tablet_flat/test/libs/table/test_store.h b/ydb/core/tablet_flat/test/libs/table/test_store.h index 0b6f6c9c555..ac4667d0abb 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_store.h +++ b/ydb/core/tablet_flat/test/libs/table/test_store.h @@ -26,7 +26,6 @@ namespace NTest { bool Rooted; TVector<TPageId> IndexGroupsPages; TVector<TPageId> IndexHistoricPages; - TData *Index; TData *Scheme; TData *Blobs; TData *ByKey; @@ -128,7 +127,6 @@ namespace NTest { Rooted, { Indexes.back() }, { }, - GetPage(MainPageCollection, Indexes.back()), GetPage(MainPageCollection, Scheme), GetPage(MainPageCollection, Globs), GetPage(MainPageCollection, ByKey), diff --git a/ydb/core/tablet_flat/test/libs/table/test_writer.h b/ydb/core/tablet_flat/test/libs/table/test_writer.h index e57925312a1..ed9e7ea1c49 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_writer.h +++ b/ydb/core/tablet_flat/test/libs/table/test_writer.h @@ -86,7 +86,6 @@ namespace NTest { epoch, TPartScheme::Parse(*eggs.Scheme, eggs.Rooted), { eggs.IndexGroupsPages, eggs.IndexHistoricPages }, - *eggs.Index, eggs.Blobs ? new TExtBlobs(*eggs.Blobs, { }) : nullptr, eggs.ByKey ? new TBloom(*eggs.ByKey) : nullptr, eggs.Large ? new TFrames(*eggs.Large) : nullptr, @@ -118,7 +117,6 @@ namespace NTest { if (lay.HasIndex()) { indexGroupsPages.push_back(lay.GetIndex()); } - for (ui32 pageId : lay.GetGroupIndexes()) { indexGroupsPages.push_back(pageId); } @@ -130,7 +128,6 @@ namespace NTest { true /* rooted page collection */, std::move(indexGroupsPages), std::move(indexHistoricPages), - Store->GetPage(0, lay.HasIndex() ? lay.GetIndex() : undef), Store->GetPage(0, lay.HasScheme() ? lay.GetScheme() : undef), Store->GetPage(0, lay.HasGlobs() ? lay.GetGlobs() : undef), Store->GetPage(0, lay.HasByKey() ? lay.GetByKey() : undef), |