-
Notifications
You must be signed in to change notification settings - Fork 21
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
waiting until all the callbacks are done before stopping #497
Conversation
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.
lgtm
@@ -500,8 +500,12 @@ class SampleDB { | |||
} | |||
|
|||
void on_log_insert_completion(logdev_id_t fid, logstore_seq_num_t lsn, logdev_key ld_key) { | |||
if (m_highest_log_idx.count(fid) == 0) { m_highest_log_idx[fid] = std::atomic{-1}; } | |||
atomic_update_max(m_highest_log_idx[fid], ld_key.idx); | |||
{ |
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.
many on_log_insert_completion
might be executed in different reactors (threads). theoretically, different threads might modify and access m_highest_log_idx
concurrently , which might cause a segfault . so add a lock 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.
do we want to add lock also to
HomeStore/src/tests/test_log_store.cpp
Line 521 in 2080ad4
logid_t highest_log_idx(logdev_id_t fid) { |
before stopping logdev, we should wait until all the callbacks are done to avoid memroy leak