Commit 35737c9b authored by Julien Muchembled's avatar Julien Muchembled

master: fix random crashes on shutdown when using several master nodes

parent 35468667
...@@ -26,10 +26,11 @@ class SecondaryMasterHandler(MasterHandler): ...@@ -26,10 +26,11 @@ class SecondaryMasterHandler(MasterHandler):
""" Handler used by primary to handle secondary masters""" """ Handler used by primary to handle secondary masters"""
def connectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
node = self.app.nm.getByUUID(conn.getUUID()) app = self.app
assert node is not None if app.listening_conn: # if running
node = app.nm.getByUUID(conn.getUUID())
node.setDown() node.setDown()
self.app.broadcastNodesInformation([node]) app.broadcastNodesInformation([node])
def announcePrimary(self, conn): def announcePrimary(self, conn):
raise ElectionFailure, 'another primary arises' raise ElectionFailure, 'another primary arises'
...@@ -45,12 +46,12 @@ class PrimaryHandler(EventHandler): ...@@ -45,12 +46,12 @@ class PrimaryHandler(EventHandler):
""" Handler used by secondaries to handle primary master""" """ Handler used by secondaries to handle primary master"""
def connectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
self.app.primary_master_node.setDown() self.connectionFailed(conn)
raise PrimaryFailure, 'primary master is dead'
def connectionFailed(self, conn): def connectionFailed(self, conn):
self.app.primary_master_node.setDown() self.app.primary_master_node.setDown()
raise PrimaryFailure, 'primary master is dead' if self.app.listening_conn: # if running
raise PrimaryFailure('primary master is dead')
def connectionCompleted(self, conn): def connectionCompleted(self, conn):
app = self.app app = self.app
......
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