@@ -495,6 +495,7 @@ void THive::Handle(TEvPrivate::TEvBootTablets::TPtr&) {
495495 for (auto * node : unimportantNodes) {
496496 node->Ping ();
497497 }
498+ ProcessNodePingQueue ();
498499 TVector<TTabletId> tabletsToReleaseFromParent;
499500 TSideEffects sideEffects;
500501 sideEffects.Reset (SelfId ());
@@ -685,11 +686,13 @@ void THive::Cleanup() {
685686
686687void THive::Handle (TEvLocal::TEvStatus::TPtr& ev) {
687688 BLOG_D (" Handle TEvLocal::TEvStatus for Node " << ev->Sender .NodeId () << " : " << ev->Get ()->Record .ShortDebugString ());
689+ RemoveFromPingInProgress (ev->Sender .NodeId ());
688690 Execute (CreateStatus (ev->Sender , ev->Get ()->Record ));
689691}
690692
691693void THive::Handle (TEvLocal::TEvSyncTablets::TPtr& ev) {
692694 BLOG_D (" THive::Handle::TEvSyncTablets" );
695+ RemoveFromPingInProgress (ev->Sender .NodeId ());
693696 Execute (CreateSyncTablets (ev->Sender , ev->Get ()->Record ));
694697}
695698
@@ -743,6 +746,7 @@ void THive::Handle(TEvInterconnect::TEvNodeConnected::TPtr &ev) {
743746void THive::Handle (TEvInterconnect::TEvNodeDisconnected::TPtr &ev) {
744747 TNodeId nodeId = ev->Get ()->NodeId ;
745748 BLOG_W (" Handle TEvInterconnect::TEvNodeDisconnected, NodeId " << nodeId);
749+ RemoveFromPingInProgress (nodeId);
746750 if (ConnectedNodes.erase (nodeId)) {
747751 UpdateCounterNodesConnected (-1 );
748752 }
@@ -915,6 +919,7 @@ void THive::Handle(TEvents::TEvUndelivered::TPtr &ev) {
915919 case TEvLocal::EvPing: {
916920 TNodeId nodeId = ev->Cookie ;
917921 TNodeInfo* node = FindNode (nodeId);
922+ NodePingsInProgress.erase (nodeId);
918923 if (node != nullptr && ev->Sender == node->Local ) {
919924 if (node->IsDisconnecting ()) {
920925 // ping continiousily until we fully disconnected from the node
@@ -923,6 +928,7 @@ void THive::Handle(TEvents::TEvUndelivered::TPtr &ev) {
923928 KillNode (node->Id , node->Local );
924929 }
925930 }
931+ ProcessNodePingQueue ();
926932 break ;
927933 }
928934 };
@@ -1686,6 +1692,13 @@ void THive::UpdateCounterNodesConnected(i64 nodesConnectedDiff) {
16861692 }
16871693}
16881694
1695+ void THive::UpdateCounterPingQueueSize () {
1696+ if (TabletCounters != nullptr ) {
1697+ auto & counter = TabletCounters->Simple ()[NHive::COUNTER_PINGQUEUE_SIZE];
1698+ counter.Set (NodePingQueue.size ());
1699+ }
1700+ }
1701+
16891702void THive::RecordTabletMove (const TTabletMoveInfo& moveInfo) {
16901703 TabletMoveHistory.PushBack (moveInfo);
16911704 TabletCounters->Cumulative ()[NHive::COUNTER_TABLETS_MOVED].Increment (1 );
@@ -2662,6 +2675,25 @@ void THive::ExecuteStartTablet(TFullTabletId tabletId, const TActorId& local, ui
26622675 Execute (CreateStartTablet (tabletId, local, cookie, external));
26632676}
26642677
2678+ void THive::QueuePing (const TActorId& local) {
2679+ NodePingQueue.push (local);
2680+ }
2681+
2682+ void THive::ProcessNodePingQueue () {
2683+ while (!NodePingQueue.empty () && NodePingsInProgress.size () < GetMaxPingsInFlight ()) {
2684+ TActorId local = NodePingQueue.front ();
2685+ TNodeId node = local.NodeId ();
2686+ NodePingQueue.pop ();
2687+ NodePingsInProgress.insert (node);
2688+ SendPing (local, node);
2689+ }
2690+ }
2691+
2692+ void THive::RemoveFromPingInProgress (TNodeId node) {
2693+ NodePingsInProgress.erase (node);
2694+ ProcessNodePingQueue ();
2695+ }
2696+
26652697void THive::SendPing (const TActorId& local, TNodeId id) {
26662698 Send (local,
26672699 new TEvLocal::TEvPing (HiveId,
0 commit comments