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