-
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
MetaService Fixes #450
Merged
Merged
MetaService Fixes #450
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,7 +266,7 @@ class VMetaBlkMgrTest : public ::testing::Test { | |
if (!done_read) { | ||
done_read = true; | ||
m_mbm->read_sub_sb(mtype); | ||
const auto read_buf_str = m_cb_blks[mblk->hdr.h.bid.to_integer()]; | ||
const auto read_buf_str = m_cb_blks[mblk->hdr.h.bid.to_integer()].str; | ||
const std::string write_buf_str = m_write_sbs[mblk->hdr.h.bid.to_integer()].str; | ||
const auto ret = read_buf_str.compare(write_buf_str); | ||
if (mblk->hdr.h.compressed == false) { | ||
|
@@ -327,7 +327,7 @@ class VMetaBlkMgrTest : public ::testing::Test { | |
|
||
{ | ||
std::unique_lock< std::mutex > lg{m_mtx}; | ||
const auto read_buf_str = m_cb_blks[mblk->hdr.h.bid.to_integer()]; | ||
const auto read_buf_str = m_cb_blks[mblk->hdr.h.bid.to_integer()].str; | ||
const std::string write_buf_str{str}; | ||
const auto ret = read_buf_str.compare(write_buf_str); | ||
HS_DBG_ASSERT(ret == 0, "Context data mismatch: Saved: {}, read: {}.", write_buf_str, read_buf_str); | ||
|
@@ -422,8 +422,8 @@ class VMetaBlkMgrTest : public ::testing::Test { | |
HS_DBG_ASSERT(it_cb != std::cend(m_cb_blks), "Saved bid during write not found in recover callback."); | ||
|
||
// the saved buf should be equal to the buf received in the recover callback; | ||
const int ret = it->second.str.compare(it_cb->second); | ||
HS_DBG_ASSERT(ret == 0, "Context data mismatch: Saved: {}, callback: {}.", it->second.str, it_cb->second); | ||
const int ret = it->second.str.compare(it_cb->second.str); | ||
HS_DBG_ASSERT(ret == 0, "Context data mismatch: Saved: {}, callback: {}.", it->second.str, it_cb->second.str); | ||
} | ||
} | ||
|
||
|
@@ -497,13 +497,16 @@ class VMetaBlkMgrTest : public ::testing::Test { | |
|
||
void recover_with_on_complete() { | ||
// restart will cause recovery and callbacks will be triggered | ||
++m_restart_cnt; | ||
m_cb_blks.clear(); | ||
restart_homestore(); | ||
} | ||
|
||
void validate() { | ||
// verify received blks via callbaks are all good; | ||
verify_cb_blks(); | ||
m_write_sbs.swap(m_cb_blks); | ||
m_cb_blks.clear(); | ||
} | ||
|
||
meta_op_type get_op() { | ||
|
@@ -537,7 +540,7 @@ class VMetaBlkMgrTest : public ::testing::Test { | |
} | ||
} | ||
|
||
uint64_t total_op_cnt() const { return m_update_cnt + m_wrt_cnt + m_rm_cnt; } | ||
uint64_t total_op_cnt() const { return m_update_cnt + m_wrt_cnt + m_rm_cnt + m_restart_cnt; } | ||
|
||
uint32_t write_ratio() const { | ||
if (m_wrt_cnt == 0) return 0; | ||
|
@@ -579,24 +582,28 @@ class VMetaBlkMgrTest : public ::testing::Test { | |
m_update_cnt = 0; | ||
m_rm_cnt = 0; | ||
m_total_wrt_sz = 0; | ||
m_restart_cnt = 0; | ||
} | ||
|
||
void register_client() { | ||
m_mbm = &(meta_service()); | ||
m_total_wrt_sz = m_mbm->used_size(); | ||
|
||
HS_REL_ASSERT_EQ(m_mbm->total_size() - m_total_wrt_sz, m_mbm->available_blks() * m_mbm->block_size()); | ||
|
||
m_mbm->deregister_handler(mtype); | ||
m_mbm->register_handler( | ||
mtype, | ||
[this](meta_blk* mblk, sisl::byte_view buf, size_t size) { | ||
if (mblk) { | ||
std::unique_lock< std::mutex > lg{m_mtx}; | ||
m_cb_blks[mblk->hdr.h.bid.to_integer()] = md5_sum(r_cast< const char* >(buf.bytes()), size); | ||
m_cb_blks[mblk->hdr.h.bid.to_integer()] = sb_info_t { | ||
mblk, md5_sum(r_cast< const char* >(buf.bytes()), size)}; | ||
} | ||
}, | ||
[this](bool success) { HS_DBG_ASSERT_EQ(success, true); }); | ||
[this](bool success) { | ||
HS_DBG_ASSERT_EQ(success, true); | ||
m_total_wrt_sz = m_mbm->used_size(); | ||
HS_REL_ASSERT_EQ(m_mbm->total_size() - m_total_wrt_sz, m_mbm->available_blks() * m_mbm->block_size()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update the |
||
}); | ||
} | ||
|
||
void register_client_inlcuding_dependencies() { | ||
|
@@ -682,7 +689,8 @@ class VMetaBlkMgrTest : public ::testing::Test { | |
[this](meta_blk* mblk, sisl::byte_view buf, size_t size) { | ||
if (mblk) { | ||
std::unique_lock< std::mutex > lg{m_mtx}; | ||
m_cb_blks[mblk->hdr.h.bid.to_integer()] = std::string{r_cast< const char* >(buf.bytes()), size}; | ||
m_cb_blks[mblk->hdr.h.bid.to_integer()] = sb_info_t { | ||
mblk, md5_sum(r_cast< const char* >(buf.bytes()), size)}; | ||
} | ||
}, | ||
[this](bool success) { HS_DBG_ASSERT_EQ(success, true); }); | ||
|
@@ -702,10 +710,11 @@ class VMetaBlkMgrTest : public ::testing::Test { | |
uint64_t m_wrt_cnt{0}; | ||
uint64_t m_update_cnt{0}; | ||
uint64_t m_rm_cnt{0}; | ||
uint64_t m_restart_cnt{0}; | ||
uint64_t m_total_wrt_sz{0}; | ||
MetaBlkService* m_mbm{nullptr}; | ||
std::map< uint64_t, sb_info_t > m_write_sbs; // during write, save blkid to buf map; | ||
std::map< uint64_t, std::string > m_cb_blks; // during recover, save blkid to buf map; | ||
std::map< uint64_t, sb_info_t > m_cb_blks; // during recover, save blkid to buf map; | ||
std::mutex m_mtx; | ||
#ifdef _PRERELEASE | ||
flip::FlipClient m_fc{HomeStoreFlip::instance()}; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
use
m_cb_blks
to replacem_write_sbs
, as all the cookies saved inm_write_sbs
is invalid after restart