-
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
commit blk during log replay in rep dev #524
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,11 +77,12 @@ RaftReplDev::RaftReplDev(RaftReplService& svc, superblk< raft_repl_dev_superblk | |
} | ||
|
||
RD_LOG(INFO, | ||
"Started {} RaftReplDev group_id={}, replica_id={}, raft_server_id={} commited_lsn={}, compact_lsn={} " | ||
"next_dsn={} " | ||
"Started {} RaftReplDev group_id={}, replica_id={}, raft_server_id={} commited_lsn={}, " | ||
"compact_lsn={}, checkpoint_lsn:{}, next_dsn={} " | ||
"log_dev={} log_store={}", | ||
(load_existing ? "Existing" : "New"), group_id_str(), my_replica_id_str(), m_raft_server_id, | ||
m_commit_upto_lsn.load(), m_compact_lsn.load(), m_next_dsn.load(), m_rd_sb->logdev_id, m_rd_sb->logstore_id); | ||
m_commit_upto_lsn.load(), m_compact_lsn.load(), m_rd_sb->checkpoint_lsn, m_next_dsn.load(), | ||
m_rd_sb->logdev_id, m_rd_sb->logstore_id); | ||
|
||
#ifdef _PRERELEASE | ||
m_msg_mgr.bind_data_service_request(PUSH_DATA, m_group_id, [this](intrusive< sisl::GenericRpcData >& rpc_data) { | ||
|
@@ -746,7 +747,7 @@ void RaftReplDev::handle_fetch_data_response(sisl::GenericClientResponse respons | |
RD_DBG_ASSERT_EQ(total_size, 0, "Total size mismatch, some data is not consumed"); | ||
} | ||
|
||
void RaftReplDev::handle_commit(repl_req_ptr_t rreq, bool recovery) { | ||
void RaftReplDev::commit_blk(repl_req_ptr_t rreq) { | ||
if (rreq->local_blkid().is_valid()) { | ||
if (data_service().commit_blk(rreq->local_blkid()) != BlkAllocStatus::SUCCESS) { | ||
if (hs()->device_mgr()->is_boot_in_degraded_mode() && m_log_store_replay_done) | ||
|
@@ -755,6 +756,10 @@ void RaftReplDev::handle_commit(repl_req_ptr_t rreq, bool recovery) { | |
RD_DBG_ASSERT(false, "fail to commit blk when applying log in non-degraded mode.") | ||
} | ||
} | ||
} | ||
|
||
void RaftReplDev::handle_commit(repl_req_ptr_t rreq, bool recovery) { | ||
commit_blk(rreq); | ||
|
||
// Remove the request from repl_key map. | ||
m_repl_key_req_map.erase(rreq->rkey()); | ||
|
@@ -1181,10 +1186,14 @@ void RaftReplDev::on_log_found(logstore_seq_num_t lsn, log_buffer buf, void* ctx | |
} | ||
|
||
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. Not directly related to this PR, but could impact some of the assert in underlying layer, is SM long run currently use debug build or release build? 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. Debug build |
||
rreq->set_lsn(repl_lsn); | ||
// keep lentry in scope for the lyfe cycle of the rreq | ||
raakella1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rreq->set_lentry(lentry); | ||
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. This is a bit hacky as we dont set it in normal IO path , we believe nuraft will not release them during the whole lifecycle till I would vote even for normal operations we keep lentry shared_ptr for safety and more consistent behavior. |
||
rreq->init(rkey, jentry->code, false /* is_proposer */, entry_to_hdr(jentry), entry_to_key(jentry), data_size); | ||
RD_LOGD("Replay log on restart, rreq=[{}]", rreq->to_string()); | ||
|
||
if (repl_lsn > m_rd_sb->durable_commit_lsn) { | ||
// In memory state of these blks is lost. Commit them now to avoid usage of same blk twice. | ||
commit_blk(rreq); | ||
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. Nit: can we dirty the allocator with these blks and still commit them in handle_commit()?. Just in the case for rollback. 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. Is there a way to dirty the blks without allocating them? 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. not yet but we can change dataservice api? 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. also implement roll_back to free blk 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.
Just be noted commit_blk will be expecting blks in allocated state for non-recovery mode (existing handle_commit), and for recovery mode, it will try to reserve on cache also before committing to disk; Need a bit more handling to combine them. |
||
m_state_machine->link_lsn_to_req(rreq, int64_cast(repl_lsn)); | ||
return; | ||
} | ||
|
@@ -1202,7 +1211,12 @@ bool RaftReplDev::is_resync_mode() { | |
int64_t const leader_commited_lsn = raft_server()->get_leader_committed_log_idx(); | ||
int64_t const my_log_idx = raft_server()->get_last_log_idx(); | ||
auto diff = leader_commited_lsn - my_log_idx; | ||
return diff > HS_DYNAMIC_CONFIG(consensus.resync_log_idx_threshold); | ||
bool resync_mode = (diff > HS_DYNAMIC_CONFIG(consensus.resync_log_idx_threshold)); | ||
if (resync_mode) { | ||
RD_LOGD("Raft Channel: Resync mode, leader_commited_lsn={}, my_log_idx={}, diff={}", leader_commited_lsn, | ||
my_log_idx, diff); | ||
} | ||
return resync_mode; | ||
} | ||
|
||
} // namespace homestore |
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.
would be nice to put a comment here that this is only needed during recovery