Skip to content

Commit 8f8f260

Browse files
authored
Merge eaf9dfa into 9585917
2 parents 9585917 + eaf9dfa commit 8f8f260

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

ydb/core/driver_lib/run/run.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,11 @@ static TString ReadFile(const TString& fileName) {
502502
}
503503

504504
void TKikimrRunner::InitializeGracefulShutdown(const TKikimrRunConfig& runConfig) {
505-
Y_UNUSED(runConfig);
506505
GracefulShutdownSupported = true;
506+
const auto& config = runConfig.AppConfig.GetShutdownConfig();
507+
if (config.HasMinDelayBeforeShutdownSeconds()) {
508+
MinDelayBeforeShutdown = TDuration::Seconds(config.GetMinDelayBeforeShutdownSeconds());
509+
}
507510
}
508511

509512
void TKikimrRunner::InitializeKqpController(const TKikimrRunConfig& runConfig) {
@@ -1734,6 +1737,7 @@ void TKikimrRunner::KikimrStop(bool graceful) {
17341737
ActorSystem->Send(new IEventHandle(NGRpcService::CreateGrpcPublisherServiceActorId(), {}, new TEvents::TEvPoisonPill));
17351738
}
17361739

1740+
THPTimer timer;
17371741
TIntrusivePtr<TDrainProgress> drainProgress(new TDrainProgress());
17381742
if (AppData->FeatureFlags.GetEnableDrainOnShutdown() && GracefulShutdownSupported && ActorSystem) {
17391743
drainProgress->OnSend();
@@ -1767,6 +1771,10 @@ void TKikimrRunner::KikimrStop(bool graceful) {
17671771
}
17681772
}
17691773

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+
17701778
if (ActorSystem) {
17711779
ActorSystem->BroadcastToProxies([](const TActorId& proxyId) {
17721780
return new IEventHandle(proxyId, {}, new TEvInterconnect::TEvTerminate);

ydb/core/driver_lib/run/run.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class TKikimrRunner : public virtual TThrRefBase, private IGlobalObjectStorage {
4343

4444
bool EnabledGrpcService = false;
4545
bool GracefulShutdownSupported = false;
46+
TDuration MinDelayBeforeShutdown;
4647
THolder<NSQS::TAsyncHttpServer> SqsHttp;
4748

4849
THolder<NYdb::TDriver> YdbDriver;

ydb/core/protos/config.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,6 +1935,10 @@ message TMetadataCacheConfig {
19351935
optional uint64 RefreshPeriodMs = 1 [default = 15000];
19361936
}
19371937

1938+
message TShutdownConfig {
1939+
optional uint32 MinDelayBeforeShutdownSeconds = 1;
1940+
}
1941+
19381942
message TLabel {
19391943
optional string Name = 1;
19401944
optional string Value = 2;
@@ -2019,6 +2023,7 @@ message TAppConfig {
20192023
optional TMemoryControllerConfig MemoryControllerConfig = 81;
20202024
optional TGroupedMemoryLimiterConfig GroupedMemoryLimiterConfig = 82;
20212025
optional NKikimrReplication.TReplicationDefaults ReplicationConfig = 83;
2026+
optional TShutdownConfig ShutdownConfig = 84;
20222027

20232028
repeated TNamedConfig NamedConfigs = 100;
20242029
optional string ClusterYamlConfig = 101;

0 commit comments

Comments
 (0)