Repository navigation
Open
Description
I am using Registry v2.4.1.
When I delete an image, run garbage collection, and try to push the same image, Registry thinks that the layers are already present and doesn't ask the client to upload them again. There are no other images in the registry and the blob directories under /var/lib/registry/... are empty in my test registry. I am guessing that some in-memory blob tracking cache needs to be invalidated after garbage collection.
Delete, GC, and try to push:
# curl -XDELETE http://localhost:5000/v2/test1/manifests/sha256:e74b1feff383713dc90402b092a7db6d7f1039ccbc88565e7ee959afba93066b
# docker exec -ti registry2 /bin/registry garbage-collect /etc/docker/registry/config.yml
INFO[0000] Deleting blob: /docker/registry/v2/blobs/sha256/14/14e6410efe488c623ffd79a858567ae742ab2c4a23b7197fcf4e67d765bac2c6 go.version=go1.6.2 instance.id=b357c178-221b-49a7-8b91-6dc7da415a3d
INFO[0000] Deleting blob: /docker/registry/v2/blobs/sha256/82/82d2c12b1cdaba861e8be79e39cb23eee889d778f88268e62883f19b83039ae4 go.version=go1.6.2 instance.id=b357c178-221b-49a7-8b91-6dc7da415a3d
[...]
# docker push 127.0.0.1:5000/test1:v2
The push refers to a repository [127.0.0.1:5000/test1]
622d280fe41e: Layer already exists
7503f970aad3: Layer already exists
2371c1731b0a: Layer already exists
e5fd538c8c98: Layer already exists
[...]
No blobs are present on disk:
# du -s docker/registry/v2/blobs
4 docker/registry/v2/blobs/sha256/14
4 docker/registry/v2/blobs/sha256/e0
4 docker/registry/v2/blobs/sha256/bc
4 docker/registry/v2/blobs/sha256/22
4 docker/registry/v2/blobs/sha256/e7
4 docker/registry/v2/blobs/sha256/04
4 docker/registry/v2/blobs/sha256/89
[...]
Restart Registry after delete and push again:
# docker restart registry2
registry2
# docker push 127.0.0.1:5000/test1:v2
The push refers to a repository [127.0.0.1:5000/test1]
622d280fe41e: Pushed
56dc8d9cf120: Pushing [> ] 1.641 MB/367 MB
[...]
Reacted by Dennis Tychsen, Wesley Griffing and Michael Kriese
Metadata
Metadata
Assignees
Labels
No labels
Activity
RichardScothern commentedon Jun 27, 2016
Your analysis is correct @mikenel. However, before running a garbage collection, the registry should be in read-only mode (which requires a restart) or not running at all. If this doesn't happen you are at risk of losing data by writing data to the registry while garbage collection is running.
fsword commentedon Dec 10, 2016
@RichardScothern I dont think this is the right way for registry.
Restartis used at console, so its is not a suitable way foradmin. Somebody may think registry should be used as a docker container, butcontainer restartis a operation on devops platform ( eg. mesos/k8s ) , we cannot suppose thatregistry adminis a user of that.So, if we use registry in the right way,
the registryshould be maintained by admin without restart, andadminmake the choise of when to GC.dmcgowan commentedon Dec 20, 2016
Our desire is to have a better garbage collector which does not require a restart. Implementing this is blocked on a few other features, including having metadata stored in a transactional database. Until we get to that point, the registry must be brought up in read-only mode to ensure no writes are happening. We are not opinionated in how to operationalize this restart just noting the risks of having concurrent write operations on the backend and the requirement on read-only mode on the registry process. If you have a method that has worked well for you please share.
fsword commentedon Dec 24, 2016
@dmcgowan Yes, it's also one of the reasons I said that. But I'm not good at golang and not familiar with docker registry......
If you need a PR for this issue, maybe you can pay for it. I can pay 0.1 BTC for it.
stevvooe commentedon Jan 10, 2017
I suspect that this is the same issue as #2094.
dentych commentedon Apr 9, 2019
Any news on this? It is still an issue, and it seems to have died off a little?..
gwaines commentedon Apr 17, 2019
We just tried on current version of docker and still seems to require a registry restart.
jimmytoan commentedon Oct 24, 2020
I found that the last push does not upload layer to registry, because the registry shows
Layer already exists. It caused by the cache (in memory or redis)I'm able to confirm it by 2 different settings of registry on Kubernetes
Case 1: configure registry to use in memory cache (default settings). Re-create registry pod before pushing. It works
Case 2: configure registry to user redis cache. Re-create redis pod before pushing. It works
Note: I still do not figure out how to clear the registry cache right after delete tags and garbage collection
ziXet commentedon Apr 5, 2021
I have the same issue! registry service must be restarted for inmemory cache
deleteriousEffect commentedon Apr 5, 2021
Garbage collection could potentially clear a Redis cache, but I don't see a way to clear an inmemory cache, since garbage collection runs in a separate process, so it wouldn't have access to an inmemory cache of a running registry.
milosgajdos commentedon Apr 21, 2021
Probably related #3322
Registry uses non existant redis cache
chore(docs): update dvcr-cleaner internal doc
chore(docs): update dvcr-cleaner internal doc (#896)
chore(docs): update dvcr-cleaner internal doc (#896)
fix: validate blob cache hits against backend storage
fix: validate blob cache hits against backend storage