Skip to content

Commit e3d18b9

Browse files
committed
Fix[MQB]: use CSL to update state on QueueAssignmentAdvisory
Signed-off-by: Emelia Lei <[email protected]>
1 parent c18ff5c commit e3d18b9

6 files changed

+44
-56
lines changed

src/groups/mqb/mqbblp/mqbblp_clusterstatemanager.cpp

+30-18
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,24 @@ void ClusterStateManager::onCommit(
7070
BSLS_ASSERT_SAFE(dispatcher()->inDispatcherThread(d_cluster_p));
7171
BSLS_ASSERT_SAFE(advisory.choice().isClusterMessageValue());
7272

73-
// NOTE: Even when using old workflow, we still apply all advisories to the
74-
// CSL. We just don't invoke the commit callbacks.
75-
if (!d_clusterConfig.clusterAttributes().isCSLModeEnabled()) {
76-
return; // RETURN
77-
}
78-
7973
if (status != mqbc::ClusterStateLedgerCommitStatus::e_SUCCESS) {
8074
BALL_LOG_ERROR << d_clusterData_p->identity().description()
8175
<< ": Failed to commit advisory: " << advisory
8276
<< ", with status '" << status << "'";
8377
return; // RETURN
8478
}
8579

80+
const bmqp_ctrlmsg::ClusterMessage& clusterMessage =
81+
advisory.choice().clusterMessage();
82+
83+
// NOTE: Even when using old workflow, we still apply all advisories to the
84+
// CSL. We just don't invoke the commit callbacks.
85+
// Make an exception for QueueAssignmentAdvisory
86+
if (!d_clusterConfig.clusterAttributes().isCSLModeEnabled() &&
87+
!clusterMessage.choice().isQueueAssignmentAdvisoryValue()) {
88+
return; // RETURN
89+
}
90+
8691
// Commenting out following 'if' check to fix an assert during node
8792
// shutdown.
8893
// if ( d_clusterData_p->membership().selfNodeStatus()
@@ -94,8 +99,6 @@ void ClusterStateManager::onCommit(
9499
<< ": Committed advisory: " << advisory << ", with status '"
95100
<< status << "'";
96101

97-
const bmqp_ctrlmsg::ClusterMessage& clusterMessage =
98-
advisory.choice().clusterMessage();
99102
mqbc::ClusterUtil::apply(d_state_p, clusterMessage, *d_clusterData_p);
100103
}
101104

@@ -1481,7 +1484,8 @@ void ClusterStateManager::processQueueAssignmentRequest(
14811484
void ClusterStateManager::processQueueAssignmentAdvisory(
14821485
const bmqp_ctrlmsg::ControlMessage& message,
14831486
mqbnet::ClusterNode* source,
1484-
bool delayed)
1487+
bool delayed,
1488+
bool fromLeaderAdvisory)
14851489
{
14861490
// executed by the cluster *DISPATCHER* thread
14871491

@@ -1690,16 +1694,21 @@ void ClusterStateManager::processQueueAssignmentAdvisory(
16901694
}
16911695
}
16921696
else {
1693-
AppInfos appIdInfos(d_allocator_p);
1697+
if (delayed || fromLeaderAdvisory) {
1698+
AppInfos appIdInfos(d_allocator_p);
16941699

1695-
mqbc::ClusterUtil::parseQueueInfo(&appIdInfos,
1696-
queueInfo,
1697-
d_allocator_p);
1700+
mqbc::ClusterUtil::parseQueueInfo(&appIdInfos,
1701+
queueInfo,
1702+
d_allocator_p);
16981703

1699-
d_state_p->assignQueue(uri,
1700-
queueKey,
1701-
queueInfo.partitionId(),
1702-
appIdInfos);
1704+
d_state_p->assignQueue(uri,
1705+
queueKey,
1706+
queueInfo.partitionId(),
1707+
appIdInfos);
1708+
}
1709+
// When this function is called from
1710+
// processQueueAssignmentAdvisory, assignQueue will
1711+
// be triggered through mqbblp::ClusterStateManager::onCommit
17031712
}
17041713

17051714
BALL_LOG_INFO << d_cluster_p->description()
@@ -2150,7 +2159,10 @@ void ClusterStateManager::processLeaderAdvisory(
21502159
queueAsgnAdv.sequenceNumber() = advisory.sequenceNumber();
21512160
queueAsgnAdv.queues() = advisory.queues();
21522161

2153-
processQueueAssignmentAdvisory(controlMsg, source);
2162+
processQueueAssignmentAdvisory(controlMsg,
2163+
source,
2164+
false /* not delayed */,
2165+
true /* called from leaderAdvisory */);
21542166

21552167
// Leader status and sequence number are updated unconditionally. It may
21562168
// have been updated by one of the routines called earlier in this method,

src/groups/mqb/mqbblp/mqbblp_clusterstatemanager.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,11 @@ class ClusterStateManager BSLS_KEYWORD_FINAL
489489
/// TODO_CSL: This is the current workflow which we should be able to
490490
/// remove after the new workflow via
491491
/// ClusterQueueHelper::onQueueAssigned() is stable.
492-
void
493-
processQueueAssignmentAdvisory(const bmqp_ctrlmsg::ControlMessage& message,
494-
mqbnet::ClusterNode* source,
495-
bool delayed = false) BSLS_KEYWORD_OVERRIDE;
492+
void processQueueAssignmentAdvisory(
493+
const bmqp_ctrlmsg::ControlMessage& message,
494+
mqbnet::ClusterNode* source,
495+
bool delayed = false,
496+
bool fromLeaderAdvisory = false) BSLS_KEYWORD_OVERRIDE;
496497

497498
/// Process the queue unAssigned advisory in the specified `message`
498499
/// received from the specified `source`.

src/groups/mqb/mqbc/mqbc_clusterstatemanager.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,8 @@ void ClusterStateManager::processQueueAssignmentRequest(
17841784
void ClusterStateManager::processQueueAssignmentAdvisory(
17851785
BSLS_ANNOTATION_UNUSED const bmqp_ctrlmsg::ControlMessage& message,
17861786
BSLS_ANNOTATION_UNUSED mqbnet::ClusterNode* source,
1787-
BSLS_ANNOTATION_UNUSED bool delayed)
1787+
BSLS_ANNOTATION_UNUSED bool delayed,
1788+
BSLS_ANNOTATION_UNUSED bool fromLeaderAdvisory)
17881789
{
17891790
BSLS_ASSERT_SAFE(false &&
17901791
"This method should only be invoked in non-CSL mode");

src/groups/mqb/mqbc/mqbc_clusterstatemanager.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,11 @@ class ClusterStateManager BSLS_KEYWORD_FINAL
589589
/// TODO_CSL: This is the current workflow which we should be able to
590590
/// remove after the new workflow via
591591
/// ClusterQueueHelper::onQueueAssigned() is stable.
592-
void
593-
processQueueAssignmentAdvisory(const bmqp_ctrlmsg::ControlMessage& message,
594-
mqbnet::ClusterNode* source,
595-
bool delayed = false) BSLS_KEYWORD_OVERRIDE;
592+
void processQueueAssignmentAdvisory(
593+
const bmqp_ctrlmsg::ControlMessage& message,
594+
mqbnet::ClusterNode* source,
595+
bool delayed = false,
596+
bool fromLeaderAdvisory = false) BSLS_KEYWORD_OVERRIDE;
596597

597598
/// Process the queue unAssigned advisory in the specified `message`
598599
/// received from the specified `source`.

src/groups/mqb/mqbc/mqbc_clusterutil.cpp

-28
Original file line numberDiff line numberDiff line change
@@ -1007,34 +1007,6 @@ ClusterUtil::assignQueue(ClusterState* clusterState,
10071007
<< queueAdvisory << ", rc: " << rc;
10081008
}
10091009

1010-
if (!cluster->isCSLModeEnabled()) {
1011-
// In CSL mode, we assign the queue to ClusterState upon CSL commit
1012-
// callback of QueueAssignmentAdvisory, so we don't assign it here.
1013-
1014-
// In non-CSL mode this is the shortcut to call Primary CQH instead of
1015-
// waiting for the quorum of acks in the ledger.
1016-
1017-
BSLS_ASSERT_SAFE(queueAdvisory.queues().size() == 1);
1018-
1019-
bmqp_ctrlmsg::QueueInfo& queueInfo = queueAdvisory.queues().back();
1020-
1021-
AppInfos appInfos(allocator);
1022-
mqbc::ClusterUtil::parseQueueInfo(&appInfos, queueInfo, allocator);
1023-
1024-
BSLA_MAYBE_UNUSED const bool assignRc = clusterState->assignQueue(
1025-
uri,
1026-
key,
1027-
queueAdvisory.queues().back().partitionId(),
1028-
appInfos);
1029-
BSLS_ASSERT_SAFE(assignRc);
1030-
1031-
BALL_LOG_INFO << cluster->description()
1032-
<< ": Queue assigned: " << queueAdvisory;
1033-
1034-
// Broadcast 'queueAssignmentAdvisory' to all followers
1035-
clusterData->messageTransmitter().broadcastMessage(controlMsg);
1036-
}
1037-
10381010
return QueueAssignmentResult::k_ASSIGNMENT_OK;
10391011
}
10401012

src/groups/mqb/mqbi/mqbi_clusterstatemanager.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ class ClusterStateManager {
336336
virtual void
337337
processQueueAssignmentAdvisory(const bmqp_ctrlmsg::ControlMessage& message,
338338
mqbnet::ClusterNode* source,
339-
bool delayed = false) = 0;
339+
bool delayed = false,
340+
bool fromLeaderAdvisory = false) = 0;
340341

341342
/// Process the queue unAssigned advisory in the specified `message`
342343
/// received from the specified `source`.

0 commit comments

Comments
 (0)