Skip to content

Commit 88aba44

Browse files
authored
Remove[MQB]: isFirstLeaderAdvisory (#835)
Signed-off-by: dorjesinpo <129227380+dorjesinpo@users.noreply.github.com>
1 parent a535b5b commit 88aba44

5 files changed

Lines changed: 24 additions & 71 deletions

File tree

src/groups/mqb/mqbblp/mqbblp_clusterorchestrator.cpp

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/groups/mqb/mqbblp/mqbblp_clusterstatemanager.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,6 @@ void ClusterStateManager::onClusterLeader(
641641

642642
if (!node) {
643643
BSLS_ASSERT_SAFE(mqbc::ElectorInfoLeaderStatus::e_UNDEFINED == status);
644-
645-
d_isFirstLeaderAdvisory = true;
646644
}
647645
}
648646

@@ -677,8 +675,6 @@ void ClusterStateManager::onPartitionPrimaryAssignment(
677675
oldPrimary,
678676
oldLeaseId);
679677

680-
d_isFirstLeaderAdvisory = false;
681-
682678
d_afterPartitionPrimaryAssignmentCb(partitionId, primary, status);
683679
}
684680

@@ -699,7 +695,6 @@ ClusterStateManager::ClusterStateManager(
699695
, d_state_p(clusterState)
700696
, d_clusterStateLedger_mp(clusterStateLedger)
701697
, d_storageManager_p(0)
702-
, d_isFirstLeaderAdvisory(true)
703698
{
704699
// executed by *ANY* thread
705700

@@ -910,9 +905,6 @@ void ClusterStateManager::sendClusterState(
910905
BSLS_ASSERT_SAFE(mqbnet::ElectorState::e_LEADER ==
911906
d_clusterData_p->electorInfo().electorState());
912907

913-
// Self is leader and has published advisory above, so update it.
914-
d_isFirstLeaderAdvisory = false;
915-
916908
mqbc::ClusterUtil::sendClusterState(d_clusterData_p,
917909
d_clusterStateLedger_mp.get(),
918910
d_storageManager_p,

src/groups/mqb/mqbblp/mqbblp_clusterstatemanager.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ class ClusterStateManager BSLS_KEYWORD_FINAL
151151

152152
mqbi::StorageManager* d_storageManager_p;
153153

154-
bool d_isFirstLeaderAdvisory;
155-
156154
AfterPartitionPrimaryAssignmentCb d_afterPartitionPrimaryAssignmentCb;
157155

158156
private:
@@ -486,9 +484,6 @@ class ClusterStateManager BSLS_KEYWORD_FINAL
486484
void onNodeStopped() BSLS_KEYWORD_OVERRIDE;
487485

488486
// ACCESSORS
489-
// (virtual: mqbi::ClusterStateManager)
490-
bool isFirstLeaderAdvisory() const BSLS_KEYWORD_OVERRIDE;
491-
492487
/// Return the cluster state managed by this instacne.
493488
const mqbc::ClusterState* clusterState() const BSLS_KEYWORD_OVERRIDE;
494489

@@ -550,12 +545,6 @@ inline void ClusterStateManager::setAfterPartitionPrimaryAssignmentCb(
550545
}
551546

552547
// ACCESSORS
553-
// (virtual: mqbi::ClusterStateManager)
554-
inline bool ClusterStateManager::isFirstLeaderAdvisory() const
555-
{
556-
return d_isFirstLeaderAdvisory;
557-
}
558-
559548
inline const mqbc::ClusterState* ClusterStateManager::clusterState() const
560549
{
561550
return d_state_p;

src/groups/mqb/mqbc/mqbc_clusterstatemanager.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,6 @@ class ClusterStateManager BSLS_KEYWORD_FINAL
599599
BSLS_KEYWORD_OVERRIDE;
600600

601601
// ACCESSORS
602-
// (virtual: mqbi::ClusterStateManager)
603-
bool isFirstLeaderAdvisory() const BSLS_KEYWORD_OVERRIDE;
604-
605602
/// Return the cluster state managed by this instacne.
606603
const mqbc::ClusterState* clusterState() const BSLS_KEYWORD_OVERRIDE;
607604

@@ -663,13 +660,6 @@ inline void ClusterStateManager::setAfterPartitionPrimaryAssignmentCb(
663660

664661
// ACCESSORS
665662
// (virtual: mqbi::ClusterStateManager)
666-
inline bool ClusterStateManager::isFirstLeaderAdvisory() const
667-
{
668-
BSLS_ASSERT_SAFE(false && "NOT IMPLEMENTED!");
669-
670-
return false;
671-
}
672-
673663
inline const mqbc::ClusterState* ClusterStateManager::clusterState() const
674664
{
675665
return d_state_p;

src/groups/mqb/mqbi/mqbi_clusterstatemanager.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,6 @@ class ClusterStateManager {
312312
virtual void onNodeStopped() = 0;
313313

314314
// ACCESSORS
315-
virtual bool isFirstLeaderAdvisory() const = 0;
316-
317315
/// Return the cluster state managed by this instacne.
318316
virtual const mqbc::ClusterState* clusterState() const = 0;
319317

0 commit comments

Comments
 (0)