Skip to content

Commit bcae19f

Browse files
committed
KIKIMR-19520 Make indexes non-sticky initially
1 parent 285a2e6 commit bcae19f

File tree

8 files changed

+30
-51
lines changed

8 files changed

+30
-51
lines changed

ydb/core/tablet_flat/flat_executor_ut.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5156,15 +5156,17 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorStickyPages) {
51565156

51575157
int failedAttempts = 0;
51585158
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) });
5159-
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 20); // data pages only, 2 indexes are sticky
5159+
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 20); // 20 data pages, 2 index pages are sticky until restart
51605160

51615161
// restart tablet
51625162
env.SendSync(new TEvents::TEvPoison, false, true);
51635163
env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
51645164

5165-
// should have the same behaviour
51665165
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true);
5167-
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 20);
5166+
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 22); // 20 data pages and 2 index pages
5167+
5168+
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true);
5169+
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 20); // 20 data pages, 2 index pages are sticky again
51685170
}
51695171

51705172
Y_UNIT_TEST(TestSticky) {
@@ -5219,15 +5221,17 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorStickyPages) {
52195221

52205222
int failedAttempts = 0;
52215223
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) });
5222-
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 12); // 1 groups[0], 1 historic[0], 10 historic[1] pages, 4 indexes are sticky
5224+
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 12); // 1 groups[0], 1 historic[0], 10 historic[1] pages, 3 index pages are sticky until restart
52235225

52245226
// restart tablet
52255227
env.SendSync(new TEvents::TEvPoison, false, true);
52265228
env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
52275229

5228-
// should have the same behaviour
52295230
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true);
5230-
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 12);
5231+
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 15); // 1 groups[0], 1 historic[0], 10 historic[1] pages, 3 index pages
5232+
5233+
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true);
5234+
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 12); // 1 groups[0], 1 historic[0], 10 historic[1] pages, 3 index pages are sticky again
52315235
}
52325236

52335237
Y_UNIT_TEST(TestStickyMain) {
@@ -5284,15 +5288,17 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorStickyPages) {
52845288

52855289
int failedAttempts = 0;
52865290
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) });
5287-
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 2); // 1 groups[0], 1 historic[0], 4 indexes are sticky
5291+
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 2); // 1 groups[0], 1 historic[0], 3 index pages are sticky until restart
52885292

52895293
// restart tablet
52905294
env.SendSync(new TEvents::TEvPoison, false, true);
52915295
env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
52925296

5293-
// should have the same behaviour
52945297
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true);
5295-
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 2);
5298+
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 5); // 1 groups[0], 1 historic[0], 3 index pages
5299+
5300+
env.SendSync(new NFake::TEvExecute{ new TTxFullScan(failedAttempts) }, true);
5301+
UNIT_ASSERT_VALUES_EQUAL(failedAttempts, 2); // 1 groups[0], 1 historic[0], 3 index pages are sticky again
52965302
}
52975303

