Commit fd566e39 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Avoid double-end of a replication.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2502 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0c7e1dd4
......@@ -115,7 +115,10 @@ class ReplicationHandler(EventHandler):
missing_tid_set = tid_set - my_tid_set
for tid in missing_tid_set:
ask(Packets.AskTransactionInformation(tid), timeout=300)
ask(self._doAskCheckTIDRange(add64(tid_list[-1], 1), RANGE_LENGTH))
if len(tid_list) == MIN_RANGE_LENGTH:
# If we received fewer, we knew it before sending AskTIDsFrom, and
# we should have finished TID replication at that time.
ask(self._doAskCheckTIDRange(add64(tid_list[-1], 1), RANGE_LENGTH))
@checkConnectionIsReplicatorConnection
def answerTransactionInformation(self, conn, tid,
......@@ -155,8 +158,9 @@ class ReplicationHandler(EventHandler):
missing_object_set = object_set - my_object_set
for oid, serial in missing_object_set:
ask(Packets.AskObject(oid, serial, None), timeout=300)
ask(self._doAskCheckSerialRange(max_oid, add64(max_serial, 1),
RANGE_LENGTH))
if sum((len(x) for x in object_dict.itervalues())) == MIN_RANGE_LENGTH:
ask(self._doAskCheckSerialRange(max_oid, add64(max_serial, 1),
RANGE_LENGTH))
@checkConnectionIsReplicatorConnection
def answerObject(self, conn, oid, serial_start,
......
......@@ -196,14 +196,12 @@ class StorageReplicationHandlerTests(NeoUnitTestBase):
app = self.getApp(conn=conn, tid_result=[])
# With no known TID
ReplicationHandler(app).answerTIDsFrom(conn, tid_list)
self._checkPacketTIDList(conn, tid_list[:], tid_list[-1], app)
# With some TIDs known
conn = self.getFakeConnection()
known_tid_list = [tid_list[0], tid_list[1]]
unknown_tid_list = [tid_list[2], ]
app = self.getApp(conn=conn, tid_result=known_tid_list)
ReplicationHandler(app).answerTIDsFrom(conn, tid_list[1:])
self._checkPacketTIDList(conn, unknown_tid_list, tid_list[-1], app)
calls = app.dm.mockGetNamedCalls('deleteTransaction')
self.assertEqual(len(calls), 1)
calls[0].checkArgs(tid_list[0])
......@@ -243,8 +241,6 @@ class StorageReplicationHandlerTests(NeoUnitTestBase):
app = self.getApp(conn=conn, history_result={})
# With no known OID/Serial
ReplicationHandler(app).answerObjectHistoryFrom(conn, oid_dict)
self._checkPacketSerialList(conn, flat_oid_list, oid_4, tid_list[5],
app)
# With some known OID/Serials
# For test to be realist, history_result should contain the same
# number of serials as oid_dict, otherise it just tests the special
......@@ -257,11 +253,6 @@ class StorageReplicationHandlerTests(NeoUnitTestBase):
oid_5: [tid_list[6]],
})
ReplicationHandler(app).answerObjectHistoryFrom(conn, oid_dict)
self._checkPacketSerialList(conn, (
(oid_1, oid_dict[oid_1][1]),
(oid_2, oid_dict[oid_2][0]),
(oid_2, oid_dict[oid_2][1]),
), oid_4, tid_list[5], app)
calls = app.dm.mockGetNamedCalls('deleteObject')
actual_deletes = set(((x.getParam(0), x.getParam(1)) for x in calls))
expected_deletes = set((
......
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