|
|
Subscribe / Log in / New account

Snap refresh behaviour is really strange.

Snap refresh behaviour is really strange.

Posted Feb 24, 2023 16:09 UTC (Fri) by smcv (subscriber, #53363)
In reply to: Snap refresh behaviour is really strange. by farnz
Parent article: No more Flatpak (by default) in Ubuntu Flavors

Flatpak does work like this, and it's one of the motivations for it using libostree (which sets up hardlink-based immutable directory trees). Once an instance of a Flatpak app is running, its view of the app and runtime files in /app and /usr will never change even if the app or its runtime gets updated, ensuring that the app doesn't get broken by its resource files being swapped out underneath it (unlike system package managers like dpkg or rpm, which would traditionally just go ahead with changing the files in-place and hope the app can cope, but now often encourage doing "offline updates" during a reboot).

If you update a Flatpak app or runtime while the app is *not* running, then the old version will be cleaned up immediately (in the case of a runtime, this only happens if there is no running app that uses that runtime). If an instance of the app is running, it holds a lock which prevents that cleanup, but the "active" version swaps to the new one, so running another instance of the same app in parallel will give the new instance its updated /app and /usr. The old version will eventually be cleaned up, during the next update that takes place after the first instance has exited.

I don't know whether Snap does this. I would hope so, it's certainly in a position to use similar tricks if it wants to?

Of course, for particularly security-sensitive apps like Firefox, there's an incentive for the app to prompt you to exit and restart even if it's somewhat disruptive to do so, to make sure you're really running the updated version with its security fixes: there's a usability/security tradeoff here, and we can't realistically insert code changes into a running process, however important they might be.


to post comments

Snap refresh behaviour is really strange.

Posted Feb 24, 2023 16:15 UTC (Fri) by farnz (subscriber, #17727) [Link]

The reason I said "in theory" is that I've not tested Flatpak's behaviour. Snap currently requires you to close the app to update it - it won't download and install a newer version in parallel to the old version, and thus you have to quit your app, apply the update, and then restart.

I'm glad to hear that Flatpak does the right thing here - as a user, I want to be able to say "sure, get all the updates and install them" while I'm on mains power and reliable fast Internet, but I may not be able to restart the app to get the new version running until I've finished a chunk of work (which I may, in turn, not be able to do until I'm on a coach or train journey). The only thing you've not cleared up for me is whether it's easy, in the Flatpak world, to determine which apps I need to restart to update - it's obviously technically possible based on your description, but whether any of the front ends tell me "hey, you have Firefox 109 running, but the currently active version is 114.3 - restart Firefox to update" is a different question,

Snap refresh behaviour is really strange.

Posted Feb 24, 2023 21:27 UTC (Fri) by himi (subscriber, #340) [Link]

Thanks for the detailed discussion of Flatpak's approach - it's pretty much what I just assumed snap would be doing, because frankly it's how I'd have done it if I was writing a container-based package delivery system . . .

The usability/user-interaction question obviously has no clearly superior answer, and arguably would have different answers for different use cases (server versus desktop, system software versus end user, developer versus regular user, etc), but I think it's pretty hard to argue with implementing support for a "minimum downtime" approach that does as much as possible of the time consuming download and update in the background before requiring the running process to go away. Snap is definitely failing at that right now, for unknown reasons.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds