Bug 1300878 - [RFE] dnf makecache enabled on readonly-root systems wastes cpu
[RFE] dnf makecache enabled on readonly-root systems wastes cpu
Status: CLOSED EOL
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
23
Unspecified Unspecified
low Severity unspecified
: ---
: ---
Assigned To: rpm-software-management
Fedora Extras Quality Assurance
: FutureFeature, Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-01-21 19:33 EST by Oleg Drokin
Modified: 2016-12-20 13:03 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-12-20 13:03:46 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Bugzilla 1187111 None None None 2016-01-21 19:33 EST

  None (edit)
Description Oleg Drokin 2016-01-21 19:33:37 EST
Description of problem:

It looks like dnf makecache timer that is eanbled by default for some reason cannot understand that it's running on a readonly root system (i.e. nfsroot)
and fires anyway, so 10 minutes after system start we end up with dnf makecache process that hogs 100% of cpu.
32441 ?        RNs   14:24 /usr/bin/python -OO /usr/bin/dnf -v makecache timer

strace shows that it's looping trying to perform:
open("/var/cache/dnf/metadata_lock.pid", O_WRONLY|O_CREAT|O_EXCL, 0644) = -1 EEXIST (File exists)
open("/var/cache/dnf/metadata_lock.pid", O_RDONLY) = -1 ENOENT (No such file or directory)

The file does not exist:
# ls -la /var/cache/dnf/metadata_lock.pid
ls: cannot access /var/cache/dnf/metadata_lock.pid: No such file or directory

The /var/cache/dnf is not one of the default targets to be mounted in tmpfs (and for a good reason).

I see that the timer in question already contains a condition against running when started from livecd image:
ConditionKernelCommandLine=!rd.live.image

Now, if this could be replaced with a check of /etc/sysconfig/readonly-root and not run when READONLY is set to yes - that would be a lot more proper solution.
Or at least a check that /var/cache/dnf is actually writeable.

Version-Release number of selected component (if applicable):
present in all version of dnf starting from FC21

How reproducible:

100% reproducible

Steps to Reproduce:
If you are not up to the task of doing nfs readonly-root install or the like, you can simulate it by:

1. mount none /var/cache/dnf -t tmpfs
2. mount / /media --bind
3. cp -a /media/var/cache/dnf/* /var/cache/dnf/
4. umount /media

5. strace dnf makecache

Note it's important to do the copying of a real existing dnf cache as otherwise it's smart enough to fail seeing as it cannot create it if the /var/cache/dnf is empty (which it is not on a real readonly nfsroot install)

Actual results:

dnf enters infinite loop hogging 100% of one cpu.


Expected results:

should notice that it cannot do anything.
Even better if dnf makecache was not run by default in such a case.

Additional info:
This all got introduced with the mandatory on-by-default dnf makecache timer as part of dnf package, that sparked quite a heated discussion in bug 1187111.
Comment 1 Oleg Drokin 2016-01-21 19:38:51 EST
There's one more step in the reproducer, btw, that I forgot to include:

3.5 mount /var/cache/dnf -o remount,ro

Otherwise the /var/cache/dnf is not readonly and you won't see the problem.
Comment 2 Honza Silhan 2016-01-25 08:11:33 EST
we can add the readonly checker everytime we load cache directory.
Comment 3 Fedora Admin XMLRPC Client 2016-07-08 05:36:03 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 4 Fedora End Of Life 2016-11-24 10:06:12 EST
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 5 Fedora End Of Life 2016-12-20 13:03:46 EST
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.