[Checkins] SVN: relstorage/trunk/relstorage/ Fixed handling of future checkpoints when no checkpoints are
Shane Hathaway
shane at hathawaymix.org
Tue Oct 20 17:19:11 EDT 2009
Log message for revision 105181:
Fixed handling of future checkpoints when no checkpoints are
currently set.
Changed:
U relstorage/trunk/relstorage/cache.py
U relstorage/trunk/relstorage/tests/test_cache.py
-=-
Modified: relstorage/trunk/relstorage/cache.py
===================================================================
--- relstorage/trunk/relstorage/cache.py 2009-10-20 20:49:17 UTC (rev 105180)
+++ relstorage/trunk/relstorage/cache.py 2009-10-20 21:19:11 UTC (rev 105181)
@@ -389,6 +389,8 @@
# checkpoint0 is in a future that this instance can't
# yet see. Ignore the checkpoint change for now.
new_checkpoints = self.checkpoints
+ if not new_checkpoints:
+ new_checkpoints = (new_tid_int, new_tid_int)
allow_shift = False
if (new_checkpoints == self.checkpoints
@@ -412,15 +414,16 @@
# Rebuild delta_after0 and delta_after1.
new_delta_after0 = {}
new_delta_after1 = {}
- # poller.list_changes provides an iterator of (oid, tid) where
- # tid > after_tid and tid <= last_tid.
- changes = self.adapter.poller.list_changes(
- cursor, cp1, new_tid_int)
- for oid_int, tid_int in changes:
- if tid_int > cp0:
- new_delta_after0[oid_int] = tid_int
- elif tid_int > cp1:
- new_delta_after1[oid_int] = tid_int
+ if cp0 <= new_tid_int:
+ # poller.list_changes provides an iterator of
+ # (oid, tid) where tid > after_tid and tid <= last_tid.
+ changes = self.adapter.poller.list_changes(
+ cursor, cp1, new_tid_int)
+ for oid_int, tid_int in changes:
+ if tid_int > cp0:
+ new_delta_after0[oid_int] = tid_int
+ elif tid_int > cp1:
+ new_delta_after1[oid_int] = tid_int
self.checkpoints = new_checkpoints
self.delta_after0 = new_delta_after0
self.delta_after1 = new_delta_after1
Modified: relstorage/trunk/relstorage/tests/test_cache.py
===================================================================
--- relstorage/trunk/relstorage/tests/test_cache.py 2009-10-20 20:49:17 UTC (rev 105180)
+++ relstorage/trunk/relstorage/tests/test_cache.py 2009-10-20 21:19:11 UTC (rev 105181)
@@ -253,7 +253,7 @@
self.assertEqual(c.checkpoints, (50, 50))
self.assertEqual(data['myprefix:checkpoints'], '40 30')
- def test_after_poll_future_checkpoints(self):
+ def test_after_poll_future_checkpoints_when_cp_exist(self):
from relstorage.tests.fakecache import data
data['myprefix:checkpoints'] = '90 80'
c = self._makeOne()
@@ -267,6 +267,18 @@
self.assertEqual(c.delta_after0, {2: 45})
self.assertEqual(c.delta_after1, {})
+ def test_after_poll_future_checkpoints_when_cp_nonexistent(self):
+ from relstorage.tests.fakecache import data
+ data['myprefix:checkpoints'] = '90 80'
+ c = self._makeOne()
+ c.after_poll(None, 40, 50, [(2, 45)])
+ # This instance can't yet see txn 90, and there aren't any
+ # existing checkpoints, so fall back to the current tid.
+ self.assertEqual(c.checkpoints, (50, 50))
+ self.assertEqual(data['myprefix:checkpoints'], '90 80')
+ self.assertEqual(c.delta_after0, {})
+ self.assertEqual(c.delta_after1, {})
+
def test_after_poll_retain_checkpoints(self):
from relstorage.tests.fakecache import data
data['myprefix:checkpoints'] = '40 30'
More information about the checkins
mailing list