Commit dba07e72 by Julien Muchembled

master: fix crash in STARTING_BACKUP when connecting to an upstream secondary master

This fixes the following assertion:

  Traceback (most recent call last):
    File "neo/master/app.py", line 172, in run
      self._run()
    File "neo/master/app.py", line 182, in _run
      self.playPrimaryRole()
    File "neo/master/app.py", line 302, in playPrimaryRole
      self.backup_app.provideService())
    File "neo/master/backup_app.py", line 114, in provideService
      node, conn = bootstrap.getPrimaryConnection()
    File "neo/lib/bootstrap.py", line 74, in getPrimaryConnection
      poll(1)
    File "neo/lib/event.py", line 160, in poll
      to_process.process()
    File "neo/lib/connection.py", line 504, in process
      self._handlers.handle(self, self._queue.pop(0))
    File "neo/lib/connection.py", line 92, in handle
      self._handle(connection, packet)
    File "neo/lib/connection.py", line 107, in _handle
      pending[0][1].packetReceived(connection, packet)
    File "neo/lib/handler.py", line 125, in packetReceived
      self.dispatch(*args)
    File "neo/lib/handler.py", line 75, in dispatch
      method(conn, *args, **kw)
    File "neo/lib/handler.py", line 159, in notPrimaryMaster
      assert primary != self.app.server
  AttributeError: 'BackupApplication' object has no attribute 'server'
1 parent e3cd5c5b
......@@ -65,6 +65,7 @@ There is no conflict of node id between the 2 clusters:
class BackupApplication(object):
pt = None
server = None # like in BaseApplication
uuid = None
def __init__(self, app, name, master_addresses):
......
......@@ -349,6 +349,22 @@ class ReplicationTests(NEOThreadedTest):
self.tic()
self.assertTrue(backup.master.is_alive())
@with_cluster(master_count=2)
def testBackupFromUpstreamWithSecondaryMaster(self, upstream):
"""
Check that the backup master reacts correctly when connecting first
to a secondary master of the upstream cluster.
"""
with NEOCluster(upstream=upstream) as backup:
primary = upstream.primary_master
m, = (m for m in upstream.master_list if m is not primary)
backup.master.resetNode(upstream_masters=[m.server])
backup.start()
backup.neoctl.setClusterState(ClusterStates.STARTING_BACKUP)
self.tic()
self.assertEqual(backup.neoctl.getClusterState(),
ClusterStates.BACKINGUP)
@backup_test()
def testCreationUndone(self, backup):
"""
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!