@@ -1539,34 +1539,6 @@ void ClusterOrchestrator::processPrimaryStatusAdvisory(
15391539 return ; // RETURN
15401540 }
15411541 }
1542- else if (!d_stateManager_mp->isFirstLeaderAdvisory ()) {
1543- // Self node has heard from the leader at least once. Perform
1544- // additional validations.
1545-
1546- if (pinfo.primaryNode () != source) {
1547- BALL_LOG_ERROR << d_clusterData_p->identity ().description ()
1548- << " : Partition [" << primaryAdv.partitionId ()
1549- << " ]: received primary status advisory: "
1550- << primaryAdv
1551- << " from: " << source->nodeDescription ()
1552- << " , but current primary is: "
1553- << (pinfo.primaryNode ()
1554- ? pinfo.primaryNode ()->nodeDescription ()
1555- : " ** null **" );
1556- return ; // RETURN
1557- }
1558-
1559- if (pinfo.primaryLeaseId () != primaryAdv.primaryLeaseId ()) {
1560- BALL_LOG_ERROR << d_clusterData_p->identity ().description ()
1561- << " : Partition [" << primaryAdv.partitionId ()
1562- << " ]: received primary status advisory: "
1563- << primaryAdv << " from perceived primary: "
1564- << source->nodeDescription ()
1565- << " , but with different leaseId. Self perceived "
1566- << " leaseId: " << pinfo.primaryLeaseId ();
1567- return ; // RETURN
1568- }
1569- }
15701542 else {
15711543 // TODO Remove `mqbi::ClusterStateManager::setPrimary()` when this code
15721544 // is removed.
@@ -1577,23 +1549,35 @@ void ClusterOrchestrator::processPrimaryStatusAdvisory(
15771549 // and hasn't heard from the leader, but various primary nodes have
15781550 // sent their status advisory messages to it.
15791551
1580- // Note that we cannot use self node's status in place of
1581- // 'isFirstLeaderAdvisory', because a node may transition from
1582- // STARTING to AVAILABLE, but still may not have heard from the leader.
1583-
1584- // Also note that self node could be receiving the 2nd primary status
1585- // advisory from the 'source' (recall that a primary sends status
1586- // advisory when it sees a new node transitioning to STARTING and again
1587- // when transitioning to AVAILABLE), but self node may not have yet
1588- // heard from the leader. So if self's cluster state is already
1589- // up-to-date with this primary's status, we don't assert certain
1590- // things.
1591-
15921552 // TBD: Since we are updating cluster state based on a message from the
15931553 // non-leader node, we are breaking the contract that only leader
15941554 // issues writes to the cluster state. This needs to be reviewed. See
15951555 // 'StorageMgr::processPrimaryStatusAdvisoryDispatched' as well.
15961556
1557+ if (pinfo.primaryNode ()) {
1558+ if (pinfo.primaryNode () != source) {
1559+ BALL_LOG_ERROR
1560+ << d_clusterData_p->identity ().description ()
1561+ << " : Partition [" << primaryAdv.partitionId ()
1562+ << " ]: received primary status advisory: " << primaryAdv
1563+ << " from: " << source->nodeDescription ()
1564+ << " , but current primary is: "
1565+ << pinfo.primaryNode ()->nodeDescription ();
1566+ return ; // RETURN
1567+ }
1568+
1569+ if (pinfo.primaryLeaseId () != primaryAdv.primaryLeaseId ()) {
1570+ BALL_LOG_ERROR
1571+ << d_clusterData_p->identity ().description ()
1572+ << " : Partition [" << primaryAdv.partitionId ()
1573+ << " ]: received primary status advisory: " << primaryAdv
1574+ << " from perceived primary: " << source->nodeDescription ()
1575+ << " , but with different leaseId. Self perceived "
1576+ << " leaseId: " << pinfo.primaryLeaseId ();
1577+ return ; // RETURN
1578+ }
1579+ }
1580+
15971581 BALL_LOG_WARN << d_clusterData_p->identity ().description ()
15981582 << " Partition [" << primaryAdv.partitionId ()
15991583 << " ]: received primary status advisory: " << primaryAdv
0 commit comments