Commit 7b2e6752 authored by Julien Muchembled's avatar Julien Muchembled

master: fix/simplify generation of TID

The 'min_tid < new_tid' assertion failed when jumping to the past.
parent ca2f7061
...@@ -235,28 +235,15 @@ class TransactionManager(EventQueue): ...@@ -235,28 +235,15 @@ class TransactionManager(EventQueue):
min_tid = self._last_tid min_tid = self._last_tid
if tid <= min_tid: if tid <= min_tid:
tid = addTID(min_tid, 1) tid = addTID(min_tid, 1)
# We know we won't have room to adjust by decreasing.
try_decrease = False
else:
try_decrease = True
if ttid is not None: if ttid is not None:
assert isinstance(ttid, basestring), repr(ttid) remainder = u64(ttid) % divisor
assert isinstance(divisor, (int, long)), repr(divisor) delta_remainder = remainder - u64(tid) % divisor
ref_remainder = u64(ttid) % divisor if delta_remainder:
remainder = u64(tid) % divisor tid = addTID(tid, delta_remainder)
if ref_remainder != remainder: if tid <= min_tid:
if try_decrease: tid = addTID(tid, divisor)
new_tid = addTID(tid, ref_remainder - divisor - remainder) assert u64(tid) % divisor == remainder, (dump(tid), remainder)
assert u64(new_tid) % divisor == ref_remainder, (dump(new_tid), assert min_tid < tid, (dump(min_tid), dump(tid))
ref_remainder)
if new_tid <= min_tid:
new_tid = addTID(new_tid, divisor)
else:
if ref_remainder > remainder:
ref_remainder += divisor
new_tid = addTID(tid, ref_remainder - remainder)
assert min_tid < new_tid, (dump(min_tid), dump(tid), dump(new_tid))
tid = new_tid
self._last_tid = tid self._last_tid = tid
return self._last_tid return self._last_tid
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment