Skip to content

Commit

Permalink
KIKIMR-19520 Bugfix: Set sticky for index pages before loading them t…
Browse files Browse the repository at this point in the history
…o avoid including in transaction consumption
  • Loading branch information
kunga committed Oct 9, 2023
1 parent 1376331 commit e4592d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 7 additions & 0 deletions ydb/core/tablet_flat/flat_executor_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,13 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorIndexLoading) {
env.SendSync(new NFake::TEvExecute(new NTestSuiteTFlatTableExecutorResourceProfile::TTxSetResourceProfile("zero")));
env.SendSync(new NFake::TEvExecute{ new TTxPrechargeAndSeek() });

// 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 TTxPrechargeAndSeek() }, true);

// If we didn't crash, then assume the test succeeded
env.SendSync(new TEvents::TEvPoison, false, true);
}
Expand Down
15 changes: 8 additions & 7 deletions ydb/core/tablet_flat/flat_sausagecache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ void TPrivatePageCache::TPrivatePageCache::TryShareBody(TPage *page) {
}

const TSharedData* TPrivatePageCache::Lookup(ui32 pageId, TInfo *info) {
using EPage = NTable::NPage::EPage;

TPage *page = info->EnsurePage(pageId);

TryLoad(page);
Expand All @@ -319,6 +321,12 @@ const TSharedData* TPrivatePageCache::Lookup(ui32 pageId, TInfo *info) {

if (page->Empty()) {
ToLoad.PushBack(page);

// Note: for now we mark index pages sticky before we load them
if (!page->Sticky && EPage(info->PageCollection->Page(page->Id).Type) == EPage::Index) {
MarkSticky(page->Id, info);
}

Stats.CurrentCacheMisses++;
}
return nullptr;
Expand Down Expand Up @@ -519,8 +527,6 @@ 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);

Expand All @@ -536,11 +542,6 @@ TPrivatePageCache::TPage::TWaitQueuePtr TPrivatePageCache::ProvideBlock(
if (Y_UNLIKELY(page->SharedPending))
Stats.TotalSharedPending -= page->Size;

// 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;
Expand Down

0 comments on commit e4592d6

Please sign in to comment.