@@ -177,11 +177,17 @@ namespace NKikimr {
177177
178178namespace {
179179
180- void StopGRpcServers (std::weak_ptr<TGRpcServersWrapper> grpcServersWrapper) {
180+ void StopGRpcServers (std::weak_ptr<TGRpcServersWrapper> grpcServersWrapper, bool isDisabled = false ) {
181181 auto wrapper = grpcServersWrapper.lock ();
182182 if (!wrapper) {
183183 return ;
184184 }
185+ if (wrapper->IsDisabled .load (std::memory_order_acquire)) {
186+ return ;
187+ }
188+ if (isDisabled) {
189+ wrapper->IsDisabled .store (true , std::memory_order_release);
190+ }
185191 TGuard<TMutex> guard = wrapper->Guard ();
186192 for (auto & [name, server] : wrapper->Servers ) {
187193 if (!server) {
@@ -191,7 +197,6 @@ namespace {
191197 }
192198 wrapper->Servers .clear ();
193199 }
194-
195200}
196201
197202class TGRpcServersManager : public TActorBootstrapped <TGRpcServersManager> {
@@ -265,6 +270,9 @@ class TGRpcServersManager : public TActorBootstrapped<TGRpcServersManager> {
265270 if (!wrapper) {
266271 return ;
267272 }
273+ if (wrapper->IsDisabled .load (std::memory_order_acquire)) {
274+ return ;
275+ }
268276 TGuard<TMutex> guard = wrapper->Guard ();
269277 wrapper->Servers = wrapper->GrpcServersFactory ();
270278 for (auto & [name, server] : wrapper->Servers ) {
@@ -317,6 +325,7 @@ class TGRpcServersManager : public TActorBootstrapped<TGRpcServersManager> {
317325 hFunc(TEvStop, HandleStop)
318326 cFunc(TEvGRpcServersManager::EvDisconnectRequestStarted, HandleDisconnectRequestStarted)
319327 cFunc(TEvGRpcServersManager::EvDisconnectRequestFinished, HandleDisconnectRequestFinished)
328+ cFunc(TEvents::TSystem::PoisonPill, PassAway)
320329 )
321330};
322331
@@ -2153,14 +2162,13 @@ void TKikimrRunner::KikimrStop(bool graceful) {
21532162 SqsHttp.Destroy ();
21542163 }
21552164
2156- if (ActorSystem) {
2157- ActorSystem->Stop ();
2158- }
2159-
21602165 // stop processing grpc requests/response - we must stop feeding ActorSystem
21612166 if (GRpcServersManager) {
2162- StopGRpcServers (GRpcServersWrapper);
2163- GRpcServersWrapper->Servers .clear ();
2167+ StopGRpcServers (GRpcServersWrapper, true );
2168+ }
2169+
2170+ if (ActorSystem) {
2171+ ActorSystem->Stop ();
21642172 }
21652173
21662174 if (YqSharedResources) {
0 commit comments