Skip to content

mirror cann't pull with 0 size file  #3247

Open

Description

@zhipengzuo

like the issue #2367
when the registry as proxy ,sometimes the client will retry .
what i see in the registry log:
image
GET this blob return 0 size.

i try to debug:the layer blob data don't at the machine path,but the linkblob still existed.(the linkblob refer to _layers/sha256/xxx).

so i read the code.
normally when the blob of the layer isn't the machine,the registy will to pull the blob from the remote registry first.
but in this case ,the mirror didn't trigger that.

let's see the code:
when a pull request comes to the mirror ,it will go to serverblob:
if the "served" is true ,it will not to pull the blob from the remote registry.
image

at my log ,i see served is true (i print it) but blob data.
image

then will check this layer whether in the cache Descriptor map .
image

at the gc time ,if many images share one layer ,it will not check whether other layer using this layer ,delete layer blob directly and clear this map. but the map is not a global Descriptor map.

image

image

at this time ,when another try to get blob data ,it will check the map ,the map show this layer is existed because the linkbob of this image is existed(but in fact the blob data is not existed) ,so it starts read and return 0 size file(because the blobdata is deleted).

when the registry restarts , the Descriptor map disappear and become an empty map.
when a pull request come, how the registry do is to check whether the linkblob is existed to call SetDescriptor map
image
the question comes, the blob of the layer may be deleted by another image's gc time.

so the cause of this bug is the registy only check the linkblob but doesn't check the blob whether existed . so registy will not trigger to pull layer from remote registry
why the registry this design is
image
so at this design we can't directly check the blob ... so what should we do to ensure to trigger pulling from remote registry
when the linkblob is existed and blobdata is deleted by another image at gc time?

if some understanding is not fully correct , weclome to point it .

Activity

  1. docwhat commented on Oct 20, 2020

    @docwhat

    Awesome detective work!

  2. docwhat commented on Oct 27, 2020

    @docwhat

    So... disabling the cache settings should be a workaround for this? i.e. removing the STORAGE_CACHE_BLOBDESCRIPTOR option altogether?

  3. zhipengzuo commented on Oct 27, 2020

    @zhipengzuo
    Author

    So... disabling the cache settings should be a workaround for this? i.e. removing the STORAGE_CACHE_BLOBDESCRIPTOR option altogether?

    at that situation, how could mirror to judge one layer whether between creation and population。if by the link , the problem is also existed.
    https://github.com/docker/distribution/blob/2800ab02245e2eafc10e338939511dd1aeb5e135/registry/proxy/proxyblobstore.go#L70

  4. docwhat commented on Oct 27, 2020

    @docwhat

    I'm having a hard time figuring out how the storage cache is setup and/or disabled; I apologize if I got this wrong.

    My assumption is that without the cache Stat() queries the storage directly. Storage wouldn't have any time between creation and population: either it exists or doesn't.

    It is the cache that allows the inconsistency between the descriptor (in cache) and blob (in storage).

  5. zhipengzuo commented on Oct 27, 2020

    @zhipengzuo
    Author

    I'm having a hard time figuring out how the storage cache is setup and/or disabled; I apologize if I got this wrong.

    My assumption is that without the cache Stat() queries the storage directly. Storage wouldn't have any time between creation and population: either it exists or doesn't.

    It is the cache that allows the inconsistency between the descriptor (in cache) and blob (in storage).

    ok . maybe have a try and add some debug message .

  6. docwhat commented on Dec 1, 2020

    @docwhat

    We've been using it over a month with zero problems, so it looks like the cache should be disabled for local file store.

  7. zhipengzuo commented on Jan 15, 2021

    @zhipengzuo
    Author

    @docwhat hello can you offer a pr to disable cache as default when as mirror ?

  8. docwhat commented on Jan 19, 2021

    @docwhat

    I think that's the default already.

    I think the memory caching should be disabled unconditionally when using a local file store.

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