Safe checkpointing - #33
Open
StefanFlaumberg wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The AleRax checkpoint comprises the checkpoint directory and files within it:
args.txt,fams.txt,mainCheckpoint.txtand family files storing the per-family model parameters. While theargs.txtandfams.txtfiles are written only once, at the start of the run, themainCheckpoint.txtand family files are overwritten multiple times during the run. This implies a practically significant chance of checkpoint corruption: an interrupted run can leave some of the latter files only partially written or not updated at all since the previous checkpoint (resulting in a mixed checkpoint).This PR implements a simple algorithm to detect most of the practical cases of checkpoint corruption. The algorithm is based on the following ideas:
args.txtandfams.txtfiles are written always before themainCheckpoint.txtfile. So finding the latter file implies the existence of the former two.AleState::serialize()function rewrites all the family files always after themainCheckpoint.txtfile. So an "incomplete" header can be put into themainCheckpoint.txtfile to signal the start of aserialize()call and later be substituted with a "complete" header to signal the end of aserialize()call. Finding a complete header implies that themainCheckpoint.txtfile and all the family files have been updated, while any other situation results in a corrupted or incomplete header.The new
AleState::checkpointExists()function is called at the start of the run. It returns whether the checkpoint directory exists. And if the directory does exist, the function checks themainCheckpoint.txtheader and aborts with a user-friendly error if the header is in any way different from the complete one.False positive corruption detection:
Should not occur. The only possibility I see is a run interruption happening right after all family files have been updated, yet before the
mainCheckpoint.txtheader flip -- a time window too narrow to be practically relevant.False negative corruption detection:
This algorithm heavily relies on the file writing order to the OS kernel buffer; hence, it does not cover checkpoint corruption cases caused by file deletion or modification or by a kernel crash. The latter can result in some files or their parts not being transferred from the OS kernel buffer to the disk. A solution to this would require using methods such as
fsync(). But, unlike checkpoint corruption cases caused by a process kill, which are fully covered by the algorithm, these scenarios are quite rare.