Skip to content

Commit 7710939

Browse files
committed
Fix[mqbc::StorageManager]: Send ACTIVE advisory on PrimaryStateRequest
Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>
1 parent 82ee395 commit 7710939

3 files changed

Lines changed: 52 additions & 12 deletions

File tree

src/groups/mqb/mqbc/mqbc_partitionstatetable.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,10 @@ class PartitionStateTableActions {
444444
do_transitionToActivePrimary(PartitionStateTableEvent::Enum eventType,
445445
const PartitionFSMEventData& eventData) = 0;
446446

447+
virtual void
448+
do_sendPrimaryStatusAdvisory(PartitionStateTableEvent::Enum eventType,
449+
const PartitionFSMEventData& eventData) = 0;
450+
447451
virtual void
448452
do_reapplyDetectSelfPrimary(PartitionStateTableEvent::Enum eventType,
449453
const PartitionFSMEventData& eventData) = 0;
@@ -576,7 +580,7 @@ class PartitionStateTableActions {
576580
const PartitionFSMEventData& eventData);
577581

578582
void
579-
do_storeSelfSeq_storeReplicaSeq_primaryStateResponse_sendDataToReplicas(
583+
do_storeSelfSeq_storeReplicaSeq_primaryStateResponse_sendDataToReplicas_sendPrimaryStatusAdvisory(
580584
PartitionStateTableEvent::Enum eventType,
581585
const PartitionFSMEventData& eventData);
582586

@@ -952,7 +956,7 @@ class PartitionStateTable
952956
PST_CFG(
953957
PRIMARY_HEALED,
954958
PRIMARY_STATE_RQST,
955-
storeSelfSeq_storeReplicaSeq_primaryStateResponse_sendDataToReplicas,
959+
storeSelfSeq_storeReplicaSeq_primaryStateResponse_sendDataToReplicas_sendPrimaryStatusAdvisory,
956960
PRIMARY_HEALED);
957961
PST_CFG(PRIMARY_HEALED,
958962
RST_UNKNOWN,
@@ -1283,16 +1287,11 @@ inline void PartitionStateTableActions::
12831287
do_sendDataToReplicas(eventType, eventData);
12841288
}
12851289

1286-
inline void PartitionStateTableActions::
1287-
do_storeSelfSeq_storeReplicaSeq_primaryStateResponse_sendDataToReplicas(
1288-
PartitionStateTableEvent::Enum eventType,
1289-
const PartitionFSMEventData& eventData)
1290-
{
1291-
do_storeSelfSeq(eventType, eventData);
1292-
do_storeReplicaSeq(eventType, eventData);
1293-
do_primaryStateResponse(eventType, eventData);
1294-
do_sendDataToReplicas(eventType, eventData);
1295-
}
1290+
PST_COMPOSITE_5(storeSelfSeq,
1291+
storeReplicaSeq,
1292+
primaryStateResponse,
1293+
sendDataToReplicas,
1294+
sendPrimaryStatusAdvisory)
12961295

12971296
inline void PartitionStateTableActions::do_storeReplicaSeq_sendDataToReplicas(
12981297
PartitionStateTableEvent::Enum eventType,

src/groups/mqb/mqbc/mqbc_storagemanager.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,6 +3703,43 @@ void StorageManager::do_transitionToActivePrimary(
37033703
0); // status
37043704
}
37053705

3706+
void StorageManager::do_sendPrimaryStatusAdvisory(
3707+
BSLA_MAYBE_UNUSED PartitionStateTableEvent::Enum eventType,
3708+
const PartitionFSMEventData& eventData)
3709+
{
3710+
// executed by the *QUEUE DISPATCHER* thread associated with the
3711+
// partitionId contained in 'eventData'
3712+
3713+
const int partitionId = eventData.partitionId();
3714+
BSLS_ASSERT_SAFE(0 <= partitionId &&
3715+
partitionId < static_cast<int>(d_fileStores.size()));
3716+
BSLS_ASSERT_SAFE(eventData.source());
3717+
3718+
const PartitionInfo& pinfo = d_partitionInfoVec[partitionId];
3719+
BSLS_ASSERT_SAFE(pinfo.primary() ==
3720+
d_clusterData_p->membership().selfNode());
3721+
BSLS_ASSERT_SAFE(pinfo.primaryStatus() ==
3722+
bmqp_ctrlmsg::PrimaryStatus::E_ACTIVE);
3723+
3724+
bmqp_ctrlmsg::ControlMessage controlMsg;
3725+
bmqp_ctrlmsg::PrimaryStatusAdvisory& primaryAdv =
3726+
controlMsg.choice()
3727+
.makeClusterMessage()
3728+
.choice()
3729+
.makePrimaryStatusAdvisory();
3730+
primaryAdv.partitionId() = partitionId;
3731+
primaryAdv.primaryLeaseId() = pinfo.primaryLeaseId();
3732+
primaryAdv.status() = bmqp_ctrlmsg::PrimaryStatus::E_ACTIVE;
3733+
3734+
fileStore(partitionId).sendMessage(controlMsg, eventData.source());
3735+
3736+
BALL_LOG_INFO << d_clusterData_p->identity().description()
3737+
<< " Partition [" << partitionId
3738+
<< "]: sent primary status advisory " << controlMsg
3739+
<< " to replica node "
3740+
<< eventData.source()->nodeDescription() << ".";
3741+
}
3742+
37063743
void StorageManager::do_reapplyDetectSelfPrimary(
37073744
BSLA_MAYBE_UNUSED PartitionStateTableEvent::Enum eventType,
37083745
const PartitionFSMEventData& eventData)

src/groups/mqb/mqbc/mqbc_storagemanager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,10 @@ class StorageManager BSLS_KEYWORD_FINAL : public mqbi::StorageManager,
800800
const PartitionFSMEventData& eventData)
801801
BSLS_KEYWORD_OVERRIDE;
802802

803+
void do_sendPrimaryStatusAdvisory(PartitionStateTableEvent::Enum eventType,
804+
const PartitionFSMEventData& eventData)
805+
BSLS_KEYWORD_OVERRIDE;
806+
803807
void do_reapplyDetectSelfPrimary(PartitionStateTableEvent::Enum eventType,
804808
const PartitionFSMEventData& eventData)
805809
BSLS_KEYWORD_OVERRIDE;

0 commit comments

Comments
 (0)