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

Last snapshot of state machine #301

Open
nptai opened this issue Mar 13, 2022 · 1 comment
Open

Last snapshot of state machine #301

nptai opened this issue Mar 13, 2022 · 1 comment

Comments

@nptai
Copy link

nptai commented Mar 13, 2022

void raft_server::on_snapshot_completed
     ( ptr<snapshot>& s, bool result, ptr<std::exception>& err )
{
...
    {
        recur_lock(lock_);
        p_in("snapshot idx %lu log_term %lu created, "
             "compact the log store if needed",
             s->get_last_log_idx(), s->get_last_log_term());

       ptr<snapshot> new_snp = state_machine_->last_snapshot();
...
}

I found that state_machine_->last_snapshot() may change during doing commit_in_bg_exec(), that causes N19_bad_log_idx_for_term
Why don't use s?

@greensky00
Copy link
Contributor

That is intended as new_snp is for calling set_last_snapshot and doing log compaction. As you mentioned, the last snapshot may change so that we always want to pick up the latest one under the lock_.

Can you please elaborate more on N19_bad_log_idx_for_term (log, stack trace)? How did it happen?

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

No branches or pull requests

2 participants