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

[Bug]: /var/tmp/flatpak-cache-* directories are not garbage collected by systemd, because they are constantly touched by flatpak #5380

Open
4 tasks done
gentoo-root opened this issue Apr 6, 2023 · 2 comments
Labels

Comments

@gentoo-root
Copy link

gentoo-root commented Apr 6, 2023

Checklist

  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.
  • If this is an issue with a particular app, I have tried filing it in the appropriate issue tracker for the app (e.g. under https://github.com/flathub/) and determined that it is an issue with Flatpak itself.
  • This issue is not a report of a security vulnerability (see here if you need to report a security issue).

Flatpak version

1.15.4

What Linux distribution are you using?

Arch Linux

Linux distribution version

rolling

What architecture are you using?

x86_64

How to reproduce

  1. Use flatpak for more than 30 days.
  2. Observe /var/tmp/flatpak-cache-* directories not being cleaned up by the systemd-tmpfiles rule, even though most of them are empty.

Expected Behavior

I expect that /var/tmp/flatpak-cache-* directories do not accumulate indefinitely and are garbage collected eventually.

Actual Behavior

I have a few dozens of stale and empty /var/tmp/flatpak-cache-* directories that are no longer used, but are not garbage collected:

...
drwxr-xr-x 1 max   max        0 Sep 10  2022 flatpak-cache-RTU1R1
drwxr-xr-x 1 max   max        0 Feb  9 12:02 flatpak-cache-SQN5Z1
drwxr-xr-x 1 max   max        0 Nov 26 17:58 flatpak-cache-T5YIT1
...

Additional Information

Running SYSTEMD_LOG_LEVEL=7 systemd-tmpfiles --clean revealed the reason why these unused directories don't get garbage collected: it's because the access time (atime) of each directory is updated regularly, supposedly, by flatpak itself:

...
Directory "/var/tmp/flatpak-cache-RTU1R1": access time Thu 2023-04-06 01:16:53.247647 EEST is too new.
Directory "/var/tmp/flatpak-cache-977DS1": access time Thu 2023-04-06 01:16:53.247647 EEST is too new.
Directory "/var/tmp/flatpak-cache-OYDWR1": access time Thu 2023-04-06 01:16:53.247647 EEST is too new.
...

The atimes of all flatpak-cache directories are within one second, so I suppose flatpak goes over all of them, updating atimes, when it performs some action.

Possible ways to solve it:

  1. Flatpak could stop iterating and bumping atimes of flatpak-cache directories that are no longer in use. This way, systemd-tmpfiles could garbage collect them.
  2. Alternatively, if the previous way is not possible for some reason, flatpak could ship with a tmpfiles config that tells systemd to ignore atimes on flatpak-cache directories, something like this, not tested yet:
e /var/tmp/flatpak-cache-* - - - 30d:abcmBM
@gentoo-root gentoo-root added the bug label Apr 6, 2023
@matejak
Copy link

matejak commented Apr 25, 2023

Could this be related to #1119? Interestingly, problems with the cache seem to be correlated with the Arch Linux distribution. Interestingly, e.g. Fedora doesn't seem to do any tmp-related magic when creating the package - see https://src.fedoraproject.org/rpms/flatpak/blob/f38/f/flatpak.spec

@fewaltix
Copy link

@matejak: I can confirm that the same problem plagues OpenSuse as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants