more reliable retries and fallback mirror usage - #1336#1339
more reliable retries and fallback mirror usage - #1336#1339wilzbach merged 14 commits intodlang:stablefrom
Conversation
|
Thanks for your pull request, @wilzbach! |
|
On Travis two jobs even failed with this: https://travis-ci.org/dlang/dub/jobs/328895076 So apparently this doesn't fix the issue :/ |
82a6262 to
ad7d85b
Compare
| logDiagnostic("Placing to %s...", placement.toNativeString()); | ||
| return m_packageManager.storeFetchedPackage(path, pinfo, dstpath); | ||
| } catch (ZipException e) { | ||
| logInfo("Failed to extract zip archive for %s %s...", packageId, ver); |
There was a problem hiding this comment.
This isn't the best behavior as the PackageManager fallbacks will never be tried if the main registry returns invalid zips. However, this would require refactoring their interface a bit and I wasn't sure whether this is wanted. In any case, this should already be an measureable improvement (see the test) as it will restart the download when the registry / GH returned invalid data.
There was a problem hiding this comment.
Packages are downloaded directly from GH though, at least that should be the case.
https://github.com/dlang/dub-registry/blob/fe18df23b32f602a7579816a801a8a4e98346b5c/source/dubregistry/web.d#L177-L187
5f4acff to
8495788
Compare
|
This is finally passing on the CIs. It was a bit tricky to add a test for |
|
This seems to work very much on the symptom side of things. Why do we end up silently with corrupted zip packages in the first place? Maybe sth. wrong with |
Well, the errors are pretty random and spurious, so it looks like the network stream gets interrupted.
If I would know, I wouldn't have proposed this workaround for now. |
66f13be to
6366760
Compare
|
I'd suggest to checksum the packages, but GH apparently rebuild those archives from time to time. If it's simply an interrupted transfer, then it should be feasible to reproduce this in a test case, e.g. through a proxy.
Not until vibe-core is stable enough to replace the libevent dependency. I've checked std.net.curl.download and couldn't see anything wrong, it's just a thin wrapper around curl_easy_perform. |
Because that retries downloads, i.e. |
I already added a simple test registry based on Vibe.d in this PR that either serves a valid or invalid zip. We can probably also test interrupted downloads with this, but I'm not sure what's the best way to simulate this. Should we implement our own file serving (for a specific version) and sleep for |
|
BTW, we should finish support for dub/source/dub/packagesupplier.d Line 89 in 785a0b2 |
|
Here we go, router.get("/packages/gitcompatibledubpackage/1.0.2.zip", (req, res) @trusted {
res.writeBody("", HTTPStatus.internalServerError);
});$ curl localhost:1234/packages/gitcompatibledubpackage/1.0.2.zip
$ curl -fsSL localhost:1234/packages/gitcompatibledubpackage/1.0.2.zip
curl: (22) The requested URL returned error: 500 Internal Server ErrorOK, curl only fails with $ ./bin/dub fetch gitcompatibledubpackage --version=1.0.2 --skip-registry=all --registry=http://localhost:1234/ --vverbose
Refreshing local packages (refresh existing: true)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/dawg/.dub/packages/local-packages.json
Try to load local package map at /home/dawg/.dub/packages/local-packages.json
iterating dir /home/dawg/.dub/packages/
...
Determined package version using GIT: dub 1.7.1-beta.1+commit.34.gcdf18e3
Downloading metadata for gitcompatibledubpackage
Getting from http://localhost:1234/packages/gitcompatibledubpackage.json
Getting http://localhost:1234/packages/gitcompatibledubpackage.json...
Fetching gitcompatibledubpackage 1.0.2...
Acquiring package zip file
Downloading from 'http://localhost:1234/packages/gitcompatibledubpackage/1.0.2.zip'
Storing http://localhost:1234/packages/gitcompatibledubpackage/1.0.2.zip...
Placing to /home/dawg/.dub/packages/...
Placing package 'gitcompatibledubpackage' version '1.0.2' to location '/home/dawg/.dub/packages/gitcompatibledubpackage-1.0.2/gitcompatibledubpackage' from file '/tmp/gitcompatibledubpackage-0c8f66bd-cd98-4a84-819c-f9f06cc8180b.zip'
Opening file /tmp/gitcompatibledubpackage-0c8f66bd-cd98-4a84-819c-f9f06cc8180b.zip
rawRead must take a non-empty buffer
Full exception: object.Exception@/usr/include/dmd/phobos/std/stdio.d(972): rawRead must take a non-empty buffer
----------------
/usr/include/dmd/phobos/std/stdio.d:972 @safe ubyte[] std.stdio.File.rawRead!(ubyte).rawRead(ubyte[]) [0x8851dc]
source/dub/internal/vibecompat/core/file.d:46 @trusted void dub.internal.vibecompat.core.file.RangeFile.rawRead(ubyte[]) [0x86fa7c]
source/dub/internal/vibecompat/core/file.d:42 @safe ubyte[] dub.internal.vibecompat.core.file.RangeFile.readAll() [0x86fa32]
source/dub/packagemanager.d:360 dub.package_.Package dub.packagemanager.PackageManager.storeFetchedPackage(dub.internal.vibecompat.inet.path.NativePath, dub.internal.vibecompat.data.json.Json, dub.internal.vibecompat.inet.path.NativePath) [0x7513ff]This should have failed in std.net.curl.download, but instead fails during unpacking. Almost as if we're missing a |
|
Think I found the culprits (yes multiple ones as always). 18318 – std.net.curl.download silently ignores non-2xx http statuses Also since #1104 we're only catching HTTPStatusErrors, but we also need to catch CurlErrors for things like timeouts, ssl, etc. pp. |
- require arguments for test_registry - check removal of broken package
- silent http status errors (e.g. 502) should be responsible for most "corrupted" zip packages
Awesome! Travis failed because you forgot to commit the 1.0.2 symlink - I added that one.
Agreed, there are lots of other things we could do as well:
Though of all these will require quite some effort. |
| fi | ||
|
|
||
| echo "HTTP status errors on downloads should be retried - gitcompatibledubpackage (1.0.2)" | ||
| retryOut=$(! timeout 1s "$DUB" fetch gitcompatibledubpackage --version=1.0.2 --skip-registry=all --registry=http://localhost:$PORT --vverbose 2>&1) |
There was a problem hiding this comment.
The Travis log shows an error and retryCount of 1 - despite the log clearly showing "Bad Gateway" three times:
Downloading metadata for gitcompatibledubpackage
Getting from http://localhost:4934/packages/gitcompatibledubpackage.json
Getting http://localhost:4934/packages/gitcompatibledubpackage.json...
Fetching gitcompatibledubpackage 1.0.2...
Acquiring package zip file
Downloading from 'http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip'
Storing http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip...
Download http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip 502 Bad Gateway (1.1)
Failed to download package gitcompatibledubpackage from http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip (Attempt 1 of 3)
Storing http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip...
Download http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip 502 Bad Gateway (1.1)
Failed to download package gitcompatibledubpackage from http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip (Attempt 2 of 3)
Storing http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip...
Download http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip 502 Bad Gateway (1.1)
Failed to download package gitcompatibledubpackage from http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip (Attempt 3 of 3)
Failed to download package gitcompatibledubpackage from http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip
Full exception: object.Exception@source/dub/packagesupplier.d(208): Failed to download package gitcompatibledubpackage from http://localhost:4934/packages/gitcompatibledubpackage/1.0.2.zip
----------------
source/dub/packagesupplier.d:208 void dub.packagesupplier.RegistryPackageSupplier.fetchPackage(dub.internal.vibecompat.inet.path.NativePath, immutable(char)[], dub.dependency.Dependency, bool) [0x762422]
source/dub/dub.d:766 dub.package_.Package dub.dub.Dub.fetch(immutable(char)[], const(dub.dependency.Dependency), dub.project.PlacementLocation, dub.dub.FetchOptions, immutable(char)[]) [0x74bafa]
source/dub/commandline.d:1235 int dub.commandline.FetchCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x70c427]
source/dub/commandline.d:252 int dub.commandline.runDubCommandLine(immutable(char)[][]) [0x704e8a]
source/app.d:14 _Dmain [0x6fc025]
========== -Output was ==========
[ERROR] :DUB should have retried download on server error multiple times, but only tried 1 times. command failed
testregistry --- Opening file /tmp/gitcompatibledubpackage-cb607641-d990-4f5c-a426-0e158a14689e.zip rawRead must take a non-empty buffer Full exception: object.Exception@/home/travis/dlang/dmd-2.075.1/linux/bin64/../../src/phobos/std/stdio.d(902): rawRead must take a non-empty buffer ---------------- /home/travis/dlang/dmd-2.075.1/linux/bin64/../../src/phobos/std/stdio.d:902 @safe ubyte[] std.stdio.File.rawRead!(ubyte).rawRead(ubyte[]) [0xa16c4b] source/dub/internal/vibecompat/core/file.d:46 @trusted void dub.internal.vibecompat.core.file.RangeFile.rawRead(ubyte[]) [0xa01908] source/dub/internal/vibecompat/core/file.d:42 @safe ubyte[] dub.internal.vibecompat.core.file.RangeFile.readAll() [0xa01882] source/dub/packagemanager.d:360 dub.package_.Package ---
82a7e53 to
a885e97
Compare
- stdx-allocator requires std.typecons.Ternary
|
Thx for fixing this up :). |
|
I am getting the following with 1.7.2. It used to work with 1.7.1 and missed the beta release of 1.7.2. Fetching gitcompatibledubpackage 1.0.4... |
|
How do you run the testsuite? |
|
It's running as part of the package building process for NixOS. |
Yes, looks like that's not the case for you. |
|
I patched it and now getting: |
|
Do you expose some limitations that prevent vibe.d from starting? E.g. no network access to fetch the binary? Could you post the full log? |
|
It was my mistake, it works now. |
See #1336
I'm wondering why 435fd1c#diff-ce350ca917a3ebde71db3a122988b8ba didn't help (it's part of 2.077).