Comment 0 for bug 2033268

Revision history for this message
Michael Vogt (mvo) wrote :

It looks like snapd is leaking snaps when refresh-app-awareness is in use. This got reported in the forum in https://forum.snapcraft.io/t/snaps-autoclean-disable-cache-seeds-for-juju-ci-cd/36363 and indeed on my systems:

```
$ ls /var/lib/snapd/snaps/firefox*
/var/lib/snapd/snaps/firefox_2387.snap /var/lib/snapd/snaps/firefox_2531.snap
/var/lib/snapd/snaps/firefox_2391.snap /var/lib/snapd/snaps/firefox_2559.snap
/var/lib/snapd/snaps/firefox_2393.snap /var/lib/snapd/snaps/firefox_2937.snap
/var/lib/snapd/snaps/firefox_2417.snap
```

I looked at the code and it seems the issue is the following:

1. When the refresh starts the soft check that firefox is running reports it is not (this can happen e.g. on startup of the computer when snapd checks for auto-refreshes and the user has not clicked on "firefox" yet)
2. user clicks on firefox, it is now running while the snap is downloading
3. the code path in handlers.go:doPreDownloadSnap() or handlers.go:doUnlinkCurrentSnap() are hit, here firefox is now busy and asyncRefreshOnSnapClose() is called
4. however if firefox is not closed and asyncRefreshOnSnapClose() / continueRefreshOnSnapClose() is aborted it seems no cleanup of the download is happening