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