You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Andy Wu (JIRA)" <ji...@apache.org> on 2019/05/09 17:35:00 UTC

[jira] [Commented] (RATIS-243) Add log purge function after taking snapshot

    [ https://issues.apache.org/jira/browse/RATIS-243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16836573#comment-16836573 ] 

Andy Wu commented on RATIS-243:
-------------------------------

[~alanwu1009] One question: purge logic is taken care in StateMachineUpdater. Why do you need to call raftLog.purge(index) in your implemented StateMachine?
{code:java}
        // check if need to trigger a snapshot
        if (shouldTakeSnapshot()) {
          if (futures.isInitialized()) {
            JavaUtils.allOf(futures.get()).get();
          }
          lastSnapshotIndex = stateMachine.takeSnapshot();
          raftLog.purge(lastSnapshotIndex);
        }
{code}


> Add log purge function after taking snapshot
> --------------------------------------------
>
>                 Key: RATIS-243
>                 URL: https://issues.apache.org/jira/browse/RATIS-243
>             Project: Ratis
>          Issue Type: Improvement
>          Components: server
>            Reporter: Andy Wu
>            Assignee: Andy Wu
>            Priority: Major
>             Fix For: 0.4.0
>
>         Attachments: r243_20190412.patch, r243_20190415.patch, r243_20190416.patch, r243_20190418.patch
>
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> After snapshotting the state machine, we can safely purge logs in the cache and disk.
> Based on the lastAppliedIndex, we can find out which segment the index lands, we can purge all previous segments if leader has no pending RPC on it. We will leave the segment where index lands alone, so we do not need to deal with partial file deletion logic. 
> Also if we only have snapshots, make sure we can install snapshots to the followers. 
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)