Skip to content
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

Merged
merged 1 commit into from
Aug 28, 2024
Merged

Conversation

raakella1
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 67.45%. Comparing base (1a0cef8) to head (7652028).
Report is 51 commits behind head on master.

Files with missing lines Patch % Lines
src/lib/replication/repl_dev/raft_repl_dev.cpp 87.50% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #524       +/-   ##
===========================================
+ Coverage   56.51%   67.45%   +10.94%     
===========================================
  Files         108      109        +1     
  Lines       10300    10427      +127     
  Branches     1402     1399        -3     
===========================================
+ Hits         5821     7034     +1213     
+ Misses       3894     2717     -1177     
- Partials      585      676       +91     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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) {
commit_blk(rreq);
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to dirty the blks without allocating them?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not yet but we can change dataservice api?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also implement roll_back to free blk

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

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.

@@ -1181,10 +1186,12 @@ void RaftReplDev::on_log_found(logstore_seq_num_t lsn, log_buffer buf, void* ctx
}

rreq->set_lsn(repl_lsn);
rreq->set_lentry(lentry);
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 commit().

I would vote even for normal operations we keep lentry shared_ptr for safety and more consistent behavior.

Copy link
Collaborator

@xiaoxichen xiaoxichen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

We didnt catch both bugs in all our restorability UT, because both bugs occurs if we have dc_lsn < last_log_lsn , how can we have this UT to exercise this path?

@@ -1181,10 +1186,14 @@ void RaftReplDev::on_log_found(logstore_seq_num_t lsn, log_buffer buf, void* ctx
}

Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug build

@@ -234,6 +235,7 @@ struct repl_req_ctx : public boost::intrusive_ref_counter< repl_req_ctx, boost::
std::variant< std::unique_ptr< uint8_t[] >, raft_buf_ptr_t > m_journal_buf; // Buf for the journal entry
repl_journal_entry* m_journal_entry{nullptr}; // pointer to the journal entry
bool m_is_jentry_localize_pending{false}; // Is the journal entry needs to be localized from remote
nuraft::ptr< nuraft::log_entry > m_lentry;
Copy link
Contributor

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

@xiaoxichen
Copy link
Collaborator

As discussed in DM, this PR is not right as there is no guarantee the data has been written to the allocated blks before the restart.

@JacksonYao287
Copy link
Contributor

        HomeRaftLogStore::end_of_append_batch(start_lsn, count);
        HISTOGRAM_OBSERVE(m_rd.metrics(), raft_end_of_append_batch_latency_us, get_elapsed_time_us(cur_time));

        cur_time = std::chrono::steady_clock::now();
        // Wait for the fetch and write to be completed successfully.
        std::move(fut).wait();

we can put std::move(fut).wait() before end_of_append_batch.

if data is written but log is not flushed, that`s fine, since the block is not committed

@xiaoxichen
Copy link
Collaborator

yes we can, it is trading regular IO latency vs space leak during recovery, which I am not sure it worth to .

Prior to that, we have to solve the rollback stuff.

@JacksonYao287
Copy link
Contributor

Prior to that, we have to solve the rollback stuff.

rollback happens when a request is pre_committed but not committed.
1 in normal case, we can free the blk in on_rollback.
2 in recovery case , since the blk is not commited (commit_blk will be called in on_commit), so blk leak will not happen.
in on_log_found, if the lsn of a log entry is bigger than dc_sln, we can just discard it.

any input?

xiaoxichen
xiaoxichen previously approved these changes Aug 28, 2024
@xiaoxichen
Copy link
Collaborator

@raakella1 raakella1 merged commit 8d6d70b into eBay:master Aug 28, 2024
21 checks passed
@raakella1 raakella1 deleted the commit_blk branch August 28, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants