@@ -502,10 +502,10 @@ static TString ReadFile(const TString& fileName) {
502502}
503503
504504void TKikimrRunner::InitializeGracefulShutdown (const TKikimrRunConfig& runConfig) {
505- Y_UNUSED (runConfig);
506505 GracefulShutdownSupported = true ;
507- if (runConfig.AppConfig .HasDelayBeforeShutdownSeconds ()) {
508- DelayBeforeShutdown = TDuration::Seconds (runConfig.AppConfig .GetDelayBeforeShutdownSeconds ());
506+ const auto & config = runConfig.AppConfig .GetShutdownConfig ();
507+ if (config.HasMinDelayBeforeShutdownSeconds ()) {
508+ MinDelayBeforeShutdown = TDuration::Seconds (config.GetMinDelayBeforeShutdownSeconds ());
509509 }
510510}
511511
@@ -1735,9 +1735,9 @@ void TKikimrRunner::KikimrStop(bool graceful) {
17351735
17361736 if (EnabledGrpcService) {
17371737 ActorSystem->Send (new IEventHandle (NGRpcService::CreateGrpcPublisherServiceActorId (), {}, new TEvents::TEvPoisonPill));
1738- Sleep (DelayBeforeShutdown);
17391738 }
17401739
1740+ THPTimer timer;
17411741 TIntrusivePtr<TDrainProgress> drainProgress (new TDrainProgress ());
17421742 if (AppData->FeatureFlags .GetEnableDrainOnShutdown () && GracefulShutdownSupported && ActorSystem) {
17431743 drainProgress->OnSend ();
@@ -1771,6 +1771,10 @@ void TKikimrRunner::KikimrStop(bool graceful) {
17711771 }
17721772 }
17731773
1774+ // Wait for a minimum delay to make sure that clients forget about this node
1775+ auto timeLeftBeforeShutdown = MinDelayBeforeShutdown - TDuration::Seconds (timer.Passed ());
1776+ Sleep (timeLeftBeforeShutdown);
1777+
17741778 if (ActorSystem) {
17751779 ActorSystem->BroadcastToProxies ([](const TActorId& proxyId) {
17761780 return new IEventHandle (proxyId, {}, new TEvInterconnect::TEvTerminate);
0 commit comments