summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkungasc <[email protected]>2023-10-09 11:46:37 +0300
committerkungasc <[email protected]>2023-10-09 12:34:03 +0300
commite4592d6bd86384da2667f8399b41ca65858f3ee8 (patch)
tree4cb15fffb7061c4215985770b70dd77a36e4c27e
parent1376331995d16f9fed16d5c84799d212469e7b7c (diff)
KIKIMR-19520 Bugfix: Set sticky for index pages before loading them to avoid including in transaction consumption
-rw-r--r--ydb/core/tablet_flat/flat_executor_ut.cpp7
-rw-r--r--ydb/core/tablet_flat/flat_sausagecache.cpp15
2 files changed, 15 insertions, 7 deletions
diff --git a/ydb/core/tablet_flat/flat_executor_ut.cpp b/ydb/core/tablet_flat/flat_executor_ut.cpp
index 1641c59c7e7..4371aed1486 100644
--- a/ydb/core/tablet_flat/flat_executor_ut.cpp
+++ b/ydb/core/tablet_flat/flat_executor_ut.cpp
@@ -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);
}
diff --git a/ydb/core/tablet_flat/flat_sausagecache.cpp b/ydb/core/tablet_flat/flat_sausagecache.cpp
index cbde110cd06..93cef08a695 100644
--- a/ydb/core/tablet_flat/flat_sausagecache.cpp
+++ b/ydb/core/tablet_flat/flat_sausagecache.cpp
@@ -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);
@@ -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;
@@ -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);
@@ -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;