Infinite busy-loop trying to cull when cache space is short

Bug #1810372 reported by Daniel Axtens
12
This bug affects 1 person
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,loop,user_xattr 0 0

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/cache/fscache/largefile.txt bs=1024k count=850
$ df /var/cache/fscache
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 999320 922896 7612 100% /var/cache/fscache

edit /etc/default/cachefilesd to uncomment 'RUN=yes', e.g.:
$ grep RUN /etc/default/cachefilesd
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.

Revision history for this message
Daniel Axtens (daxtens) wrote :

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.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "0001-cachefilesd-can-spin-when-disk-space-is-short.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Daniel Axtens (daxtens) wrote :

The full .diff.tar.gz is attached.

Dan Streetman (ddstreet)
tags: added: sts sts-sponsor sts-sponsor-ddstreet
Dan Streetman (ddstreet)
description: updated
description: updated
Dan Streetman (ddstreet)
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
Dan Streetman (ddstreet)
description: updated
Revision history for this message
Dan Streetman (ddstreet) wrote :
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Daniel, or anyone else affected,

Accepted cachefilesd into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cachefilesd/0.10.5-1ubuntu0.16.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in cachefilesd (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-xenial
Changed in cachefilesd (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: added: verification-needed-trusty
Revision history for this message
Brian Murray (brian-murray) wrote :

Hello Daniel, or anyone else affected,

Accepted cachefilesd into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cachefilesd/0.10.5-1ubuntu0.14.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-trusty to verification-done-trusty. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-trusty. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Daniel Axtens (daxtens)
tags: added: verification-done-xenial
removed: verification-needed-xenial
Revision history for this message
Daniel Axtens (daxtens) wrote :

User has verified the Xenial version. I have verified the Trusty version.

Regards,
Daniel

tags: added: verification-done-trusty
removed: verification-needed-trusty
Dan Streetman (ddstreet)
tags: added: verification-done
removed: verification-needed
tags: removed: sts-sponsor sts-sponsor-ddstreet
Revision history for this message
Eric Desrochers (slashd) wrote :

Hi Daniel,

As discussed on irc, can you be a little bit more specific about the test you did for both releases (X/T), the package version used, the outcome, ... I'm sure you did the necessary testing but the SRU team will definitely appreciate hearing about it in order to have more information to take the right decision when they will be ready to release the package into -updates.

Thanks in advance !

Revision history for this message
Daniel Axtens (daxtens) wrote :

Hi,

Thanks Eric.

I specifically tested the version from Trusty: 0.10.5-1ubuntu0.14.04.1.

I tested it by enabling cachefilesd and using dd to get the disk to about 95% full.

With 0.10.5-1, starting cachefilesd with a full disk caused the process to spin at 100% cpu usage. With the version from proposed, CPU usage was down to normal negligible levels.

The other user did a similar test with the Xenial version 0.10.5-1ubuntu0.16.04.1 and had similar results: the version in -proposed does not max out a CPU core when the disk is full.

Regards,
Daniel

Revision history for this message
Robie Basak (racb) wrote : Update Released

The verification of the Stable Release Update for cachefilesd has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cachefilesd - 0.10.5-1ubuntu0.14.04.1

---------------
cachefilesd (0.10.5-1ubuntu0.14.04.1) trusty; urgency=medium

  [ Daniel Axtens ]
  * cachefilesd can spin when disk space is short (LP: #1810372)

 -- Dan Streetman <email address hidden> Fri, 11 Jan 2019 09:21:15 -0500

Changed in cachefilesd (Ubuntu Trusty):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cachefilesd - 0.10.5-1ubuntu0.16.04.1

---------------
cachefilesd (0.10.5-1ubuntu0.16.04.1) xenial; urgency=medium

  [ Daniel Axtens ]
  * cachefilesd can spin when disk space is short (LP: #1810372)

 -- Dan Streetman <email address hidden> Fri, 11 Jan 2019 09:22:23 -0500

Changed in cachefilesd (Ubuntu Xenial):
status: Fix Committed → Fix Released
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.