diff --git a/src/groups/mqb/mqbblp/mqbblp_cluster.cpp b/src/groups/mqb/mqbblp/mqbblp_cluster.cpp index 2723c08300..94a28ecefb 100644 --- a/src/groups/mqb/mqbblp/mqbblp_cluster.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_cluster.cpp @@ -2210,6 +2210,9 @@ void Cluster::onRecoveryStatusDispatched( BSLS_ASSERT_SAFE(itMp->storage()->partitionId() == static_cast(pid)); + // TODO: wrong thread to call 'loadVirtualStorageDetails' + // but 'onRecoveryStatusDispatched' should not be concurrent + // with any of 'add/removeVirtualStorage' calls. AppInfos appIdInfos; itMp->storage()->loadVirtualStorageDetails(&appIdInfos); diff --git a/src/groups/mqb/mqbc/mqbc_storagemanager.h b/src/groups/mqb/mqbc/mqbc_storagemanager.h index d26688d7a5..3ecaaf9543 100644 --- a/src/groups/mqb/mqbc/mqbc_storagemanager.h +++ b/src/groups/mqb/mqbc/mqbc_storagemanager.h @@ -808,11 +808,11 @@ class StorageManager BSLS_KEYWORD_FINAL /// associated queue storage created. /// /// THREAD: Executed by the Client's dispatcher thread. - void registerQueue(const bmqt::Uri& uri, - const mqbu::StorageKey& queueKey, - int partitionId, - const AppInfos& appIdKeyPairs, - mqbi::Domain* domain) BSLS_KEYWORD_OVERRIDE; + void registerQueue(const bmqt::Uri& uri, + const mqbu::StorageKey& queueKey, + int partitionId, + const AppInfos& appIdKeyPairs, + mqbi::Domain* domain) BSLS_KEYWORD_OVERRIDE; /// Synchronously unregister the queue with the specified `uri` from the /// specified `partitionId`. diff --git a/src/groups/mqb/mqbc/mqbc_storageutil.cpp b/src/groups/mqb/mqbc/mqbc_storageutil.cpp index 2c627eeece..7cca27ca09 100644 --- a/src/groups/mqb/mqbc/mqbc_storageutil.cpp +++ b/src/groups/mqb/mqbc/mqbc_storageutil.cpp @@ -155,12 +155,12 @@ void StorageUtil::loadAddedAndRemovedEntries( loadDifference(removedEntries, existingEntries, newEntries); } -bool StorageUtil::loadUpdatedAppInfos(AppInfos* addedAppInfos, - AppInfos* removedAppInfos, - const mqbs::ReplicatedStorage& storage, +bool StorageUtil::loadUpdatedAppInfos(AppInfos* addedAppInfos, + AppInfos* removedAppInfos, + const AppInfos& existingAppInfos, const AppInfos& newAppInfos) { - // executed by the *CLUSTER DISPATCHER* thread + // executed by the *QUEUE_DISPATCHER* thread // PRECONDITIONS BSLS_ASSERT_SAFE(addedAppInfos); @@ -181,9 +181,6 @@ bool StorageUtil::loadUpdatedAppInfos(AppInfos* addedAppInfos, // list of newly added and removed appIds, and then invoking 'updateQueue' // in the appropriate thread. - AppInfos existingAppInfos; - storage.loadVirtualStorageDetails(&existingAppInfos); - loadAddedAndRemovedEntries(addedAppInfos, removedAppInfos, existingAppInfos, @@ -294,7 +291,7 @@ void StorageUtil::updateQueuePrimaryDispatched( bool hasUpdate = loadUpdatedAppInfos(&addedAppInfos, &removedAppInfos, - *storage, + existingAppInfos, appIdKeyPairs); if (!hasUpdate) { // No update needed for AppId/Key pairs. diff --git a/src/groups/mqb/mqbc/mqbc_storageutil.h b/src/groups/mqb/mqbc/mqbc_storageutil.h index 13abedc51e..993bdf2d2a 100644 --- a/src/groups/mqb/mqbc/mqbc_storageutil.h +++ b/src/groups/mqb/mqbc/mqbc_storageutil.h @@ -189,14 +189,14 @@ struct StorageUtil { /// Load into the specified `addedAppInfos` and /// `removedAppInfos` the appId/key pairs which have been added and - /// removed respectively for the specified `storage` based on the + /// removed respectively for the specified `existingAppInfos` based on the /// specified `newAppInfos`. Return true if there are any added or removed /// appId/key pairs, false otherwise. /// - /// THREAD: Executed by the cluster dispatcher thread. - static bool loadUpdatedAppInfos(AppInfos* addedAppInfos, - AppInfos* removedAppInfos, - const mqbs::ReplicatedStorage& storage, + /// THREAD: Executed by the queue dispatcher thread. + static bool loadUpdatedAppInfos(AppInfos* addedAppInfos, + AppInfos* removedAppInfos, + const AppInfos& existingAppInfos, const AppInfos& newAppInfos); /// THREAD: Executed by the Queue's dispatcher thread. diff --git a/src/groups/mqb/mqbi/mqbi_storage.h b/src/groups/mqb/mqbi/mqbi_storage.h index 0574f2d158..95267c8af7 100644 --- a/src/groups/mqb/mqbi/mqbi_storage.h +++ b/src/groups/mqb/mqbi/mqbi_storage.h @@ -375,10 +375,7 @@ class Storage { public: // PUBLIC TYPES - /// `AppInfo` is an alias for an (appId, appKey) pairing - /// representing unique virtual storage identification. - - /// `AppInfos` is an alias for a set of pairs of appId and appKey + /// `AppInfos` is an alias for a map [appId] -> appKey typedef bsl::unordered_map AppInfos; typedef bmqc::Array