support set truncate_index manually in on_snapshot_save #457
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.
In braft, creating a snapshot will result in the truncation of logs, and users can not decide which logs will be truncated after snapshot_save.
But sometimes, user wants to take over it and decides which logs should be retained.
For example, last_index=20 now, And snapshot_save is issued, but I don’t want to truncate all the logs before 20.
On the contrary, logs between 11-20 should be kept and only logs before 11 will be truncated. But now, users can't achieve it. : (
I believe it will be a useful feature. By fully controlling the truncate index, users can use raft log as WAL of non-volatile StateMachine or to implement CDC etc.