Bug 1307098 - yum downloadonly does not reliably remove lock files
yum downloadonly does not reliably remove lock files
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: yum (Show other bugs)
Unspecified Unspecified
urgent Severity urgent
: rc
: 6.8
Assigned To: Valentina Mukhamedzhanova
Eva Mrakova
: Patch, ZStream
Depends On:
Blocks: 1269194 1277547 1337912
  Show dependency treegraph
Reported: 2016-02-12 12:16 EST by Andy Grimm
Modified: 2017-03-21 07:00 EDT (History)
6 users (show)

See Also:
Fixed In Version: yum-3.2.29-74.el6
Doc Type: Bug Fix
Doc Text:
Previously, a /var/run/yum.pid file was left on the disk after running the "yum --downloadonly" command. Consequently, under certain circumstances, the "yum" command failed because the yum utility incorrectly assumed that another instance of "yum" was already running. With this update, /var/run/yum.pid is correctly removed after running "yum --downloadonly", and the described problem no longer occurs.
Story Points: ---
Clone Of:
: 1337912 (view as bug list)
Last Closed: 2017-03-21 07:00:55 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Andy Grimm 2016-02-12 12:16:17 EST
Description of problem:
When "/usr/bin/yum -y --downloadonly update" is called, and there are packages to download, the process almost always leaves behind /var/run/yum.pid and rpmdb lockfiles.

The reason for this appears to be that yum calls sys.exit in this scenario, and sys.exit does not reliably trigger the __del__ method for the YumBase object, which is where all the unlocking/cleanup happen.

Relevant code from upstream, where this problem likely still exists:

sys,exit happens here:

__del__ method is here:

Version-Release number of selected component (if applicable):

How reproducible:
Almost always

Steps to Reproduce:
1.  Log into a system for which there will be updates to download
2.  /usr/bin/yum -y --downloadonly update
3.  ls /var/run/yum.pid /var/lib/rpm/__*

Actual results:
yum.pid and rpmdb lockfiles are present

Expected results:
lock files should be removed prior to the yum process exiting.
Comment 2 Andy Grimm 2016-02-15 17:01:55 EST
One update on this:  I realized that I may be wrong about the current function/purpose of the /var/lib/rpm/__db* files.  I was under the impression that those were lock files that would block subsequent transactions, but that does not seem to be the case in further tests.  Also, it seems that while calling self.closeRpmDB() does close those filehandles, it doesn't actually remove the files.  

Adding self.doUnlock() prior to the sys.exit definitely works to remove the PID file, though.
Comment 3 Andy Grimm 2016-02-16 16:12:16 EST
It looks like upstream code closes these database well before the exit.  It appears to have been added in this commit:

Comment 14 errata-xmlrpc 2017-03-21 07:00:55 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


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