Commit 57265e7f authored by Vincent Pelletier's avatar Vincent Pelletier

Make handleAnswerPrimaryMaster, handleRequestNodeIdentification and...

Make handleAnswerPrimaryMaster, handleRequestNodeIdentification and handleAskPrimaryMaster resilient to connection loss. As they are involved in question-response exchanges during election on connections which will get dropped as soon as a master arises, they must check if the connection is still opened before trying to send.
Note: the connection might get closed anyway during the actual send, but this is handled separately already. The problem we fix here emerged because of more tedious checkings in Connection's ask & answer methods.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@799 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent a80f94df
...@@ -157,6 +157,14 @@ class ClientElectionEventHandler(MasterEventHandler): ...@@ -157,6 +157,14 @@ class ClientElectionEventHandler(MasterEventHandler):
app.negotiating_master_node_set.discard(conn.getAddress()) app.negotiating_master_node_set.discard(conn.getAddress())
def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list): def handleAnswerPrimaryMaster(self, conn, packet, primary_uuid, known_master_list):
if conn.getConnector() is None:
# Connection can be closed by peer after he sent
# AnswerPrimaryMaster if he finds the primary master before we
# give him our UUID.
# The connection gets closed before this message gets processed
# because this message might have been queued, but connection
# interruption takes effect as soon as received.
return
app = self.app app = self.app
# Register new master nodes. # Register new master nodes.
for ip_address, port, uuid in known_master_list: for ip_address, port, uuid in known_master_list:
...@@ -215,6 +223,14 @@ class ServerElectionEventHandler(MasterEventHandler): ...@@ -215,6 +223,14 @@ class ServerElectionEventHandler(MasterEventHandler):
def handleRequestNodeIdentification(self, conn, packet, node_type, def handleRequestNodeIdentification(self, conn, packet, node_type,
uuid, ip_address, port, name): uuid, ip_address, port, name):
if conn.getConnector() is None:
# Connection can be closed by peer after he sent
# RequestNodeIdentification if he finds the primary master before
# we answer him.
# The connection gets closed before this message gets processed
# because this message might have been queued, but connection
# interruption takes effect as soon as received.
return
self.checkClusterName(name) self.checkClusterName(name)
app = self.app app = self.app
if node_type != MASTER_NODE_TYPE: if node_type != MASTER_NODE_TYPE:
......
...@@ -80,6 +80,13 @@ class MasterEventHandler(EventHandler): ...@@ -80,6 +80,13 @@ class MasterEventHandler(EventHandler):
logging.error('ignoring notify cluster information in %s' % self.__class__.__name__) logging.error('ignoring notify cluster information in %s' % self.__class__.__name__)
def handleAskPrimaryMaster(self, conn, packet): def handleAskPrimaryMaster(self, conn, packet):
if conn.getConnector() is None:
# Connection can be closed by peer after he sent AskPrimaryMaster
# if he finds the primary master before we answer him.
# The connection gets closed before this message gets processed
# because this message might have been queued, but connection
# interruption takes effect as soon as received.
return
app = self.app app = self.app
if app.primary: if app.primary:
primary_uuid = app.uuid primary_uuid = app.uuid
......
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