@@ -497,6 +497,7 @@ void THive::Handle(TEvPrivate::TEvBootTablets::TPtr&) {
497497 for (auto * node : unimportantNodes) {
498498 node->Ping ();
499499 }
500+ ProcessNodePingQueue ();
500501 TVector<TTabletId> tabletsToReleaseFromParent;
501502 TSideEffects sideEffects;
502503 sideEffects.Reset (SelfId ());
@@ -687,11 +688,13 @@ void THive::Cleanup() {
687688
688689void THive::Handle (TEvLocal::TEvStatus::TPtr& ev) {
689690 BLOG_D (" Handle TEvLocal::TEvStatus for Node " << ev->Sender .NodeId () << " : " << ev->Get ()->Record .ShortDebugString ());
691+ RemoveFromPingInProgress (ev->Sender .NodeId ());
690692 Execute (CreateStatus (ev->Sender , ev->Get ()->Record ));
691693}
692694
693695void THive::Handle (TEvLocal::TEvSyncTablets::TPtr& ev) {
694696 BLOG_D (" THive::Handle::TEvSyncTablets" );
697+ RemoveFromPingInProgress (ev->Sender .NodeId ());
695698 Execute (CreateSyncTablets (ev->Sender , ev->Get ()->Record ));
696699}
697700
@@ -745,6 +748,7 @@ void THive::Handle(TEvInterconnect::TEvNodeConnected::TPtr &ev) {
745748void THive::Handle (TEvInterconnect::TEvNodeDisconnected::TPtr &ev) {
746749 TNodeId nodeId = ev->Get ()->NodeId ;
747750 BLOG_W (" Handle TEvInterconnect::TEvNodeDisconnected, NodeId " << nodeId);
751+ RemoveFromPingInProgress (nodeId);
748752 if (ConnectedNodes.erase (nodeId)) {
749753 UpdateCounterNodesConnected (-1 );
750754 }
@@ -917,6 +921,7 @@ void THive::Handle(TEvents::TEvUndelivered::TPtr &ev) {
917921 case TEvLocal::EvPing: {
918922 TNodeId nodeId = ev->Cookie ;
919923 TNodeInfo* node = FindNode (nodeId);
924+ NodePingsInProgress.erase (nodeId);
920925 if (node != nullptr && ev->Sender == node->Local ) {
921926 if (node->IsDisconnecting ()) {
922927 // ping continiousily until we fully disconnected from the node
@@ -925,6 +930,7 @@ void THive::Handle(TEvents::TEvUndelivered::TPtr &ev) {
925930 KillNode (node->Id , node->Local );
926931 }
927932 }
933+ ProcessNodePingQueue ();
928934 break ;
929935 }
930936 };
@@ -1696,6 +1702,13 @@ void THive::UpdateCounterTabletsStarting(i64 tabletsStartingDiff) {
16961702 }
16971703}
16981704
1705+ void THive::UpdateCounterPingQueueSize () {
1706+ if (TabletCounters != nullptr ) {
1707+ auto & counter = TabletCounters->Simple ()[NHive::COUNTER_PINGQUEUE_SIZE];
1708+ counter.Set (NodePingQueue.size ());
1709+ }
1710+ }
1711+
16991712void THive::RecordTabletMove (const TTabletMoveInfo& moveInfo) {
17001713 TabletMoveHistory.PushBack (moveInfo);
17011714 TabletCounters->Cumulative ()[NHive::COUNTER_TABLETS_MOVED].Increment (1 );
@@ -2672,6 +2685,25 @@ void THive::ExecuteStartTablet(TFullTabletId tabletId, const TActorId& local, ui
26722685 Execute (CreateStartTablet (tabletId, local, cookie, external));
26732686}
26742687
2688+ void THive::QueuePing (const TActorId& local) {
2689+ NodePingQueue.push (local);
2690+ }
2691+
2692+ void THive::ProcessNodePingQueue () {
2693+ while (!NodePingQueue.empty () && NodePingsInProgress.size () < GetMaxPingsInFlight ()) {
2694+ TActorId local = NodePingQueue.front ();
2695+ TNodeId node = local.NodeId ();
2696+ NodePingQueue.pop ();
2697+ NodePingsInProgress.insert (node);
2698+ SendPing (local, node);
2699+ }
2700+ }
2701+
2702+ void THive::RemoveFromPingInProgress (TNodeId node) {
2703+ NodePingsInProgress.erase (node);
2704+ ProcessNodePingQueue ();
2705+ }
2706+
26752707void THive::SendPing (const TActorId& local, TNodeId id) {
26762708 Send (local,
26772709 new TEvLocal::TEvPing (HiveId,
0 commit comments