Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry network requests on transient errors #3478

Merged

Conversation

mwleeds
Copy link
Collaborator

@mwleeds mwleeds commented Mar 20, 2020

Like ostreedev/ostree#1594 but for Flatpak.

Instead of defaulting to G_IO_ERROR_FAILED, use more specific codes when
we can. These were copied from libostree.
Currently if flatpak is installing an extra data app such as Spotify and
the server with the .deb file fails to complete the request, the
installation fails with a message like "Connection terminated
unexpectedly". This commit makes flatpak instead try 5 times to download
a given URI if the error returned seems like a transient one (so not,
for example, 404 not found). This is analogous to what was done in
libostree in commit 938055392fd455027a69398c441b992ae521aa87, and we use
some code from there.
@mwleeds
Copy link
Collaborator Author

mwleeds commented Mar 20, 2020

Here's some evidence this works from when I unplugged the network mid-install:

Installing… ████████████████████ 100%  122.6 kB/s  00:00(flatpak install:1159): flatpak-DEBUG: 15:45:45.497: flatpak_http_should_retry_request: error: 706:1 Error resolving “repository.spotify.com”: Temporary failure in name resolution, n_retries_remaining: 4
(flatpak install:1159): flatpak-DEBUG: 15:45:45.497: Should retry request (remaining: 4 retries), due to transient error: Error resolving “repository.spotify.com”: Temporary failure in name resolution
(flatpak install:1159): flatpak-DEBUG: 15:45:45.497: Loading http://repository.spotify.com/pool/non-free/s/spotify-client/spotify-client_1.1.26.501.gbe11e53b-15_amd64.deb using libsoup
(flatpak install:1159): flatpak-DEBUG: 15:45:45.498: flatpak_http_should_retry_request: error: 706:1 Error resolving “repository.spotify.com”: Temporary failure in name resolution, n_retries_remaining: 3
(flatpak install:1159): flatpak-DEBUG: 15:45:45.498: Should retry request (remaining: 3 retries), due to transient error: Error resolving “repository.spotify.com”: Temporary failure in name resolution
(flatpak install:1159): flatpak-DEBUG: 15:45:45.498: Loading http://repository.spotify.com/pool/non-free/s/spotify-client/spotify-client_1.1.26.501.gbe11e53b-15_amd64.deb using libsoup
(flatpak install:1159): flatpak-DEBUG: 15:45:45.499: flatpak_http_should_retry_request: error: 706:1 Error resolving “repository.spotify.com”: Temporary failure in name resolution, n_retries_remaining: 2
(flatpak install:1159): flatpak-DEBUG: 15:45:45.499: Should retry request (remaining: 2 retries), due to transient error: Error resolving “repository.spotify.com”: Temporary failure in name resolution
(flatpak install:1159): flatpak-DEBUG: 15:45:45.499: Loading http://repository.spotify.com/pool/non-free/s/spotify-client/spotify-client_1.1.26.501.gbe11e53b-15_amd64.deb using libsoup
(flatpak install:1159): flatpak-DEBUG: 15:45:45.499: flatpak_http_should_retry_request: error: 706:1 Error resolving “repository.spotify.com”: Temporary failure in name resolution, n_retries_remaining: 1

Though I'm not sure why the progress says 100%. It's possible I misused FlatpakLoadUriProgress in this patch.

@mwleeds
Copy link
Collaborator Author

mwleeds commented Mar 20, 2020

Never mind, the progress bar seems broken for extra data downloads independently of these patches, based on the output of flatpak install --reinstall flathub org.freedesktop.Platform.openh264//19.08 (which goes directly to 100%).

@mwleeds
Copy link
Collaborator Author

mwleeds commented Mar 20, 2020

Even with this patch I sometimes have issues installing Spotify, but it seems like an issue on their side that they keep dropping connections over and over:

        ID                          Branch         Op         Remote          Download
 1. [|] com.spotify.Client          stable         i          flathub         < 131.9 MB

        ID                          Branch         Op         Remote          Download
 1. [—] com.spotify.Client          stable         i          flathub         2.0 MB / 131.9 MB

Installing… ████████████████████ 100%  395.7 kB/s  00:00(flatpak install:5757): flatpak-DEBUG: 16:40:30.407: flatpak_http_should_retry_request: error: 228:34 Connection terminated unexpectedly, n_retries_remainin        ID                          Branch         Op         Remote          Download
 1. [|] com.spotify.Client          stable         i          flathub         2.2 MB / 131.9 MB

Installing… ████████████████████ 100%  216.6 kB/s  00:00(flatpak install:5757): flatpak-DEBUG: 16:40:35.508: flatpak_http_should_retry_request: error: 228:34 Connection terminated unexpectedly, n_retries_remainin        ID                          Branch         Op         Remote          Download
 1. [—] com.spotify.Client          stable         i          flathub         2.0 MB / 131.9 MB

Installing… ████████████████████ 100%  131.9 kB/s  00:00(flatpak install:5757): flatpak-DEBUG: 16:40:40.616: flatpak_http_should_retry_request: error: 228:34 Connection terminated unexpectedly, n_retries_remainin        ID                          Branch         Op         Remote          Download
 1. [|] com.spotify.Client          stable         i          flathub         2.1 MB / 131.9 MB

Installing… ████████████████████ 100%  104.5 kB/s  00:00(flatpak install:5757): flatpak-DEBUG: 16:40:45.731: flatpak_http_should_retry_request: error: 228:34 Connection terminated unexpectedly, n_retries_remainin        ID                          Branch         Op         Remote          Download
 1. [—] com.spotify.Client          stable         i          flathub         2.3 MB / 131.9 MB

Installing… ████████████████████ 100%  91.4 kB/s  00:00(flatpak install:5757): flatpak-DEBUG: 16:40:50.837: flatpak_http_should_retry_request: error: 228:34 Connection terminated unexpectedly, n_retries_remaining        ID                          Branch         Op         Remote          Download
 1. [|] com.spotify.Client          stable         i          flathub         2.2 MB / 131.9 MB
        ID                          Branch         Op         Remote          Download
 1. [✗] com.spotify.Client          stable         i          flathub         2.2 MB / 131.9 MB

Error: While downloading http://repository.spotify.com/pool/non-free/s/spotify-client/spotify-client_1.1.26.501.gbe11e53b-15_amd64.deb: Connection terminated unexpectedly
error: Failed to install com.spotify.Client: While downloading http://repository.spotify.com/pool/non-free/s/spotify-client/spotify-client_1.1.26.501.gbe11e53b-15_amd64.deb: Connection terminated unexpectedly

@alexlarsson alexlarsson merged commit a229948 into flatpak:master Mar 23, 2020
@mwleeds mwleeds deleted the retry-on-transient-errors-upstream branch March 23, 2020 17:12
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.

None yet

2 participants