52985304
Y_UNIT_TEST(TestStickyAll) {

ydb/core/tablet_flat/flat_part_loader.cpp

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -124,58 +124,33 @@ TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept
124124
Y_VERIFY(Packs && Packs.front());
125125

126126
TVector<TPageId> load;
127-
for (auto page: { SchemeId, IndexId, GlobsId,
127+
for (auto page: { SchemeId, GlobsId,
128128
SmallId, LargeId, ByKeyId,
129129
GarbageStatsId, TxIdStatsId }) {
130130
if (page != Max<TPageId>() && !Packs[0]->Lookup(page))
131131
load.push_back(page);
132132
}
133-
for (auto page : GroupIndexesIds) {
134-
if (!Packs[0]->Lookup(page)) {
135-
load.push_back(page);
136-
}
137-
}
138-
for (auto page : HistoricIndexesIds) {
139-
if (!Packs[0]->Lookup(page)) {
140-
load.push_back(page);
141-
}
142-
}
143133

144134
if (load) {
145135
return new NPageCollection::TFetch{ 0, Packs[0]->PageCollection, std::move(load) };
146136
}
147137

148138
auto *scheme = GetPage(SchemeId);
149-
auto *index = GetPage(IndexId);
150139
auto *large = GetPage(LargeId);
151140
auto *small = GetPage(SmallId);
152141
auto *blobs = GetPage(GlobsId);
153142
auto *byKey = GetPage(ByKeyId);
154143
auto *garbageStats = GetPage(GarbageStatsId);
155144
auto *txIdStats = GetPage(TxIdStatsId);
156145

157-
if (scheme == nullptr || index == nullptr) {
158-
Y_FAIL("One of scheme or index pages is not loaded");
146+
if (scheme == nullptr) {
147+
Y_FAIL("Scheme page is not loaded");
159148
} else if (ByKeyId != Max<TPageId>() && !byKey) {
160149
Y_FAIL("Filter page must be loaded if it exists");
161150
} else if (small && Packs.size() != (1 + GroupIndexesIds.size() + 1)) {
162151
Y_Fail("TPart has small blobs, " << Packs.size() << " page collections");
163152
}
164153

165-
// TODO: stop load indexes
166-
for (auto pageId : GroupIndexesIds) {
167-
auto* page = GetPage(pageId);
168-
if (!page) {
169-
Y_Fail("Missing group index page " << pageId);
170-
}
171-
}
172-
for (auto pageId : HistoricIndexesIds) {
173-
auto* page = GetPage(pageId);
174-
if (!page) {
175-
Y_Fail("Missing historic index page " << pageId);
176-
}
177-
}
178-
179154
const auto extra = BlobsLabelFor(Packs[0]->PageCollection->Label());
180155

181156
auto *stat = Root.HasStat() ? &Root.GetStat() : nullptr;
@@ -202,7 +177,6 @@ TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept
202177
epoch,
203178
TPartScheme::Parse(*scheme, Rooted),
204179
{ std::move(groupIndexesIds), HistoricIndexesIds },
205-
*index,
206180
blobs ? new NPage::TExtBlobs(*blobs, extra) : nullptr,
207181
byKey ? new NPage::TBloom(*byKey) : nullptr,
208182
large ? new NPage::TFrames(*large) : nullptr,

ydb/core/tablet_flat/flat_part_loader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace NTable {
8383
constexpr static bool NeedIn(EPage page) noexcept
8484
{
8585
return
86-
page == EPage::Scheme || page == EPage::Index
86+
page == EPage::Scheme
8787
|| page == EPage::Frames || page == EPage::Globs
8888
|| page == EPage::Schem2 || page == EPage::Bloom
8989
|| page == EPage::GarbageStats

ydb/core/tablet_flat/flat_sausagecache.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ void TPrivatePageCache::DropSharedBody(TInfo *info, ui32 pageId) {
519519
TPrivatePageCache::TPage::TWaitQueuePtr TPrivatePageCache::ProvideBlock(
520520
NSharedCache::TEvResult::TLoaded&& loaded, TInfo *info)
521521
{
522+
using EPage = NTable::NPage::EPage;
523+
522524
Y_VERIFY_DEBUG(loaded.Page && loaded.Page.IsUsed());
523525
TPage *page = info->EnsurePage(loaded.PageId);
524526

@@ -534,7 +536,12 @@ TPrivatePageCache::TPage::TWaitQueuePtr TPrivatePageCache::ProvideBlock(
534536
if (Y_UNLIKELY(page->SharedPending))
535537
Stats.TotalSharedPending -= page->Size;
536538

537-
// N.B. we must be careful not to accidentally drop the sticky bit
539+
// Note: for now we mark index pages sticky after we load them
540+
if (!page->Sticky && EPage(info->PageCollection->Page(page->Id).Type) == EPage::Index) {
541+
MarkSticky(page->Id, info);
542+
}
543+
544+
// Note: we must be careful not to accidentally drop the sticky bit
538545
page->Fill(std::move(loaded.Page), page->Sticky);
539546
Stats.TotalSharedBody += page->Size;
540547
Stats.TotalPinnedBody += page->Size;

ydb/core/tablet_flat/flat_table_part.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ namespace NTable {
5656
TEpoch Epoch;
5757
TIntrusiveConstPtr<TPartScheme> Scheme;
5858
TIndexPages IndexPages;
59-
TSharedData Index;
6059
TIntrusiveConstPtr<NPage::TExtBlobs> Blobs;
6160
TIntrusiveConstPtr<NPage::TBloom> ByKey;
6261
TIntrusiveConstPtr<NPage::TFrames> Large;
@@ -85,7 +84,6 @@ namespace NTable {
8584
, Large(std::move(params.Large))
8685
, Small(std::move(params.Small))
8786
, IndexPages(std::move(params.IndexPages))
88-
, Index(std::move(params.Index))
8987
, ByKey(std::move(params.ByKey))
9088
, GarbageStats(std::move(params.GarbageStats))
9189
, TxIdStats(std::move(params.TxIdStats))
@@ -140,7 +138,6 @@ namespace NTable {
140138
, Large(src.Large)
141139
, Small(src.Small)
142140
, IndexPages(src.IndexPages)
143-
, Index(src.Index)
144141
, ByKey(src.ByKey)
145142
, GarbageStats(src.GarbageStats)
146143
, Stat(src.Stat)
@@ -159,7 +156,6 @@ namespace NTable {
159156
const TIntrusiveConstPtr<NPage::TFrames> Large;
160157
const TIntrusiveConstPtr<NPage::TFrames> Small;
161158
const TIndexPages IndexPages;
162-
const NPage::TIndex Index;
163159
const TIntrusiveConstPtr<NPage::TBloom> ByKey;
164160
const TIntrusiveConstPtr<NPage::TGarbageStats> GarbageStats;
165161
const TIntrusiveConstPtr<NPage::TTxIdStatsPage> TxIdStats;

ydb/core/tablet_flat/flat_writer_blocks.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ namespace NWriter {
6262
for (auto &glob : Writer.Grab())
6363
Cone->Put(std::move(glob));
6464

65-
if (NTable::TLoader::NeedIn(type)) {
65+
// Note: for now we mark index pages sticky after we load them
66+
if (NTable::TLoader::NeedIn(type) || type == EPage::Index) {
6667
Sticky.emplace_back(pageId, std::move(raw));
67-
} else if (bool(Cache) && type == EPage::DataPage) {
68+
} else if (bool(Cache) && (type == EPage::DataPage)) {
6869
Regular.emplace_back(pageId, std::move(raw));
6970
}
7071

ydb/core/tablet_flat/test/libs/table/test_store.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ namespace NTest {
2626
bool Rooted;
2727
TVector<TPageId> IndexGroupsPages;
2828
TVector<TPageId> IndexHistoricPages;
29-
TData *Index;
3029
TData *Scheme;
3130
TData *Blobs;
3231
TData *ByKey;
@@ -128,7 +127,6 @@ namespace NTest {
128127
Rooted,
129128
{ Indexes.back() },
130129
{ },
131-
GetPage(MainPageCollection, Indexes.back()),
132130
GetPage(MainPageCollection, Scheme),
133131
GetPage(MainPageCollection, Globs),
134132
GetPage(MainPageCollection, ByKey),

ydb/core/tablet_flat/test/libs/table/test_writer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ namespace NTest {
8686
epoch,
8787
TPartScheme::Parse(*eggs.Scheme, eggs.Rooted),
8888
{ eggs.IndexGroupsPages, eggs.IndexHistoricPages },
89-
*eggs.Index,
9089
eggs.Blobs ? new TExtBlobs(*eggs.Blobs, { }) : nullptr,
9190
eggs.ByKey ? new TBloom(*eggs.ByKey) : nullptr,
9291
eggs.Large ? new TFrames(*eggs.Large) : nullptr,
@@ -118,7 +117,6 @@ namespace NTest {
118117
if (lay.HasIndex()) {
119118
indexGroupsPages.push_back(lay.GetIndex());
120119
}
121-
122120
for (ui32 pageId : lay.GetGroupIndexes()) {
123121
indexGroupsPages.push_back(pageId);
124122
}
@@ -130,7 +128,6 @@ namespace NTest {
130128
true /* rooted page collection */,
131129
std::move(indexGroupsPages),
132130
std::move(indexHistoricPages),
133-
Store->GetPage(0, lay.HasIndex() ? lay.GetIndex() : undef),
134131
Store->GetPage(0, lay.HasScheme() ? lay.GetScheme() : undef),
135132
Store->GetPage(0, lay.HasGlobs() ? lay.GetGlobs() : undef),
136133
Store->GetPage(0, lay.HasByKey() ? lay.GetByKey() : undef),

0 commit comments

Comments
 (0)