-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Update layer store to sync transaction files before committing #25523
Conversation
/cc @aaronlehmann @tonistiigi ptal |
To be more consistent with existing
|
Windows error seems real:
|
@mlaventure: ugh yes, Window's lack of support for mode makes it annoying to test. In this case @tonistiigi: I had considered using |
err = io.ErrShortWrite | ||
} | ||
if err == nil { | ||
err = f.Sync() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an optimization, it may make sense to leave the files open and call Sync
on all of the files at Commit
time before the rename.
If multiple files are written sequentially, each Sync
could be expensive. But by delaying the Sync
s until commit time, the first one would probably flush all the buffers, and the remaining syncs would be no-ops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree with that optimization, was trying to avoid until I knew what the impact would be. We could get away with leaving most the files open until then, except for the tar split file which gets explicitly closed after apply.
Fixes case where shutdown occurs before content is synced to disked on layer creation. This case can leave the layer store in an bad state and require manual recovery. This change ensures all files are synced to disk before a layer is committed. Any shutdown that occurs will only cause the layer to not show up but will allow it to be repulled or recreated without error. Added generic io logic to ioutils package to abstract it out of the layer store package. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
c0b7512
to
c37bd10
Compare
Updated and ci is passing again |
Any thoughts about adding the optimization? |
@aaronlehmann: I have, right now the only way I see doing it involves making the returned close a nop, add each |
@dmcgowan What about |
Yeah, this was what I had in mind. I don't see a problem with leaving the files open until |
@tonistiigi: @aaronlehmann: I am less convinced of the value of this optimization. While |
LGTM. Single fsync would be nice (unless benchmarks on machines with slow disks show it doesn't have an impact) but can be a follow-up. |
@aaronlehmann Are you good with this? |
I still feel like coalescing the fsync would be a meaningful improvement, but as Tonis says that could be a followup. |
This set of patches make sure that changes in the layer store are synced to disk before updating the metadata of docker. connects to moby/moby#25523 fixes resin-io/hq#274 Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
This set of patches make sure that changes in the layer store are synced to disk before updating the metadata of docker. connects to moby/moby#25523 fixes resin-io/hq#274 Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
@aaronlehmann Does that mean you give this one your blessing? |
Yeah |
LGTM |
Fixes case where shutdown occurs before content is synced to disked on layer creation. This case can leave the layer store in an bad state and require manual recovery. This change ensures all files are synced to disk before a layer is committed. Any shutdown that occurs will only cause the layer to not show up but will allow it to be repulled or recreated without error. Added generic io logic to ioutils package to abstract it out of the layer store package. This is cherry-picked from docker upstream PR: moby#25523 Signed-off-by: Derek McGowan <derek@mcgstyle.net> Signed-off-by: Deng Guangxing <dengguangxing@huawei.com>
Fixes case where shutdown occurs before content is synced to disked
on layer creation. This case can leave the layer store in an bad
state and require manual recovery. This change ensures all files
are synced to disk before a layer is committed. Any shutdown that
occurs will only cause the layer to not show up but will allow it to
be repulled or recreated without error.
Added generic io logic to ioutils package to abstract it out of
the layer store package.
This is designed to address #23184 but further testing is needed before
that issue can be marked resolved. This change will also not fix
any layer store with existing empty files.