Skip to content

Commit dbd56f6

Browse files
authored
Merge 2e614c8 into 6508540
2 parents 6508540 + 2e614c8 commit dbd56f6

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

ydb/core/driver_lib/run/run.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,11 @@ static TString ReadFile(const TString& fileName) {
495495
}
496496

497497
void TKikimrRunner::InitializeGracefulShutdown(const TKikimrRunConfig& runConfig) {
498-
Y_UNUSED(runConfig);
499498
GracefulShutdownSupported = true;
499+
const auto& config = runConfig.AppConfig.GetShutdownConfig();
500+
if (config.HasMinDelayBeforeShutdownSeconds()) {
501+
MinDelayBeforeShutdown = TDuration::Seconds(config.GetMinDelayBeforeShutdownSeconds());
502+
}
500503
}
501504

502505
void TKikimrRunner::InitializeKqpController(const TKikimrRunConfig& runConfig) {
@@ -1708,6 +1711,7 @@ void TKikimrRunner::KikimrStop(bool graceful) {
17081711
ActorSystem->Send(new IEventHandle(NGRpcService::CreateGrpcPublisherServiceActorId(), {}, new TEvents::TEvPoisonPill));
17091712
}
17101713

1714+
THPTimer timer;
17111715
TIntrusivePtr<TDrainProgress> drainProgress(new TDrainProgress());
17121716
if (AppData->FeatureFlags.GetEnableDrainOnShutdown() && GracefulShutdownSupported && ActorSystem) {
17131717
drainProgress->OnSend();
@@ -1741,6 +1745,12 @@ void TKikimrRunner::KikimrStop(bool graceful) {
17411745
}
17421746
}
17431747

1748+
// Wait for a minimum delay to make sure that clients forget about this node
1749+
auto passedTime = TDuration::Seconds(timer.Passed());
1750+
if (MinDelayBeforeShutdown > passedTime) {
1751+
Sleep(MinDelayBeforeShutdown - passedTime);
1752+
}
1753+
17441754
if (ActorSystem) {
17451755
ActorSystem->BroadcastToProxies([](const TActorId& proxyId) {
17461756
return new IEventHandle(proxyId, {}, new TEvInterconnect::TEvTerminate);

ydb/core/driver_lib/run/run.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class TKikimrRunner : public virtual TThrRefBase, private IGlobalObjectStorage {
4242

4343
bool EnabledGrpcService = false;
4444
bool GracefulShutdownSupported = false;
45+
TDuration MinDelayBeforeShutdown;
4546
THolder<NSQS::TAsyncHttpServer> SqsHttp;
4647

4748
THolder<NYdb::TDriver> YdbDriver;

ydb/core/protos/config.proto

+5
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,10 @@ message TMetadataCacheConfig {
18531853
optional uint64 RefreshPeriodMs = 1 [default = 15000];
18541854
}
18551855

1856+
message TShutdownConfig {
1857+
optional uint32 MinDelayBeforeShutdownSeconds = 1;
1858+
}
1859+
18561860
message TLabel {
18571861
optional string Name = 1;
18581862
optional string Value = 2;
@@ -1937,6 +1941,7 @@ message TAppConfig {
19371941
//optional TMemoryControllerConfig MemoryControllerConfig = 81; NB. exist in main
19381942
optional TGroupedMemoryLimiterConfig GroupedMemoryLimiterConfig = 82;
19391943
optional NKikimrReplication.TReplicationDefaults ReplicationConfig = 83;
1944+
optional TShutdownConfig ShutdownConfig = 84;
19401945

19411946
repeated TNamedConfig NamedConfigs = 100;
19421947
optional string ClusterYamlConfig = 101;

0 commit comments

Comments
 (0)