Skip to content

Commit 0bf777f

Browse files
authored
lower boot priority for delayed tablets (#6491)
1 parent b81dfa9 commit 0bf777f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

ydb/core/mind/hive/hive_impl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ void THive::ExecuteProcessBootQueue(NIceDb::TNiceDb& db, TSideEffects& sideEffec
228228
TStackVec<TBootQueue::TBootQueueRecord> delayedTablets;
229229
while (!BootQueue.BootQueue.empty() && processedItems < GetMaxBootBatchSize()) {
230230
TBootQueue::TBootQueueRecord record = BootQueue.PopFromBootQueue();
231+
BLOG_TRACE("Tablet " << record.TabletId << "." << record.FollowerId << " has priority " << record.Priority);
231232
++processedItems;
232233
TTabletInfo* tablet = FindTablet(record.TabletId, record.FollowerId);
233234
if (tablet == nullptr) {
@@ -277,6 +278,7 @@ void THive::ExecuteProcessBootQueue(NIceDb::TNiceDb& db, TSideEffects& sideEffec
277278
}
278279
}
279280
for (TBootQueue::TBootQueueRecord record : delayedTablets) {
281+
record.Priority -= 1;
280282
BootQueue.AddToBootQueue(record);
281283
}
282284
if (TabletCounters != nullptr) {

ydb/core/mind/hive/hive_ut.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,6 +3253,41 @@ Y_UNIT_TEST_SUITE(THiveTest) {
32533253
}
32543254
}
32553255

3256+
Y_UNIT_TEST(TestRestartsWithFollower) {
3257+
static constexpr ui64 NUM_NODES = 3;
3258+
TTestBasicRuntime runtime(NUM_NODES, false);
3259+
Setup(runtime, true, 3, [](TAppPrepare& app) {
3260+
app.HiveConfig.SetMaxBootBatchSize(1);
3261+
});
3262+
TVector<ui64> tabletIds;
3263+
const ui64 hiveTablet = MakeDefaultHiveID();
3264+
const ui64 testerTablet = MakeTabletID(false, 1);
3265+
CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive);
3266+
{
3267+
TDispatchOptions options;
3268+
options.FinalEvents.emplace_back(TEvLocal::EvSyncTablets, runtime.GetNodeCount());
3269+
runtime.DispatchEvents(options);
3270+
}
3271+
TTabletTypes::EType tabletType = TTabletTypes::Dummy;
3272+
THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS));
3273+
auto* followerGroup = ev->Record.AddFollowerGroups();
3274+
followerGroup->SetFollowerCount(3);
3275+
followerGroup->SetAllowLeaderPromotion(true);
3276+
ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true);
3277+
for (unsigned i = 1; i < 10; ++i) {
3278+
auto nodeIdx = 1 + (i % 2);
3279+
Ctest << "Killing node " << nodeIdx << Endl;
3280+
SendKillLocal(runtime, nodeIdx);
3281+
MakeSureTabletIsUp(runtime, tabletId, 0);
3282+
CreateLocal(runtime, nodeIdx);
3283+
}
3284+
for (unsigned i = 0; i < NUM_NODES; ++i) {
3285+
SendKillLocal(runtime, i);
3286+
}
3287+
CreateLocal(runtime, 0);
3288+
MakeSureTabletIsUp(runtime, tabletId, 0);
3289+
}
3290+
32563291
Y_UNIT_TEST(TestStartTabletTwiceInARow) {
32573292
TTestBasicRuntime runtime(1, false);
32583293
Setup(runtime, true);

0 commit comments

Comments
 (0)