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

Prevent state file corruption and check state file sanity on save #1682

Merged
merged 5 commits into from
Sep 13, 2016

Conversation

schmichael
Copy link
Member

@schmichael schmichael commented Sep 2, 2016

2 changes to try to address #1367

Here's the potential series of events that the lock is designed to guard against:

g1 - r.dirtyCh <- struct{}{}
g2 - r.syncStatus()
g1 - writes temporary file inside of persistState
g2 - truncates temporary file prior to writing to it inside of persistState
g1 - os.Renames truncated temporary file to state file
<process killed>

Using random temporary file names would also work but then we'd have to clean up temporary files leaked during unclean shutdowns.

Also just reuse the task states snapshot taken by `Alloc()` instead of
doing a redundant copy.
Prevent interleaving state syncs as it could conceivably lead to
empty state files as per #1367
@schmichael schmichael changed the title WIP (testing) - Prevent state file corruption and check state file sanity on save Prevent state file corruption and check state file sanity on save Sep 12, 2016
@dadgar
Copy link
Contributor

dadgar commented Sep 13, 2016

LGTM

@schmichael schmichael merged commit bbe884a into master Sep 13, 2016
@schmichael schmichael deleted the b-sanity-check-state-file branch September 13, 2016 18:24
schmichael added a commit that referenced this pull request Sep 13, 2016
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants