Bug 517286

Summary: Yum crashes if download of a package is too quick
Product: Red Hat Enterprise Linux 5 Reporter: Thomas Bellman <bellman>
Component: yumAssignee: James Antill <james.antill>
Status: CLOSED ERRATA QA Contact: Jan Hutaƙ <jhutar>
Severity: high Docs Contact:
Priority: high    
Version: 5.3CC: ddumas, jhutar, psklenar, rssjames, tao, vgaikwad
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Fixed In Version: yum-3.2.22-23.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-03-30 04:29:37 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Description Flags
Ugly patch fixing the crash none

Description Thomas Bellman 2009-08-13 07:41:07 EDT
When running 'yum update', Yum can crash with a ZeroDivisionError:

    Downloading Packages:
    Traceback (most recent call last):
      File "/usr/bin/yum", line 29, in ?
	yummain.user_main(sys.argv[1:], exit_code=True)
      File "/usr/share/yum-cli/yummain.py", line 229, in user_main
	errcode = main(args)
      File "/usr/share/yum-cli/yummain.py", line 181, in main
	return_code = base.doTransaction()
      File "/usr/share/yum-cli/cli.py", line 386, in doTransaction
	problems = self.downloadPkgs(downloadpkgs, callback_total=self.download_callback_total_cb) 
      File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 1162, in downloadPkgs
	callback_total(remote_pkgs, remote_size, beg_download)
      File "/usr/share/yum-cli/output.py", line 949, in download_callback_total_cb
	ui_bs   = tl.add(' %5sB/s' % self.format_number(remote_size / dl_time))
    ZeroDivisionError: float division

This happens when the download of the package is too fast.  We
have a repository on NFS, which can make the download of small
RPMs quick enough that the two calls to time.time() return the
same value.  I presume this can happen for other Yum operations
downloading packages as well, but I haven't verified that.

Reproducability is low.  It only happens occasionally for us, and
I think I have only seen this on Xen guests; the time reported by
time.time() seems to increment more seldom (but in larger steps)
on some, but not all, of those.

Yum version is yum-3.2.19-18.el5.centos

The system where I see this is actually running CentOS 5.3, but
I have looked at a real RHEL 5 system as well, and in Fedora 11
(yum-3.2.23-3.fc11), and the relevant code in yum-cli/output.py
looks identical.
Comment 1 Thomas Bellman 2009-08-13 07:53:04 EDT
Created attachment 357306 [details]
Ugly patch fixing the crash

I believe the attached patch solves the problem, although I haven't
actually managed to test it, since the problem is very intermittent.

My choice of speed to report when yum were to divide by zero is 
debatable.  I first tried using +Inf, but that will just cause
format_number() to hang in an infinite loop...  A perhaps better
choice would be to set dl_speed to None, and update format_number()
to show that as "N/A" or something like that.
Comment 2 Rob James 2009-08-13 12:54:22 EDT
We are seeing this issue too on RHEL 5.3 on Xen guests. Even if it doesn't crash, the speed calculation ends up just being wrong because of the low resolution of the clock.
Comment 5 Fedora Update System 2009-09-29 21:39:00 EDT
yum-3.2.24-2.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 6 Fedora Update System 2009-10-19 12:45:34 EDT
yum-3.2.24-2.fc10 has been submitted as an update for Fedora 10.
Comment 7 Fedora Update System 2009-11-04 07:06:18 EST
yum-3.2.24-2.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 15 errata-xmlrpc 2010-03-30 04:29:37 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.