Commit 073ce093 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Make pt.log() more robust. Do not delete cell lists in protocol handling (what was this for?).

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@206 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 1154f37b
...@@ -18,6 +18,7 @@ from neo.master.verification import VerificationEventHandler ...@@ -18,6 +18,7 @@ from neo.master.verification import VerificationEventHandler
from neo.master.service import ServiceEventHandler from neo.master.service import ServiceEventHandler
from neo.master.secondary import SecondaryEventHandler from neo.master.secondary import SecondaryEventHandler
from neo.pt import PartitionTable from neo.pt import PartitionTable
from neo.util import dump
class Application(object): class Application(object):
"""The master node application.""" """The master node application."""
...@@ -401,11 +402,15 @@ class Application(object): ...@@ -401,11 +402,15 @@ class Application(object):
if self.lptid != prev_lptid or not self.pt.filled(): if self.lptid != prev_lptid or not self.pt.filled():
# I got something newer or the target is dead. # I got something newer or the target is dead.
logging.debug('self.lptid = %s, prev_lptid = %s',
dump(self.lptid), dump(prev_lptid))
self.pt.log()
continue continue
# Wait until the cluster gets operational or the Partition Table ID # Wait until the cluster gets operational or the Partition Table ID
# turns out to be not the latest. # turns out to be not the latest.
logging.debug('waiting for the cluster to be operational') logging.debug('waiting for the cluster to be operational')
self.pt.log()
while 1: while 1:
em.poll(1) em.poll(1)
if self.pt.operational(): if self.pt.operational():
......
...@@ -316,6 +316,8 @@ class RecoveryEventHandler(MasterEventHandler): ...@@ -316,6 +316,8 @@ class RecoveryEventHandler(MasterEventHandler):
return return
if uuid != app.target_uuid: if uuid != app.target_uuid:
# If this is not from a target node, ignore it. # If this is not from a target node, ignore it.
logging.warn('got answer partition table from %s while waiting for %s',
dump(uuid), dump(app.target_uuid))
return return
for offset, cell_list in row_list: for offset, cell_list in row_list:
......
...@@ -790,7 +790,6 @@ class Packet(object): ...@@ -790,7 +790,6 @@ class Packet(object):
index += 18 index += 18
cell_list.append(cell) cell_list.append(cell)
row_list.append((offset, cell_list)) row_list.append((offset, cell_list))
del cell_list[:]
except: except:
raise ProtocolError(self, 'invalid answer partition table') raise ProtocolError(self, 'invalid answer partition table')
return ptid, row_list return ptid, row_list
...@@ -810,7 +809,6 @@ class Packet(object): ...@@ -810,7 +809,6 @@ class Packet(object):
index += 18 index += 18
cell_list.append(cell) cell_list.append(cell)
row_list.append((offset, tuple(cell_list))) row_list.append((offset, tuple(cell_list)))
del cell_list[:]
except: except:
raise ProtocolError(self, 'invalid send partition table') raise ProtocolError(self, 'invalid send partition table')
return ptid, row_list return ptid, row_list
......
...@@ -152,11 +152,14 @@ class PartitionTable(object): ...@@ -152,11 +152,14 @@ class PartitionTable(object):
FEEDING_STATE: 'F' } FEEDING_STATE: 'F' }
for offset, row in enumerate(self.partition_list): for offset, row in enumerate(self.partition_list):
desc_list = [] desc_list = []
for cell in row: if row is None:
i = node_dict[cell.getNode()] desc_list.append('None')
cell_state = cell_state_dict[cell.getState()] else:
node_state = node_state_dict[cell.getNodeState()] for cell in row:
desc_list.append('%d %s %s' % (i, cell_state, node_state)) i = node_dict[cell.getNode()]
cell_state = cell_state_dict[cell.getState()]
node_state = node_state_dict[cell.getNodeState()]
desc_list.append('%d %s %s' % (i, cell_state, node_state))
logging.debug('pt: row %d: %s', offset, ', '.join(desc_list)) logging.debug('pt: row %d: %s', offset, ', '.join(desc_list))
def operational(self): def operational(self):
......
...@@ -252,6 +252,7 @@ class Replicator(object): ...@@ -252,6 +252,7 @@ class Replicator(object):
pass pass
def _askCriticalTID(self): def _askCriticalTID(self):
logging.debug('self.new_partition_list = %r', self.new_partition_list)
conn = self.primary_master_connection conn = self.primary_master_connection
msg_id = conn.getNextId() msg_id = conn.getNextId()
conn.addPacket(Packet().askLastIDs(msg_id)) conn.addPacket(Packet().askLastIDs(msg_id))
...@@ -268,7 +269,7 @@ class Replicator(object): ...@@ -268,7 +269,7 @@ class Replicator(object):
def _askUnfinishedTIDs(self): def _askUnfinishedTIDs(self):
conn = self.primary_master_connection conn = self.primary_master_connection
msg_id = conn.getNextId() msg_id = conn.getNextId()
conn.addPacket(Packet().askUnfinishedTIDs(msg_id)) conn.addPacket(Packet().askUnfinishedTransactions(msg_id))
conn.expectMessage(msg_id) conn.expectMessage(msg_id)
self.waiting_for_unfinished_tids = True self.waiting_for_unfinished_tids = True
......
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