[Checkins] SVN: relstorage/trunk/relstorage/cache.py If delta_after0 is far over the delta limit (caused by a large

Shane Hathaway shane at hathawaymix.org
Tue Nov 17 03:33:51 EST 2009


Log message for revision 105747:
  If delta_after0 is far over the delta limit (caused by a large
  transaction), suggest starting new checkpoints instead of
  shifting.
  

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

-=-
Modified: relstorage/trunk/relstorage/cache.py
===================================================================
--- relstorage/trunk/relstorage/cache.py	2009-11-17 08:16:18 UTC (rev 105746)
+++ relstorage/trunk/relstorage/cache.py	2009-11-17 08:33:50 UTC (rev 105747)
@@ -433,10 +433,14 @@
             # delta_after0 has reached its limit.  The way to
             # shrink it is to shift the checkpoints.  Suggest
             # shifted checkpoints for future polls.
-            self._suggest_shifted_checkpoints(new_tid_int)
+            # If delta_after0 is far over the limit (caused by a large
+            # transaction), suggest starting new checkpoints instead of
+            # shifting.
+            oversize = (len(self.delta_after0) >= self.delta_size_limit * 2)
+            self._suggest_shifted_checkpoints(new_tid_int, oversize)
 
 
-    def _suggest_shifted_checkpoints(self, tid_int):
+    def _suggest_shifted_checkpoints(self, tid_int, oversize):
         """Suggest that future polls use a new pair of checkpoints.
 
         This does nothing if another instance has already shifted
@@ -448,7 +452,12 @@
         cp0, cp1 = self.checkpoints
         assert tid_int > cp0
         expect = '%d %d' % self.checkpoints
-        change_to = '%d %d' % (tid_int, cp0)
+        if oversize:
+            # start new checkpoints
+            change_to = '%d %d' % (tid_int, tid_int)
+        else:
+            # shift the existing checkpoints
+            change_to = '%d %d' % (tid_int, cp0)
         for client in self.clients_global_first:
             old_value = client.get(self.checkpoints_key)
             if old_value:



More information about the checkins mailing list