Skip to content

Swift eventual consistency problems? #1013

Closed

Description

@tdooner

Hey @ojacques @nevermosby, thanks a lot for integrating Swift support into this project. We're running in Rackspace and are using Cloud Files (Rackspace's installation of Swift) as our storage driver.

When pushing layers, we often notice errors like:

» docker push [image_name]
The push refers to a repository [image_name] (len: 1)
6db1d48e9f8d: Image successfully pushed
6165b10a9c5b: Image successfully pushed
4c9dbc176128: Image successfully pushed
1a0202a44aea: Image successfully pushed
574ba1962306: Image successfully pushed
b45b44f4dace: Image successfully pushed
a2173b937aaf: Pushing [==================================================>] 4.028 MB/4.028 MB
digest invalid: provided digest did not match uploaded content

Retrying the docker push a few seconds later works. This error is so common that I was able to reproduce this on my first shot, and most 10-layer images take 2-3 tries before they are successfully pushed.

It looks like there previously was a hack to retry in layerwriter.go for this purpose, but that was removed in a refactor. Since then, retry logic has crept back into the S3 driver, albeit for a different reason (slow S3 connections).

Anyway, I bring this up to ask if you guys would consider adding a similar retry logic if you buy that the problem is Swift's eventual consistency. Do you guys see this problem at HP?

I can bumble around in Go myself if you guys think this is worthwhile, but I feel it would be faster if you guys are down to build it.

Anyhow, cheers and thanks again for adding Swift integration to this project.

cc @sds @z3usy

Activity

  1. ojacques commented on Sep 23, 2015

    @ojacques
    Contributor

    Interesting @tdooner - we are on 2.1, and have not seen this afaik. @lebauce, @nevermosby - thoughts?

  2. nevermosby commented on Sep 23, 2015

    @nevermosby
    Contributor

    Hi @tdooner, could u please provide more information about the docker client and registry you use:

    • the version of docker client
    • the vesion of docker registry
    • anything special for your pushed docker image
      With which, I can take a further look on this issue.
  3. sds commented on Sep 23, 2015

    @sds

    Hey @nevermosby, we can reproduce this with:

    • Docker client 1.7.1 or 1.8.1
    • Docker Registry 2.1.1

    There is nothing special about the images we're pushing—the problem is just more likely to occur with images with many layers. While we haven't done extensive testing to confirm, it would also seem that the larger the layer the more likely the problem will occur.

  4. nevermosby commented on Sep 24, 2015

    @nevermosby
    Contributor

    @sds Thx for your information. I will look into it.

  5. d23 commented on Sep 24, 2015

    @d23

    We're facing the same problem, same versions (also docker 1.6), running a single registry instance.
    It fails roughly 1 in 10 layers, but it's very erratic. I'll see if i can get some more information, the logs i currenlty have don't tell much besides that the digest didn't match.

    Maybe always doing a full recalculation if they don't match, might help? (ie. always go for fullHash here, since the same check is done then as well)

  6. lebauce commented on Oct 29, 2015

    @lebauce
    Contributor

    @tdooner On Rackspace Cloud Files, the uploads fail quite frequently. The problem appears when a manifest has been uploaded but some segments of this manifest are not part of the object listing yet.

    The easiest way is to ensure that a segment exists after its been uploaded. I created a pull request that implements it here : #1141

  7. lebauce commented on Nov 4, 2015

    @lebauce
    Contributor

    @tdooner @sds Any chance that you give the PR a try to see if it improves the situation ?

  8. tdooner commented on Nov 10, 2015

    @tdooner
    Author

    @lebauce Thanks for the patch. We've been running it for the last few days. I haven't seen the problem since!

  9. tdooner commented on Nov 17, 2015

    @tdooner
    Author

    Bummer - the problem definitely still happens even with this patch.

  10. lebauce commented on Nov 23, 2015

    @lebauce
    Contributor

    @tdooner Can you confirm that it appears less often than before ? This patch should make the situation better but not remove the problem completely. I rewrote the code to use Static Large Objects instead of Dynamic Large Objects (https://github.com/lebauce/distribution/tree/swift-static-large-objects). They provide better guarantees regarding eventual consistency. It already working but I need to make additional testing before submitting a PR.

  11. tdooner commented on Nov 23, 2015

    @tdooner
    Author

    It's hard to say about the frequency. It seems like it is happening less frequently with #1141, but it's still easy to reproduce with large image uploads.

    The SLO thing sounds like a promising direction, though. Happy to try that branch once it's decently ready.

  12. reiz commented on Dec 2, 2015

    @reiz

    I have the same problems with Swift on RackSpace :-(

  13. lebauce commented on Dec 2, 2015

    @lebauce
    Contributor

    @reiz This problem seems to happen more frequently on Rackspace. Is there any chance that you try the branch #1229 to see if it fixes your problem ?

  14. reiz commented on Dec 2, 2015

    @reiz

    @lebauce You posted a link to the pull request, but I can't find the actual branch. Can you post a link to your branch/fork?

  15. 42 remaining items

  16. ncw commented on Sep 8, 2017

    @ncw

    The problems seem to be caused by eventual consistency in the container listings to make the segments of the DLO so when it is downloaded to have its hash checked it is incorrect.

    In my experience swift clusters have reasonably good eventual consistency, but it can take several seconds for everything to get in order. @majewsky 's approach of retrying the container listings seems like the right one to me (and is the approach I use in the rclone integration tests).

    Once thing which would help would be to create single objects rather than DLOs for small uploads. Swift can have objects up to 5GB. Assuming I'm reading the code correctly, it seems to segment objects into 20MB chunks and store everything as a DLO.

    If it stored smaller objects as single swift objects then this kind of eventual consistency would not be a problem. It would also be more efficient for the swift cluster.

  17. siju-vasudevan commented on Sep 9, 2017

    @siju-vasudevan

    @majewsky's and @ncw Thanks a lot for the info.

    Yesterday i got a chance to have look at the swift back end logs to see there is any error in swift logs when the push is happening. There is no error in the swift back end. The issue which i found for the zero byte layer is that , it does n't have corresponding segment. I checked in the swift logs and found swift did not received any PUT request for the segment for that layers.

  18. Vad1mo commented on Sep 9, 2017

    @Vad1mo
    Contributor

    @siju-vasudevan this is the same thing that we experience. As we didn't had access the swift server we couldn't look at the logs. This issue might have a distant relation to eventual consistency however the result is that the layer isn't simply there like you proofed.
    Thats why every subsequent push of this or any derived image will fail. Because the registry image is in a corrupt state. It has only part of the data. This prevents from pushing the same image again twice or any derived image that relies on the same layer.

    Based on our analysis and reports from other, a workaround would be when an image is pushed and the registry detects that the image is in a corrupt state it should delete that layer so a subsequent push will at least work. The previous image will be still corrupt but at least the retry or subsequent images will work.

  19. siju-vasudevan commented on Sep 13, 2017

    @siju-vasudevan

    Hi,
    Thanks for the info.
    Can we add a code in registry push function ie, once all the layers are push.. the code needs to get the manifest and compare layer size from the manifest and the actual layer size in swift backed . If it finds any mismatch then it should delete the corrupted layer and push the layer again.

    It would be great if someone who has written the registry code make this change.

  20. Vad1mo commented on Mar 12, 2018

    @Vad1mo
    Contributor

    I am once again digging into this topic.
    As you can see from the output the Segment doesn't exist, even two hours later.

    I don't think think that this is a consistency issue problem. @majewsky will swift-plus #2441 address this issue?

    swift stat --lh  images files/docker/registry/v2/blobs/sha256/eb/ebfc544c3dd05d7c30b150d02c0e77bbf9e5de952515263a46f4801e5a8bdf11/data
    
    
                   Account: AUTH_b50accfce5044d6e9e47f80d012ca4e7
                 Container: images
                    Object: files/docker/registry/v2/blobs/sha256/eb/ebfc544c3dd05d7c30b150d02c0e77bbf9e5de952515263a46f4801e5a8bdf11/data
              Content Type: application/octet-stream
            Content Length: 0
             Last Modified: Mon, 12 Mar 2018 16:06:52 GMT
                      ETag: "d41d8cd98f00b204e9800998ecf8427e"
                  Manifest: images/segments/2f6/46f636b65722f72656769737472792f76322f7265706f7369746f726965732f66696e6f2f636f6e7472616374636f6163682d75692f5f75706c6f6164732f37363139623766632d323030392d346264312d626338312d3863633632626438363731642f64617461ac5e2076ab155b92e5776db888db3c6c36466eb72c80cbe92cdeb408fcfd951bda39a3ee5e6b4b0d3255bfef95601890afd80709
             Accept-Ranges: bytes
           X-Iplb-Instance: 12631
               X-Timestamp: 1520870811.99928
                X-Trans-Id: txa3dce2020b404abaa329c-005aa6b994
    X-Openstack-Request-Id: txa3dce2020b404abaa329c-005aa6b994
    

    two hours later:

    Lets see if we can find the Manifest content:

    root@dd:~# swift list images -l --lh | grep segments/2f6/46f636b65722f72656769737472792f76322f7265706f7369746f726965732f66696e6f2f636f6e7472616374636f6163682d75692f5f75706c6f6164732f37363139623766632d323030392d346264312d626338312d3863633632626438363731642f64617461ac5e2076ab155b92e5776db888db3c6c36466eb72c80cbe92cdeb408fcfd951bda39a3ee5e6b4b0d3255bfef95601890afd80709
    root@dd
    root@dd:~# date
    Mon Mar 12 18:36:06 CET 2018
  21. MartinMikita commented on May 23, 2018

    @MartinMikita

    Hi, we are experiencing the same problem with some layers (size ~ 150MB).
    We are using docker/registry:2.6 and images are built by docker version 17.05.0-ce.
    We are using as well swift storage on OVH.

    Have anybody found the working solution for this issue?
    Probably some config-related problem?

  22. Vad1mo commented on May 23, 2018

    @Vad1mo
    Contributor

    @MartinMikita The Swift implementation in Docker Registry is broken. There are some attempts to improve it e.g. #2441 however there is nothing there yet that is working. If you want a reliable storage backend for swift use #2441 or move or use a proxy https://github.com/openstack/swift3 or use a filesystem for Swift like S3QL

  23. ncw commented on May 23, 2018

    @ncw

    I think the pragmatic solution is my suggestion above:

    Once thing which would help would be to create single objects rather than DLOs for small uploads. Swift can have objects up to 5GB. Assuming I'm reading the code correctly, it seems to segment objects into 20MB chunks and store everything as a DLO.

    That will work very well for all objects < 5GB which is nearly all of them I think.

    This isn't perfect but it will make the situation loads better. It is also 100% backwards compatible.

    Dynamic Large Objects and Static Large Objects are a mess in Swift if you ask me... They rely on consistent directory listings and the user to make sure all the parts are present so are best avoided IMHO.

  24. Vad1mo commented on May 23, 2018

    @Vad1mo
    Contributor

    @ncw can't agree more with you. DLO, SLO aren't needed. Even Windows images (with windows) don't have layers above 1GB. Anyone who is trying to push layers above 5GB should be whipped. Until we have better DLO/SLO support we should go back single objects.

  25. majewsky commented on Jun 3, 2018

    @majewsky
    Contributor

    @Vad1mo swift-plus should not be affected by this since SLOs do not need an up-to-date container listing. However, if the container listing does not converge on a timescale of 2 hours, something is seriously wrong with the Swift cluster, and I would start investigating what's going on in there.

    • How do the async_pendings metrics look?
    • Is the object-updater running on each storage node?
    • Does its log indicate any abnormalities?
  26. Vad1mo commented on Jun 3, 2018

    @Vad1mo
    Contributor

    @majewsky, I am pretty sure the problem has to do with the Registry Swift Driver implementation as we have seen it on OVH, Rackspace, and Oracle Cloud. I don't think they all do it wrong, unless its broken by design. Then its a swift problem. I am confident that #2441 will solve the problem, but I am not confident that #2441 will be accepted.

    I might be wrong, but in this messy situation a realistic solution is to change the current code to a single object solution as @ncw suggested and stay backward compatible.

  27. milosgajdos commented on Dec 18, 2023

    @milosgajdos
    Member

    Closing as Swift driver is no longer supported by this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions