Infinite busy-loop trying to cull when cache space is short
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cachefilesd (Ubuntu) |
Fix Released
|
Medium
|
Daniel Axtens | ||
Trusty |
Fix Released
|
Medium
|
Daniel Axtens | ||
Xenial |
Fix Released
|
Medium
|
Daniel Axtens |
Bug Description
[Impact]
A user reports that cachefilesd will spin at 100% of a cpu when started on a filesystem where the free space is less than the bcull threshold and culling the cache is insufficient to free up space.
Investigation shows that this is because cachefilesd detects that culling is required, tries to cull, and does not realise that culling cannot free up enough space, so just keeps retrying.
[Test Case]
Create a trusty or xenial VM, and install cachefilesd. Using either a real disk or loopback image, create a ext4 filesystem, and edit fstab to mount it at /var/cache/fscache, e.g.:
$ sudo dd if=/dev/zero of=/cache.img bs=1024m count=1024
$ sudo losetup -f /cache.img
$ sudo losetup -a
$ sudo mkfs.ext4 /dev/loop0 (note, adjust loop0 if needed)
edit fstab e.g.:
$ grep fscache /etc/fstab
/cache.img /var/cache/fscache ext4 defaults,
It's important to include the 'user_xattr' option as cachefilesd requires that.
stop the cachefilesd service and move the fscache contents:
$ sudo service cachefilesd stop
$ cd /var/cache
$ sudo mkdir fscache2
$ sudo mv -vf fscache/* fscache2/
$ sudo mount fscache
$ sudo mv -vf fscache2/* fscache/
$ sudo rmdir fscache2
create a file to fill up the fscache space, e.g.:
$ sudo dd if=/dev/zero of=/var/
$ df /var/cache/fscache
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 999320 922896 7612 100% /var/cache/fscache
edit /etc/default/
$ grep RUN /etc/default/
RUN=yes
reboot, or just restart cachefilesd service
$ sudo service cachefilesd start
check top
$ top
cachefilesd should be spinning, using 100% (or as much as it can) cpu time.
[Regression Potential]
The patch makes changes to how cachefilesd detects if it should sleep
or cull, so regressions would be in the area of cachefilesd spinning
instead of sleeping (which is what it does now) or sleeping instead
of culling.
However the patch is small and easily understood and backports with minimal effort.
[Other Info]
This is fixed upstream in 0.10.6:
* Wed Feb 3 2016 David Howells <email address hidden> 0.10.6-1
...
- Suspend culling when cache space is short and cache objects are pinned.
The particular patch is ce353f5b6b5b ("cachefilesd can spin when disk space is short.")
Since bionic has version 0.10.10-0.1, this fix is needed only for xenial and trusty.
tags: | added: sts sts-sponsor sts-sponsor-ddstreet |
description: | updated |
description: | updated |
Changed in cachefilesd (Ubuntu Trusty): | |
status: | New → In Progress |
Changed in cachefilesd (Ubuntu Xenial): | |
status: | New → In Progress |
Changed in cachefilesd (Ubuntu Trusty): | |
assignee: | nobody → Daniel Axtens (daxtens) |
Changed in cachefilesd (Ubuntu Xenial): | |
assignee: | nobody → Daniel Axtens (daxtens) |
Changed in cachefilesd (Ubuntu Trusty): | |
importance: | Undecided → Medium |
Changed in cachefilesd (Ubuntu Xenial): | |
importance: | Undecided → Medium |
Changed in cachefilesd (Ubuntu): | |
importance: | Undecided → Medium |
status: | Confirmed → Fix Released |
description: | updated |
description: | updated |
tags: |
added: verification-done-xenial removed: verification-needed-xenial |
tags: |
added: verification-done removed: verification-needed |
tags: | removed: sts-sponsor sts-sponsor-ddstreet |
It turns out the package uses the cdbs system rather than quilt, so providing a debdiff is a bit tricky. Here's the patch that I applied, the result is at https:/ /launchpad. net/~daxtens/ +archive/ ubuntu/ builder/ +build/ 16226405 and it works on my test system, and I am asking the original reporter to verify it as well.