Skip to content

registry/storage/swift: detect and fix outdated container listings - #1605

Merged
RichardScothern merged 1 commit into
distribution:masterfrom
majewsky:swift/deal-with-outdated-container-listings
Apr 8, 2016
Merged

RichardScothern merged 1 commit into
distribution:masterfrom
majewsky:swift/deal-with-outdated-container-listings

Conversation

@majewsky

@majewsky majewsky commented Apr 6, 2016

Copy link
Copy Markdown
Contributor

After #1578, this is the second product of my investigations on errors with my team's internal Registry. Similar errors are tracked here as #1013 and #1539 aka moby/moby#21290.

During load tests, I especially saw the same error ("digest invalid: provided digest did not match uploaded content") as @tdooner in #1013:

time="2016-03-29T13:06:13.84409888Z" level=error msg="response completed with error" err.code="digest invalid" err.detail="invalid digest for referenced layer: sha256:61cdfc955489883180ac1bf6f96a8f8d4bfbacafdde22da069c40084cabe7d95, content does not match digest" err.message="provided digest did not match uploaded content" go.version=go1.5.3 http.request.host="registry.local:31201" http.request.id=9bb40523-dbee-4cb2-90a4-ec58ec3fdecc http.request.method=PUT http.request.remoteaddr="1.2.3.4:58278" http.request.uri="/v2/swift-stresstest/ohdiexoe/blobs/uploads/2aea9892-af83-4f3c-b7ec-0ba138e644b1?_state=9xm52oUBAYl08BzwPgk-7NAhaohqY2xAFPMnehSiFhl7Ik5hbWUiOiJzd2lmdC1zdHJlc3N0ZXN0L29oZGlleG9lIiwiVVVJRCI6IjJhZWE5ODkyLWFmODMtNGYzYy1iN2VjLTBiYTEzOGU2NDRiMSIsIk9mZnNldCI6MTA0OTEzOTIsIlN0YXJ0ZWRBdCI6IjIwMTYtMDMtMjlUMTM6MDY6MDdaIn0%3D&digest=sha256%3A61cdfc955489883180ac1bf6f96a8f8d4bfbacafdde22da069c40084cabe7d95" http.request.useragent="docker/1.8.2-el7 go/go1.4.2 kernel/3.10.0-229.1.2.el7.x86_64 os/linux arch/amd64" http.response.contenttype="application/json; charset=utf-8" http.response.duration=1.446487756s http.response.status=400 http.response.written=204 instance.id=b5ecfb7a-8463-4000-bdab-42d1b093ba6b vars.name="swift-stresstest/ohdiexoe" vars.uuid=2aea9892-af83-4f3c-b7ec-0ba138e644b1 version=v2.3.0 

After updating our test registry from v2.3.0 to a recent master (especially containing my previous fix #1578), these errors turned into "blob upload invalid" with an additional message "upload resumed at wrong offset":

time="2016-03-31T14:28:33Z" level=info msg="upload resumed at wrong offest: 0 != 10491392" go.version=go1.6 http.request.host="registry.local:5000" http.request.id=7ff62dbd-d372-473c-a828-52bc80304b1d http.request.method=PUT http.request.remoteaddr="1.2.3.4:58336" http.request.uri="/v2/swift-stresstest/raetiedu/blobs/uploads/71aab316-549a-4fb3-9d5c-e3b5a497bd6e?_state=TAMv1K9NA61xVYHVWEdnTDdKs6Aa03W-IN927hDFDWh7Ik5hbWUiOiJzd2lmdC1zdHJlc3N0ZXN0L3JhZXRpZWR1IiwiVVVJRCI6IjcxYWFiMzE2LTU0OWEtNGZiMy05ZDVjLWUzYjVhNDk3YmQ2ZSIsIk9mZnNldCI6MTA0OTEzOTIsIlN0YXJ0ZWRBdCI6IjIwMTYtMDMtMzFUMTQ6Mjg6MjJaIn0%3D&digest=sha256%3A69516bda0ffa79679670b4448431dc850f7501e87a4c7bc846bcd424c269c5ba" http.request.useragent="docker/1.8.2-el7 go/go1.4.2 kernel/3.10.0-229.1.2.el7.x86_64 os/linux arch/amd64" instance.id=34d593ae-a0c5-4953-8844-6e7b3ce8ac87 vars.name="swift-stresstest/raetiedu" vars.uuid=71aab316-549a-4fb3-9d5c-e3b5a497bd6e version="v2.4.0+unknown" 
time="2016-03-31T14:28:33Z" level=error msg="response completed with error" err.code="blob upload invalid" err.message="blob upload invalid" go.version=go1.6 http.request.host="registry.local:5000" http.request.id=7ff62dbd-d372-473c-a828-52bc80304b1d http.request.method=PUT http.request.remoteaddr="1.2.3.4:58336" http.request.uri="/v2/swift-stresstest/raetiedu/blobs/uploads/71aab316-549a-4fb3-9d5c-e3b5a497bd6e?_state=TAMv1K9NA61xVYHVWEdnTDdKs6Aa03W-IN927hDFDWh7Ik5hbWUiOiJzd2lmdC1zdHJlc3N0ZXN0L3JhZXRpZWR1IiwiVVVJRCI6IjcxYWFiMzE2LTU0OWEtNGZiMy05ZDVjLWUzYjVhNDk3YmQ2ZSIsIk9mZnNldCI6MTA0OTEzOTIsIlN0YXJ0ZWRBdCI6IjIwMTYtMDMtMzFUMTQ6Mjg6MjJaIn0%3D&digest=sha256%3A69516bda0ffa79679670b4448431dc850f7501e87a4c7bc846bcd424c269c5ba" http.request.useragent="docker/1.8.2-el7 go/go1.4.2 kernel/3.10.0-229.1.2.el7.x86_64 os/linux arch/amd64" http.response.contenttype="application/json; charset=utf-8" http.response.duration=803.126043ms http.response.status=404 http.response.written=76 instance.id=34d593ae-a0c5-4953-8844-6e7b3ce8ac87 vars.name="swift-stresstest/raetiedu" vars.uuid=71aab316-549a-4fb3-9d5c-e3b5a497bd6e version="v2.4.0+unknown" 

I put the registry behind a mitmproxy and inspected the sequence of API calls to Swift that led to this error. The problem was an outdated container listing: Whenever a single layer segment is uploaded during a docker push, the blob writer is resumed by enumerating all the segments that have already been written (using a container listing). When the container listing is not up-to-date (which sometimes happens when Swift is under high load or when single storage nodes become temporarily unresponsive), too few segments are seen and the blob writer is resumed at the wrong offset.

I extended getAllSegments to recognize incomplete container listings, with the usual cost of only one additional HEAD call (which is usually very fast). I also applied a similar treatment to Stat for good measure.

To verify my changes, I re-ran my Registry load test (consisting of 10 workers each doing docker push && docker pull with randomly generated images) and did not see a single worker fail for over an hour whereas I would usually see around 4-6 failures within an hour. I also saw several debug messages (not included in this patch) indicating that the new code paths were indeed taken.

/cc @lebauce

The fineprint: Please do not consider #1013 and/or #1539 fixed by this. I'm fixing some eventual-consistency-related problems with the Swift driver (esp. those which I could reliably reproduce in a testing environment), not all of them.

@codecov-io

Copy link
Copy Markdown

Current coverage is 51.23%

Merging #1605 into master will decrease coverage by -6.62% as of 67321cb

@@            master   #1605   diff @@
======================================
  Files          122     122       
  Stmts        10663   10678    +15
  Branches       841     747    -94
  Methods          0       0       
======================================
- Hit           6169    5471   -698
+ Partial        841     747    -94
- Missed        3653    4460   +807

Review entire Coverage Diff as of 67321cb


Uncovered Suggestions

  1. +0.30% via .../driver/s3-aws/s3.go#730...761
  2. +0.28% via .../driver/s3-aws/s3.go#266...295
  3. +0.22% via .../driver/s3-aws/s3.go#882...904
  4. See 7 more...

Powered by Codecov. Updated on successful CI builds.

@RichardScothern

Copy link
Copy Markdown

good work @majewsky

LGTM

@RichardScothern
RichardScothern merged commit 437eeed into distribution:master Apr 8, 2016
@majewsky
majewsky deleted the swift/deal-with-outdated-container-listings branch April 18, 2016 07:48
cezarsa added a commit to cezarsa/swift that referenced this pull request Aug 19, 2016


The logic for getting all segments for DLO and SLO was separated to
improve legibility.
A test was added to simulate a swift server where listing segments
always return empty.
@cezarsa cezarsa mentioned this pull request Aug 24, 2016
3 tasks done
@majewsky majewsky mentioned this pull request Nov 6, 2017
6 of 7 tasks
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Apr 22, 2021
…tdated-container-listings

registry/storage/swift: detect and fix outdated container listings
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Jan 19, 2022
…tdated-container-listings

registry/storage/swift: detect and fix outdated container listings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants