@@ -177,14 +177,30 @@ void THive::DeleteTabletWithoutStorage(TLeaderTabletInfo* tablet, TSideEffects&
177
177
sideEffects.Send (SelfId (), new TEvTabletBase::TEvDeleteTabletResult (NKikimrProto::OK, tablet->Id ));
178
178
}
179
179
180
+ TInstant THive::GetAllowedBootingTime () {
181
+ auto connectedNodes = TabletCounters->Simple ()[NHive::COUNTER_NODES_CONNECTED].Get ();
182
+ BLOG_D (connectedNodes << " nodes connected out of " << ExpectedNodes);
183
+ if (connectedNodes == 0 ) {
184
+ return {};
185
+ }
186
+ TInstant result = LastConnect + MaxTimeBetweenConnects * std::max<i64>(static_cast <i64>(ExpectedNodes) - static_cast <i64>(connectedNodes), 1 );
187
+ if (connectedNodes < ExpectedNodes) {
188
+ result = std::max (result, StartTime () + GetWarmUpBootWaitingPeriod ());
189
+ }
190
+ result = std::min (result, StartTime () + GetMaxWarmUpPeriod ());
191
+ return result;
192
+ }
193
+
180
194
void THive::ExecuteProcessBootQueue (NIceDb::TNiceDb& db, TSideEffects& sideEffects) {
181
195
TInstant now = TActivationContext::Now ();
182
- TInstant allowed = std::min (LastConnect + GetWarmUpBootWaitingPeriod (), StartTime () + GetMaxWarmUpPeriod ());
183
- if (WarmUp && now < allowed) {
184
- BLOG_D (" ProcessBootQueue - last connect was at " << LastConnect << " - not long enough ago" );
185
- ProcessBootQueueScheduled = false ;
186
- PostponeProcessBootQueue (allowed - now);
187
- return ;
196
+ if (WarmUp) {
197
+ TInstant allowed = GetAllowedBootingTime ();
198
+ if (now < allowed) {
199
+ BLOG_D (" ProcessBootQueue - waiting until " << allowed << " because of warmup, now: " << now);
200
+ ProcessBootQueueScheduled = false ;
201
+ PostponeProcessBootQueue (allowed - now);
202
+ return ;
203
+ }
188
204
}
189
205
BLOG_D (" Handle ProcessBootQueue (size: " << BootQueue.BootQueue .size () << " )" );
190
206
THPTimer bootQueueProcessingTimer;
@@ -304,9 +320,11 @@ void THive::ProcessBootQueue() {
304
320
}
305
321
306
322
void THive::PostponeProcessBootQueue (TDuration after) {
307
- if (!ProcessBootQueuePostponed) {
323
+ TInstant postponeUntil = TActivationContext::Now () + after;
324
+ if (!ProcessBootQueuePostponed || postponeUntil < ProcessBootQueuePostponedUntil) {
308
325
BLOG_D (" PostponeProcessBootQueue (" << after << " )" );
309
326
ProcessBootQueuePostponed = true ;
327
+ ProcessBootQueuePostponedUntil = postponeUntil;
310
328
Schedule (after, new TEvPrivate::TEvPostponeProcessBootQueue ());
311
329
}
312
330
}
0 commit comments