diff options
author | Tim Laszlo <tim.laszlo@gmail.com> | 2010-07-26 15:30:51 +0000 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2010-07-30 11:53:15 -0500 |
commit | 368f9c770c0eadc8a4cf4b54255ee8d51b55c95b (patch) | |
tree | 0dd911f42bea05304dd13a1b3d430aa3b1a6d07d /src/lib/Server/Plugins | |
parent | bf3fe01ce7c139e1afe8b6addc8cd4c6c819c4a9 (diff) | |
download | bcfg2-368f9c770c0eadc8a4cf4b54255ee8d51b55c95b.tar.gz bcfg2-368f9c770c0eadc8a4cf4b54255ee8d51b55c95b.tar.bz2 bcfg2-368f9c770c0eadc8a4cf4b54255ee8d51b55c95b.zip |
DBStats: Fix random mysql errors
Occasionally importing ping data would fail with "Commands out of
sync; you can't run this command now".
Improved logging and error handling for imports.
Fixed indentation error in GetCurrentEntry
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5992 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugins')
-rw-r--r-- | src/lib/Server/Plugins/DBStats.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/lib/Server/Plugins/DBStats.py b/src/lib/Server/Plugins/DBStats.py index fe357fc40..2712cd45f 100644 --- a/src/lib/Server/Plugins/DBStats.py +++ b/src/lib/Server/Plugins/DBStats.py @@ -5,6 +5,11 @@ import lxml.etree import platform import time +try: + from django.core.exceptions import MultipleObjectsReturned +except ImportError: + pass + import Bcfg2.Server.Plugin import Bcfg2.Server.Reports.importscript from Bcfg2.Server.Reports.reports.models import Client @@ -53,15 +58,19 @@ class DBStats(Bcfg2.Server.Plugin.Plugin, logger, True, platform.node()) + logger.info("Imported data for %s in %s seconds" \ + % (metadata.hostname, time.time() - start)) + return + except MultipleObjectsReturned, e: + logger.error("DBStats: MultipleObjectsReturned while handling %s: %s" % \ + (metadata.hostname, e)) + logger.error("DBStats: Data is inconsistent") break except: logger.error("DBStats: Failed to write to db (lock); retrying", exc_info=1) - if i == 3: - logger.error("DBStats: Retry limit failed; aborting operation") - return - logger.info("Imported data in the reason fast path in %s second" \ - % (time.time() - start)) + logger.error("DBStats: Retry limit failed for %s; aborting operation" \ + % metadata.hostname) def GetExtra(self, client): c_inst = Client.objects.filter(name=client)[0] @@ -95,7 +104,7 @@ class DBStats(Bcfg2.Server.Plugin.Plugin, entry.reason.current_diff.split('\n'), 1))) elif entry.reason.is_binary: # If len is zero the object was too large to store - raise Bcfg2.Server.Plugin.PluginExecutionError + raise Bcfg2.Server.Plugin.PluginExecutionError else: ret.append(None) return ret |