[Zodb-checkins] CVS: ZODB3/ZEO - cache.py:1.1.2.8

Jeremy Hylton cvs-admin at zope.org
Wed Nov 19 14:13:11 EST 2003


Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv1325

Modified Files:
      Tag: ZODB3-mvcc-2-branch
	cache.py 
Log Message:
Bunch of small fixes to trace code.

Make sure tid and end_tid are properly initialized before calling pack().
Add debugging print to _trace() for now.
Pass data length for loads(), since stats seems to want it.


=== ZODB3/ZEO/cache.py 1.1.2.7 => 1.1.2.8 ===
--- ZODB3/ZEO/cache.py:1.1.2.7	Wed Nov 19 13:38:48 2003
+++ ZODB3/ZEO/cache.py	Wed Nov 19 14:13:08 2003
@@ -21,6 +21,8 @@
 
 from sets import Set
 
+from ZODB.utils import z64
+
 ##
 # A disk-based cache for ZEO clients.
 # <p>
@@ -74,7 +76,7 @@
         self.size = size
         self.log = logging.getLogger("zeo.cache")
 
-        if trace:
+        if trace and path:
             self._setup_trace()
         else:
             self._trace = self._notrace
@@ -189,7 +191,7 @@
         o = self.dll.access((oid, tid))
         if o is None:
             return None
-        self._trace(0x22, oid, version)
+        self._trace(0x22, oid, version, o.start_tid, o.end_tid, len(o.data))
         return o.data, o.serialno, tid
 
     ##
@@ -259,7 +261,7 @@
                     raise ValueError("data already exists for version %r"
                                      % self.version[oid][0])
             self.version[oid] = version, start_tid
-            self._trace(0x50, oid, version, start_tid)
+            self._trace(0x50, oid, version, start_tid, dlen=len(data))
         else:
             if end_tid is None:
                 _cur_start = self.current.get(oid)
@@ -269,14 +271,15 @@
                     else:
                         return
                 self.current[oid] = start_tid
-                self._trace(0x52, oid, version, start_tid)
+                self._trace(0x52, oid, version, start_tid, dlen=len(data))
             else:
                 L = self.noncurrent.setdefault(oid, [])
                 p = start_tid, end_tid
                 if p in L:
                     return # duplicate store
                 bisect.insort_left(L, (start_tid, end_tid))
-                self._trace(0x54, oid, version, start_end, end_tid)
+                self._trace(0x54, oid, version, start_tid, end_tid,
+                            dlen=len(data))
         self.dll.add(o)
 
     ##
@@ -353,11 +356,11 @@
             self.log.warning("Could not write to trace file %s: %s",
                              tfn, msg)
 
-    def _notrace(self, *arg):
+    def _notrace(self, *arg, **kwargs):
         pass
 
     def _trace(self,
-               code, oid="", version="", tid="", end_tid="", dlen=0,
+               code, oid="", version="", tid="", end_tid=z64, dlen=0,
                # The next two are just speed hacks.
                time_time=time.time, struct_pack=struct.pack):
         # The code argument is two hex digits; bits 0 and 7 must be zero.
@@ -368,13 +371,21 @@
         # Note: when tracing is disabled, this method is hidden by a dummy.
         if version:
             code |= 0x80
-        encoded = (dlen + 255) & 0x7fffff00 | code 
-        self.tracefile.write(
-            struct_pack(">iiH8s8s",
-                        time_time(),
-                        encoded,
-                        len(oid),
-                        tid, end_tid) + oid)
+        encoded = (dlen + 255) & 0x7fffff00 | code
+        if tid is None:
+            tid = z64
+        if end_tid is None:
+            end_tid = z64
+        try:
+            self.tracefile.write(
+                struct_pack(">iiH8s8s",
+                            time_time(),
+                            encoded,
+                            len(oid),
+                            tid, end_tid) + oid)
+        except:
+            print `tid`, `end_tid`
+            raise
 ##
 # An object that's part of a headed, circular, doubly-linked list.
 # Because it's doubly linked, an object can be removed from the list




More information about the Zodb-checkins mailing list