@@ -65,7 +65,7 @@ namespace NKikimr::NStorage {
6565
6666 std::vector<ui32> nodeIdsForOutgoingBinding;
6767 std::vector<ui32> nodeIdsForIncomingBinding;
68- std::vector<ui32> nodeIdsForPrimaryPileOutgoingBinding ;
68+ std::vector<ui32> nodeIdsForOtherPilesOutgoingBinding ;
6969
7070 for (const auto & [item, location] : newNodeList) {
7171 const ui32 nodeId = item.NodeId ();
@@ -83,8 +83,8 @@ namespace NKikimr::NStorage {
8383
8484 // check if node is located in primary pile (and this one is not the primary) -- then it is suitable for
8585 // binding to primary pile
86- if (BridgeInfo && !BridgeInfo-> SelfNodePile -> IsPrimary && location.GetBridgePileName () == BridgeInfo-> PrimaryPile -> Name ) {
87- nodeIdsForPrimaryPileOutgoingBinding .push_back (item.NodeId ());
86+ if (location.GetBridgePileName () != SelfNodeBridgePileName ) {
87+ nodeIdsForOtherPilesOutgoingBinding .push_back (item.NodeId ());
8888 }
8989 }
9090
@@ -111,15 +111,15 @@ namespace NKikimr::NStorage {
111111 };
112112 applyChanges (NodeIdsForOutgoingBinding, nodeIdsForOutgoingBinding);
113113 applyChanges (NodeIdsForIncomingBinding, nodeIdsForIncomingBinding);
114- applyChanges (NodeIdsForPrimaryPileOutgoingBinding, nodeIdsForPrimaryPileOutgoingBinding );
114+ applyChanges (NodeIdsForOtherPilesOutgoingBinding, nodeIdsForOtherPilesOutgoingBinding );
115115 if (bindingReset) {
116116 AbortBinding (" node vanished" );
117117 }
118118
119119 // issue updates
120120 BindQueue.Update (NodeIdsForOutgoingBinding);
121121 RevBindQueue.Update (NodeIdsForIncomingBinding);
122- PrimaryPileBindQueue .Update (NodeIdsForPrimaryPileOutgoingBinding );
122+ OtherPilesBindQueue .Update (NodeIdsForOtherPilesOutgoingBinding );
123123 }
124124
125125 TBridgePileId TDistributedConfigKeeper::ResolveNodePileId (const TNodeLocation& location) {
@@ -157,15 +157,13 @@ namespace NKikimr::NStorage {
157157 }
158158
159159 // no node from the same pile available, try to bind to primary pile (if we have quorum)
160- TMonotonic primaryClosest = TMonotonic::Max ();
161- if (LocalPileQuorum && !BridgeInfo->SelfNodePile ->IsPrimary ) {
162- if (std::optional<ui32> nodeIdFromPrimaryPile = PrimaryPileBindQueue.Pick (now, &primaryClosest)) {
163- return StartBinding (*nodeIdFromPrimaryPile);
164- }
160+ TMonotonic otherClosest = TMonotonic::Max ();
161+ if (std::optional<ui32> nodeIdFromOtherPile = OtherPilesBindQueue.Pick (now, &otherClosest)) {
162+ return StartBinding (*nodeIdFromOtherPile);
165163 }
166164
167165 // nothing to bind to
168- closest = Min (closest, revClosest, primaryClosest );
166+ closest = Min (closest, revClosest, otherClosest );
169167 if (closest != TMonotonic::Max () && !Scheduled) {
170168 STLOG (PRI_DEBUG, BS_NODE, NWDC30, " Delaying bind" );
171169 TActivationContext::Schedule (closest, new IEventHandle (TEvents::TSystem::Wakeup, 0 , SelfId (), {}, nullptr , 0 ));
@@ -488,7 +486,6 @@ namespace NKikimr::NStorage {
488486 // pending commands
489487 if (Binding && Binding->RootNodeId ) {
490488 Y_ABORT_UNLESS (Binding->RootNodeId != SelfId ().NodeId ());
491- UnbindNodesFromOtherPiles (" root node has changed" );
492489 std::ranges::for_each (std::exchange (InvokeOnRootPending, {}), std::bind (&TThis::HandleInvokeOnRoot, this ,
493490 std::placeholders::_1));
494491 }
@@ -578,7 +575,8 @@ namespace NKikimr::NStorage {
578575 Y_ABORT_UNLESS (StorageConfig); // we must have the storage configuration by the time we can process this message
579576 if (record.GetInitial ()) {
580577 for (const auto & item : record.GetBoundNodes ()) {
581- if (item.GetNodeId ().GetNodeId () == senderNodeId) { // ensure that whole node identifier tuple matches
578+ const ui32 nodeId = item.GetNodeId ().GetNodeId ();
579+ if (nodeId == senderNodeId) { // ensure that whole node identifier tuple matches
582580 knownNode = it->second == TNodeIdentifier (item.GetNodeId ());
583581 break ;
584582 }
@@ -614,21 +612,12 @@ namespace NKikimr::NStorage {
614612 }
615613
616614 // check if this is connection from another pile
617- if (record.GetInitial () && !NodesFromSamePile.contains (senderNodeId)) {
618- Y_DEBUG_ABORT_UNLESS (BridgeInfo);
619- if ((!Binding || !Binding->RootNodeId ) && LocalPileQuorum && BridgeInfo->SelfNodePile ->IsPrimary ) {
620- // we allow this node's connection as this is the primary pile AND we have majority of connected
621- // nodes AND this is the root one
622- } else {
623- // this is either not the root node, or no quorum for connection
624- auto response = TEvNodeConfigReversePush::MakeRejected ();
625- if (Binding && Binding->RootNodeId ) {
626- // command peer to join this specific node
627- response->Record .SetRootNodeId (Binding->RootNodeId );
628- }
629- SendEvent (*ev, std::move (response));
630- return ;
631- }
615+ if (record.GetInitial () && !NodesFromSamePile.contains (senderNodeId) && Binding && Binding->RootNodeId ) {
616+ // command peer to join this specific node
617+ auto response = TEvNodeConfigReversePush::MakeRejected ();
618+ response->Record .SetRootNodeId (Binding->RootNodeId );
619+ SendEvent (*ev, std::move (response));
620+ return ;
632621 }
633622
634623 if (!record.GetInitial () && !DirectBoundNodes.contains (senderNodeId)) {
@@ -792,25 +781,4 @@ namespace NKikimr::NStorage {
792781 return Scepter || (Binding && GetRootNodeId () != SelfId ().NodeId ());
793782 }
794783
795- void TDistributedConfigKeeper::UnbindNodesFromOtherPiles (const char *reason) {
796- if (!BridgeInfo) {
797- return ;
798- }
799-
800- std::vector<ui32> goingToUnbind;
801- for (const auto & [nodeId, info] : DirectBoundNodes) {
802- if (BridgeInfo->GetPileForNode (nodeId) != BridgeInfo->SelfNodePile ) {
803- auto ev = TEvNodeConfigReversePush::MakeRejected ();
804- if (Binding && Binding->RootNodeId ) { // inform about new root, if we have it
805- ev->Record .SetRootNodeId (Binding->RootNodeId );
806- }
807- SendEvent (nodeId, info, std::move (ev));
808- goingToUnbind.push_back (nodeId);
809- }
810- }
811- for (ui32 nodeId : goingToUnbind) {
812- UnbindNode (nodeId, reason);
813- }
814- }
815-
816784} // NKikimr::NStorage
0 commit comments