Skip to content

Commit d1a6e58

Browse files
authored
not switching thread context when closing on shutdown (#675)
Signed-off-by: dorjesinpo <[email protected]>
1 parent 5830f50 commit d1a6e58

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

src/groups/mqb/mqbblp/mqbblp_clusterqueuehelper.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,23 +2782,6 @@ void ClusterQueueHelper::releaseQueueDispatched(
27822782
BSLS_ASSERT_SAFE(
27832783
d_cluster_p->dispatcher()->inDispatcherThread(d_cluster_p));
27842784

2785-
if (d_supportShutdownV2) {
2786-
BMQ_LOGTHROTTLE_INFO()
2787-
<< d_cluster_p->description()
2788-
<< ": Shutting down and skipping close queue [: "
2789-
<< handleParameters.uri()
2790-
<< "], queueId: " << handleParameters.qId()
2791-
<< ", handle parameters: " << handleParameters;
2792-
if (callback) {
2793-
bmqp_ctrlmsg::Status status;
2794-
status.category() = bmqp_ctrlmsg::StatusCategory::E_SUCCESS;
2795-
status.message() = "Shutting down.";
2796-
callback(status);
2797-
}
2798-
2799-
return; // RETURN
2800-
}
2801-
28022785
bmqt::Uri uri(handleParameters.uri());
28032786
QueueContextMapIter queueContextIt = d_queues.find(uri.canonical());
28042787
if (queueContextIt == d_queues.end()) {
@@ -4716,6 +4699,28 @@ void ClusterQueueHelper::configureQueue(
47164699
// PRECONDITIONS
47174700
BSLS_ASSERT_SAFE(d_cluster_p->dispatcher()->inDispatcherThread(queue));
47184701

4702+
// Application first calls 'Cluster::initiateShutdown' (which may set
4703+
// 'd_supportShutdownV2'), followed by 'TransportManager::closeClients'
4704+
// which may result in 'QueueHandle::drop' leading to this call.
4705+
if (d_supportShutdownV2) {
4706+
// Assuming thread-safe 'description()'
4707+
BMQ_LOGTHROTTLE_INFO()
4708+
<< d_cluster_p->description()
4709+
<< ": Shutting down and skipping close queue [: "
4710+
<< handleParameters.uri()
4711+
<< "], queueId: " << handleParameters.qId()
4712+
<< ", handle parameters: " << handleParameters;
4713+
4714+
if (callback) {
4715+
bmqp_ctrlmsg::Status status;
4716+
status.category() = bmqp_ctrlmsg::StatusCategory::E_SUCCESS;
4717+
status.message() = "Shutting down.";
4718+
callback(status);
4719+
}
4720+
4721+
return; // RETURN
4722+
}
4723+
47194724
// TBD: Populate the 'bmqp_ctrlmsg::SubQueueIdInfo' of the handleParameters
47204725
// with subStream-specific (appId, upstreamSubQueueId) if applicable.
47214726
// Note that handleParameters passed here are from the 'QueueContext'

src/groups/mqb/mqbblp/mqbblp_clusterqueuehelper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,9 @@ class ClusterQueueHelper BSLS_KEYWORD_FINAL
462462

463463
StopContexts d_stopContexts;
464464

465-
/// When `true`, all cluster nodes support StopRequest V2 and this node
466-
/// executes shutdown V2 logic.
467-
bool d_supportShutdownV2;
465+
/// When `true`, this node is shutting down using shutdown v2 logic.
466+
/// This can only be true when all cluster nodes support StopRequest V2.
467+
bsls::AtomicBool d_supportShutdownV2;
468468

469469
private:
470470
// PRIVATE MANIPULATORS

0 commit comments

Comments
 (0)