Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

rkt/image: lock temp files to avoid problems with concurrent fetches #2239

Merged
merged 3 commits into from
Mar 15, 2016

Conversation

iaguis
Copy link
Member

@iaguis iaguis commented Feb 29, 2016

Whenever we create a Store temporary file, we lock it so concurrent
downloads don't corrupt it.

Fixes #2165

When figuring out if we can resume a session, if we get a bad HTTP
status, we were just returning without error and weren't resetting the
session. This means we will download the full file *on top* of the already
present file, which of course leads to a corrupted file.

Reset the session in that case.
Whenever we create a Store temporary file, we lock it so concurrent
downloads don't corrupt it.
@iaguis
Copy link
Member Author

iaguis commented Mar 14, 2016

Ping?

@krnowak
Copy link
Collaborator

krnowak commented Mar 14, 2016

How come the functional tests didn't catch the bug that got fixed by the first commit?

@iaguis
Copy link
Member Author

iaguis commented Mar 14, 2016

How come the functional tests didn't catch the bug that got fixed by the first commit?

IIRC, S3 is returning some 4xx error when trying to resume a download, which our test server doesn't.

_, err = lock.TryExclusiveLock(tmp.Name(), lock.RegFile)
if err != nil {
if err != lock.ErrLocked {
return nil, err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add some text describing what failed? "failed to lock a file" or something?

@krnowak
Copy link
Collaborator

krnowak commented Mar 14, 2016

This should prevent corrupting the image, but rkt will download the same image again. Not sure if we should worry about it in this PR.

Anyway, one nit about error message, otherwise LFAD.

@iaguis
Copy link
Member Author

iaguis commented Mar 15, 2016

Updated

krnowak added a commit that referenced this pull request Mar 15, 2016
rkt/image: lock temp files to avoid problems with concurrent fetches
@krnowak krnowak merged commit 15b29e9 into rkt:master Mar 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants