Skip to content

use adaptive timeouts and persistent node count in hive warmup KIKIMR-20551 #624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions ydb/core/mind/hive/hive_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,31 @@ void THive::DeleteTabletWithoutStorage(TLeaderTabletInfo* tablet, TSideEffects&
sideEffects.Send(SelfId(), new TEvTabletBase::TEvDeleteTabletResult(NKikimrProto::OK, tablet->Id));
}

TInstant THive::GetAllowedBootingTime() {
TDuration passed = LastConnect - StartTime();
i64 connectedNodes = TabletCounters->Simple()[NHive::COUNTER_NODES_CONNECTED].Get();
BLOG_D(connectedNodes << " nodes connected out of " << ExpectedNodes);
if (connectedNodes == 0) {
return {};
}
TDuration avgConnectTime = passed / connectedNodes;
TInstant result = LastConnect + avgConnectTime * std::max<i64>(ExpectedNodes - connectedNodes, 1);
if (connectedNodes < ExpectedNodes) {
result = std::max(result, StartTime() + GetMaxWarmUpPeriod());
}
return result;
}

void THive::ExecuteProcessBootQueue(NIceDb::TNiceDb& db, TSideEffects& sideEffects) {
TInstant now = TActivationContext::Now();
TInstant allowed = std::min(LastConnect + GetWarmUpBootWaitingPeriod(), StartTime() + GetMaxWarmUpPeriod());
if (WarmUp && now < allowed) {
BLOG_D("ProcessBootQueue - last connect was at " << LastConnect << "- not long enough ago");
ProcessBootQueueScheduled = false;
PostponeProcessBootQueue(allowed - now);
return;
if (WarmUp) {
TInstant allowed = GetAllowedBootingTime();
if (now < allowed) {
BLOG_D("ProcessBootQueue - waiting unitl " << allowed << " because of warmup, now: " << now);
ProcessBootQueueScheduled = false;
PostponeProcessBootQueue(allowed - now);
return;
}
}
BLOG_D("Handle ProcessBootQueue (size: " << BootQueue.BootQueue.size() << ")");
THPTimer bootQueueProcessingTimer;
Expand Down Expand Up @@ -302,9 +319,11 @@ void THive::ProcessBootQueue() {
}

void THive::PostponeProcessBootQueue(TDuration after) {
if (!ProcessBootQueuePostponed) {
TInstant postponeUntil = TActivationContext::Now() + after;
if (!ProcessBootQueuePostponed || postponeUntil < ProcessBootQueuePostponedUntil) {
BLOG_D("PostponeProcessBootQueue (" << after << ")");
ProcessBootQueuePostponed = true;
ProcessBootQueuePostponedUntil = postponeUntil;
Schedule(after, new TEvPrivate::TEvPostponeProcessBootQueue());
}
}
Expand Down
3 changes: 3 additions & 0 deletions ydb/core/mind/hive/hive_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ class THive : public TActor<THive>, public TTabletExecutedFlat, public THiveShar
bool ProcessBootQueueScheduled = false;
bool ProcessBootQueuePostponed = false;
TInstant LastConnect;
TInstant ProcessBootQueuePostponedUntil;
bool WarmUp;
i64 ExpectedNodes;

THashMap<ui32, TEvInterconnect::TNodeInfo> NodesInfo;
TTabletCountersBase* TabletCounters;
Expand Down Expand Up @@ -901,6 +903,7 @@ class THive : public TActor<THive>, public TTabletExecutedFlat, public THiveShar
void ScheduleDisconnectNode(THolder<TEvPrivate::TEvProcessDisconnectNode> event);
void DeleteTabletWithoutStorage(TLeaderTabletInfo* tablet);
void DeleteTabletWithoutStorage(TLeaderTabletInfo* tablet, TSideEffects& sideEffects);
TInstant GetAllowedBootingTime();
void ScheduleUnlockTabletExecution(TNodeInfo& node);
TString DebugDomainsActiveNodes() const;
TResourceNormalizedValues GetStDevResourceValues() const;
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/mind/hive/hive_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {
TMailboxType::Simple, 0,
TMailboxType::Simple, 0);
TTenantPoolConfig::TPtr tenantPoolConfig = new TTenantPoolConfig(localConfig);
// tenantPoolConfig->AddStaticSlot(DOMAIN_NAME);
tenantPoolConfig->AddStaticSlot(tenant);

TActorId actorId = runtime.Register(
Expand Down Expand Up @@ -1877,6 +1878,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {

Ctest << "killing tablet " << tabletId << Endl;
runtime.Register(CreateTabletKiller(tabletId, runtime.GetNodeId(0)));
// runtime.Register(CreateTabletKiller(tabletId, runtime.GetNodeId(1)));

waitFor([&]{ return blockedCommits.size() >= 2; }, "at least 2 blocked commits");

Expand Down
3 changes: 2 additions & 1 deletion ydb/core/mind/hive/tx__load_everything.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,8 @@ class TTxLoadEverything : public TTransactionBase<THive> {
Self->SetCounterTabletsTotal(tabletsTotal);
Self->TabletCounters->Simple()[NHive::COUNTER_SEQUENCE_FREE].Set(Self->Sequencer.FreeSize());
Self->TabletCounters->Simple()[NHive::COUNTER_SEQUENCE_ALLOCATED].Set(Self->Sequencer.AllocatedSequencesSize());
Self->TabletCounters->Simple()[NHive::COUNTER_NODES_TOTAL].Set(Self->Nodes.size());
Self->ExpectedNodes = Self->Nodes.size();
Self->TabletCounters->Simple()[NHive::COUNTER_NODES_TOTAL].Set(Self->ExpectedNodes);
Self->MigrationState = NKikimrHive::EMigrationState::MIGRATION_READY;
ctx.Send(Self->SelfId(), new TEvPrivate::TEvBootTablets());

Expand Down