[Checkins] SVN: relstorage/trunk/relstorage/storage.py The log message for POSKeyError on history-free storage should be simpler.

Shane Hathaway shane at hathawaymix.org
Thu Oct 1 14:01:53 EDT 2009


Log message for revision 104687:
  The log message for POSKeyError on history-free storage should be simpler.
  

Changed:
  U   relstorage/trunk/relstorage/storage.py

-=-
Modified: relstorage/trunk/relstorage/storage.py
===================================================================
--- relstorage/trunk/relstorage/storage.py	2009-10-01 18:00:50 UTC (rev 104686)
+++ relstorage/trunk/relstorage/storage.py	2009-10-01 18:01:52 UTC (rev 104687)
@@ -298,7 +298,7 @@
         return self._adapter.stats.get_db_size()
 
     def _log_keyerror(self, oid_int, reason):
-        """Log just before raising KeyError in load().
+        """Log just before raising POSKeyError in load().
 
         KeyErrors in load() are generally not supposed to happen,
         so this is a good place to gather information.
@@ -306,33 +306,39 @@
         cursor = self._load_cursor
         adapter = self._adapter
         logfunc = log.warning
-        msg = ["Storage KeyError on oid %d: %s" % (oid_int, reason)]
-        rows = adapter.dbiter.iter_transactions(cursor)
-        row = None
-        for row in rows:
-            # just get the first row
-            break
-        if not row:
-            # This happens when initializing a new database, so it's
-            # not a warning.
-            logfunc = log.debug
-            msg.append("No transactions exist")
+        msg = ["POSKeyError on oid %d: %s" % (oid_int, reason)]
+
+        if adapter.keep_history:
+            rows = adapter.dbiter.iter_transactions(cursor)
+            row = None
+            for row in rows:
+                # just get the first row
+                break
+            if not row:
+                # This happens when initializing a new database or
+                # after packing, so it's not a warning.
+                logfunc = log.debug
+                msg.append("No previous transactions exist")
+            else:
+                msg.append("Current transaction is %d" % row[0])
+
+            tids = []
+            try:
+                rows = adapter.dbiter.iter_object_history(cursor, oid_int)
+            except KeyError:
+                # The object has no history, at least from the point of view
+                # of the current database load connection.
+                pass
+            else:
+                for row in rows:
+                    tids.append(row[0])
+                    if len(tids) >= 10:
+                        break
+            msg.append("Recent object tids: %s" % repr(tids))
+
         else:
-            msg.append("Current transaction is %d" % row[0])
+            msg.append("history-free adapter")
 
-        tids = []
-        try:
-            rows = adapter.dbiter.iter_object_history(cursor, oid_int)
-        except KeyError:
-            # The object has no history, at least from the point of view
-            # of the current database load connection.
-            pass
-        else:
-            for row in rows:
-                tids.append(row[0])
-                if len(tids) >= 10:
-                    break
-        msg.append("Recent object tids: %s" % repr(tids))
         logfunc('; '.join(msg))
 
     def _get_oid_cache_key(self, oid_int):



More information about the checkins mailing list