Commit 4468d14d authored by Vincent Pelletier's avatar Vincent Pelletier

Fix missing field decoding in AnswerLastIDs.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1976 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 15744c7a
......@@ -119,8 +119,13 @@ class RecoveryManager(MasterHandler):
pt = app.pt
# Get max values.
app.loid = max(loid, app.loid)
self.app.tm.setLastTID(ltid)
if loid is not None:
if app.loid is None:
app.loid = loid
else:
app.loid = max(loid, app.loid)
if ltid is not None:
self.app.tm.setLastTID(ltid)
if lptid > pt.getID():
# something newer
self.target_uuid = conn.getUUID()
......
......@@ -148,7 +148,10 @@ class TransactionManager(object):
"""
Set the last TID, keep the previous if lower
"""
self._last_tid = max(self._last_tid, tid)
if self._last_tid is None:
self._last_tid = tid
else:
self._last_tid = max(self._last_tid, tid)
def reset(self):
"""
......
......@@ -185,8 +185,9 @@ class VerificationManager(BaseServiceHandler):
def answerLastIDs(self, conn, loid, ltid, lptid):
app = self.app
# If I get a bigger value here, it is dangerous.
if app.loid < loid or app.tm.getLastTID() < ltid \
or app.pt.getID() < lptid:
if (loid is not None and app.loid < loid) or \
(ltid is not None and app.tm.getLastTID() < ltid) or \
(lptid is not None and app.pt.getID() < lptid):
logging.critical('got later information in verification')
raise VerificationFailure
......
......@@ -453,6 +453,9 @@ class AnswerLastIDs(Packet):
def _decode(self, body):
(loid, ltid, lptid) = unpack('!8s8s8s', body)
if loid == INVALID_OID:
loid = None
ltid = _decodeTID(ltid)
lptid = _decodePTID(lptid)
return (loid, ltid, lptid)
......
......@@ -37,6 +37,8 @@ class Partition(object):
return self.tid
def setCriticalTID(self, tid):
if tid is None:
tid = '\x00' * 8
self.tid = tid
def safe(self, pending_tid_list):
......
......@@ -94,8 +94,8 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.app.pt = Mock({'getID': last_ptid})
self.verification.askLastIDs(conn)
oid, tid, ptid = self.checkAnswerLastIDs(conn, decode=True)
self.assertEqual(oid, INVALID_OID)
self.assertEqual(tid, INVALID_TID)
self.assertEqual(oid, None)
self.assertEqual(tid, None)
self.assertEqual(ptid, last_ptid)
# return value stored in db
......
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