ensure every record in wal is only applied once when restart (#7920) #7922
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.
This is an automated cherry-pick of #7920
What problem does this PR solve?
Issue Number:
Problem Summary:
After dumping snapshot to checkpoint file, we only remove log files which max sequence is smaller than the sequence used to dump snapshot.
So the remaining wal files may have some overlap with the checkpoint file.
And at restart, we will apply all records in the checkpoint file and other wal files which will cause some records to be applied more than once.
This may cause some problem like the following picture.
Because page 88 was already deleted, it is not shown in the checkpoint file
log_100_1
. But the operationref 90 -> 88
is still in later log files. So at restart, when it try to apply this record, it will fail to complete the ref operation.What is changed and how it works?
Record the snap sequence used to dump checkpoint in the filename of checkpoint file. Specifically, change it from
log_100_1
tolog_100_1_400
.When restart, after apply all records in checkpoint file, we will skip later record which sequence is smaller than the snap sequence in the checkpoint file name.
Check List
Tests
Side effects
Documentation
Release note