-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mqbc::StorageMgr, RecoveryMgr: Thread safety improvements #367
mqbc::StorageMgr, RecoveryMgr: Thread safety improvements #367
Conversation
@@ -79,13 +79,13 @@ class ClusterDataIdentity { | |||
private: | |||
// DATA | |||
|
|||
bsl::string d_name; | |||
const bsl::string d_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid adding these const
s here, this can lead to unusually restrictive class design issues later. If the intent is to ensure these fields are never modified after class construction, then we should provide an interface that guarantees that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Our interface already has such guarantees, so I will remove the const
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d
/// Get a modifiable reference to this object's event scheduler. | ||
bdlmt::EventScheduler* scheduler(); | ||
|
||
/// Get a modifiable reference to this object's buffer factory. | ||
bdlbb::BlobBufferFactory* bufferFactory(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the return value be NULL
here? If not, should we even be returning a pointer type? We should specify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, they cannot be NULL
here. I will add some asserts in the constructor, and change from pointer to reference here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that mqbc::ClusterData
itself only has pointers to components such as bdlmt::EventScheduler
and bdlbb::BlobBufferFactory
(see here). Take the example of bdlbb::BlobBufferFactory
, the actual owner is mqba::Application::d_bufferFactory
, and it's passed as pointer from mqba::Application -> mqbblp::ClusterCatalog -> mqbblp::Cluster -> mqbc::ClusterData
. Given that, would it make sense to keep them as pointers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will also make copy constructor and copy assignment operator private, since this object is not supposed to be copyable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d
c754199
to
f3d03d7
Compare
/// Initialize the queue key info map based on information in the specified | ||
/// `clusterState`. | ||
virtual void initializeQueueKeyInfoMap( | ||
const mqbc::ClusterState* clusterState) BSLS_KEYWORD_OVERRIDE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clusterState
is a const parameter, it's not optional and required every time. Is it possible to convert it to const reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d
} | ||
|
||
void StorageManager::initializeQueueKeyInfoMap( | ||
BSLS_ANNOTATION_UNUSED const mqbc::ClusterState* clusterState) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively you might remove the annotation and arg variable name to silence the unused variable compiler warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will keep it as BSLS_ANNOTATION_UNUSED
to be consistent with other functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I see most of the places where we've fixed thread-safety, but I have a few questions about some changes.
// PRECONDITION | ||
BSLS_ASSERT_SAFE(d_dispatcher_p->inDispatcherThread(d_cluster_p)); | ||
|
||
BSLS_ASSERT_OPT(false && "This method should only be invoked in FSM mode"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really what we want? This pair of asserts seems wrong...the second one can fire even if we are in the dispatcher thread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only caller of initializeQueueKeyInfoMap()
is mqbc::ClusterStateManager
, and it should always use mqbc
version of StorageManager
. By design, only the FSM version of this method, mqbc::StorageManager::initializeQueueKeyInfoMap()
, can be invoked. If you can think of a better way to express this, please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. In this case, the false
makes sense. Perhaps, "Only the FSM version of this method from mqbc::StorageManager
should be invoked." as the string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Will change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d
df6ca25
to
3bcd80b
Compare
@678098 @hallfox @pniedzielski Back for your review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build 184 of commit 39fa4e7 has completed with FAILURE
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
39fa4e7
to
d0301c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build 192 of commit d0301c8 has completed with FAILURE
) * mqbs:FileStore: Improve rc logging Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageManager.t: Remove the concept of replica healing stages Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbmock::StorageManager [new] Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::ClusterData: Clean up manipulators and accessors Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::RecoveryMgr: Thread safety improvements Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * Fix mqbc::StorageMgr: Initialize queue key info map in cluster thread Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageMgr.t: Set partition primary also in cluster state Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageMgr: Thread safety improvements Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * Apply clang-format Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * PR#367: Address feedback Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::ClusterData: Return reference not pointer for non-nullables Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc: Make copy constructor and copy assignment private Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * blp::StorageManager: Improve assert logging Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbmock::StorageMgr: Fix compilation errors Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::RecoveryManager: Apply clang format Signed-off-by: Yuan Jing Vincent Yan <[email protected]> --------- Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
) * mqbs:FileStore: Improve rc logging Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageManager.t: Remove the concept of replica healing stages Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbmock::StorageManager [new] Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::ClusterData: Clean up manipulators and accessors Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::RecoveryMgr: Thread safety improvements Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * Fix mqbc::StorageMgr: Initialize queue key info map in cluster thread Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageMgr.t: Set partition primary also in cluster state Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageMgr: Thread safety improvements Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * Apply clang-format Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * PR#367: Address feedback Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::ClusterData: Return reference not pointer for non-nullables Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc: Make copy constructor and copy assignment private Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * blp::StorageManager: Improve assert logging Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbmock::StorageMgr: Fix compilation errors Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::RecoveryManager: Apply clang format Signed-off-by: Yuan Jing Vincent Yan <[email protected]> --------- Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
) * mqbs:FileStore: Improve rc logging Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageManager.t: Remove the concept of replica healing stages Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbmock::StorageManager [new] Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::ClusterData: Clean up manipulators and accessors Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::RecoveryMgr: Thread safety improvements Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * Fix mqbc::StorageMgr: Initialize queue key info map in cluster thread Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageMgr.t: Set partition primary also in cluster state Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageMgr: Thread safety improvements Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * Apply clang-format Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * PR#367: Address feedback Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::ClusterData: Return reference not pointer for non-nullables Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc: Make copy constructor and copy assignment private Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * blp::StorageManager: Improve assert logging Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbmock::StorageMgr: Fix compilation errors Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::RecoveryManager: Apply clang format Signed-off-by: Yuan Jing Vincent Yan <[email protected]> --------- Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
) * mqbs:FileStore: Improve rc logging Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageManager.t: Remove the concept of replica healing stages Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbmock::StorageManager [new] Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::ClusterData: Clean up manipulators and accessors Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::RecoveryMgr: Thread safety improvements Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * Fix mqbc::StorageMgr: Initialize queue key info map in cluster thread Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageMgr.t: Set partition primary also in cluster state Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::StorageMgr: Thread safety improvements Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * Apply clang-format Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * PR#367: Address feedback Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::ClusterData: Return reference not pointer for non-nullables Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc: Make copy constructor and copy assignment private Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * blp::StorageManager: Improve assert logging Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbmock::StorageMgr: Fix compilation errors Signed-off-by: Yuan Jing Vincent Yan <[email protected]> * mqbc::RecoveryManager: Apply clang format Signed-off-by: Yuan Jing Vincent Yan <[email protected]> --------- Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
This series of changes improved the thread safety of components integral to the FSM mode, including
mqbc::StorageManager
,mqbc::RecoveryManager
, and other neighboring components.