snap refresh fails to recover after network disconnection

Bug #1998022 reported by giacof
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

I'm trying to update firefox package on an unstable network which frequently disconnects and then reconnects.

Snap manager is expected to react to network conditions and adapt download speed accordingly.
What happens instead is that as soon as network bandwidth starts to shrink, the download starts to slow down to 0.00 bytes/sec and then hangs.

The download will never recover, even when network connection is established back, so in the end the process will exit with an error code.

Then if I run again the command: snap refresh firefox, the download will restart from zero instead of resuming the failed download!

1) Ubuntu Release: 22.04

2) apt-cache policy snap
snap:
  Installato: (nessuno)
  Candidato: 2013-11-29-11
  Tabella versione:
     2013-11-29-11 500
        500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages

3) What you expected to happen

When the network is back after a disconnection, the download speed should start to raise back to the maximum available bandwidth. Moreover, in case the download fails, when snap refresh is relaunched it should resume the failed download from where it stopped.

4) What happened instead

When snap starts to download the package, it creates the file:

/var/lib/snapd/snaps/firefox_2088.snap.xdelta3-2067-to-2088.partial

where 2067 is the current version and 2088 the newest one.
Then the network connection starts to get unstable and eventually disconnects for a few seconds. The refresh process starts to slow down the download speed accordingly.
When network connection is back, the snap process doesn't seem to realize it and the download speed keeps to fall all the way down to zero.
In the end, the refresh command fails with the following error:

$ snap refresh firefox
errore: cannot perform the following tasks:
- Scarica lo snap "firefox" (2088) dal canale "latest/stable" (download too slow: 0.00 bytes/sec)

Even more severe problem: the firefox_2088.snap.xdelta3-2067-to-2088.partial gets deleted, so the download restarts from the beginning instead of resuming the failed partial download!
That makes update virtually impossible on my network, since each time it will start from the beginning and eventually fail, as soon as the network disconnects.

giacof (giacof)
description: updated
Revision history for this message
Miguel Pires (miguelpires1) wrote :

Hi. Thank you for reporting this bug. I tried to reproduce this, with both of a fresh install and a refresh, and had some mixed results. It seems like snapd will usually resume the download from the point it stopped, if the network is cut. However, I was able to see it going back to the beginning once. It could be that the time limit or the retry limit is reached. This warrants further investigation.
The "download too slow: 0.00 bytes/sec" error message also seems to suggests that in a period of 5 minutes nothing was downloaded. Was the network out for 5 minutes or was it out for just a short period of time and snapd didn't resume for 5 minutes?
Regarding the second problem of partial files being deleted, that is intended because it prevents partial files from taking up disk space, if the download was cancelled, too slow, etc. Interrupted downloads should be resumed in the same operation so this shouldn't be a problem.
Can you paste the output of `snap version` and attach the snapd.log file created by running `journalctl -u snapd > snapd.log` here please?

Thank you,
Miguel

Changed in snapd (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
giacof (giacof) wrote :

Hi, regarding the 5 minutes timeout, I'm pretty sure the connection went back in a few seconds, maybe 10 seconds at most, so that doesn't seem to be the case.
The problem might be that even after reconnecting, the network could remain unstable with a quite narrow bandwidth, possibly falling below 100kb/s for a short time and then increasing again.

snap version
snap 2.57.5+22.04
snapd 2.57.5+22.04
series 16
ubuntu 22.04
kernel 5.15.0-53-generic

Revision history for this message
giacof (giacof) wrote :
Revision history for this message
giacof (giacof) wrote :

I'm trying to update firefox to newest version and still investigating the issue.
I verified the network was always back in a matter of a few seconds, and still snapd was not able to resume until the 5 minutes timeout expired, so the download speed dropped to zero.
It looks like the main problem is snapd isn't able to detect the available network bandwidth in real time and adjust the download speed accordingly.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.