ZeroDivisionError in obj/auditor.py while running unit tests

Bug #941731 reported by Doug Weimer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Undecided
Doug Weimer

Bug Description

I occasionally hit a ZeroDivisionError when running unit tests on obj/auditor.py. The audit_all_objects method runs 'elapsed = time.time() - begin' and then divides by 'elapsed' for logging information. On very fast runs, it's possible for time.time() - begin to be 0. I don't actually think this would show up in a running instance, unit test runs on my VM just seem to run into it every now and then. Relevant code block from obj/auditor.py (begin = time.time() is set earlier in the method):

        elapsed = time.time() - begin
        self.logger.info(_(
            'Object audit (%(type)s) "%(mode)s" mode '
            'completed: %(elapsed).02fs. Total quarantined: %(quars)d, '
            'Total errors: %(errors)d, Total files/sec: %(frate).2f , '
            'Total bytes/sec: %(brate).2f, Auditing time: %(audit).2f, '
            'Rate: %(audit_rate).2f') % {
                'type': self.auditor_type, 'mode': mode, 'elapsed': elapsed,
                'quars': total_quarantines, 'errors': total_errors,
                'frate': self.total_files_processed / elapsed,
                'brate': self.total_bytes_processed / elapsed,
                'audit': time_auditing, 'audit_rate': time_auditing / elapsed})

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

Fix proposed to branch: master
Review: https://review.openstack.org/4574

Changed in swift:
assignee: nobody → Doug Weimer (dweimer)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.openstack.org/4574
Committed: http://github.com/openstack/swift/commit/72267260b146673ecb4272bd740219f41464153c
Submitter: Jenkins
Branch: master

commit 72267260b146673ecb4272bd740219f41464153c
Author: Doug Weimer <email address hidden>
Date: Mon Feb 27 02:35:50 2012 +0000

    Prevent a possible divide by 0 in obj/auditor.py.

    Fixes bug 941731. If 'elapsed=0' in audit_all_objects set it
    to 0.000001 to avoid divide by 0.

    Change-Id: If0b43568033167818c482c8927863bea1dccfe57

Changed in swift:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in swift:
milestone: none → 1.4.7
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.