Skip to content

Commit

Permalink
Do not postpone leader race after recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Kukushkin committed Nov 22, 2016
1 parent f70b2e0 commit 8868da1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
5 changes: 0 additions & 5 deletions patroni/ha.py
Expand Up @@ -738,11 +738,6 @@ def _run_cycle(self):
if msg is not None:
return msg

if not self.has_lock() and len(self.cluster.members) == 1 and \
not (self.is_synchronous_mode() and self.cluster.sync and
self.cluster.sync.matches(self.state_handler.name)):
return 'too few members in cluster after "recovery", postponing leader race'

# is data directory empty?
if self.state_handler.data_directory_empty():
return self.bootstrap() # new node
Expand Down
9 changes: 0 additions & 9 deletions tests/test_ha.py
Expand Up @@ -173,15 +173,6 @@ def test_recover_master_failed(self):
self.ha.cluster = get_cluster_initialized_with_leader()
self.assertEquals(self.ha.run_cycle(), 'starting as readonly because i had the session lock')

def test_postpone_leader_race_after_recovery(self):
self.ha.cluster = get_cluster(True, None, [Member(0, 'other', 28, {})], None, None)
self.p.is_healthy = false
self.p.is_running = false
self.p.follow = false
self.ha.post_recover = Mock(return_value=None)
self.assertEquals(self.ha.run_cycle(), 'starting as a secondary')
self.assertEquals(self.ha.run_cycle(), 'too few members in cluster after "recovery", postponing leader race')

@patch('sys.exit', return_value=1)
@patch('patroni.ha.Ha.sysid_valid', MagicMock(return_value=True))
def test_sysid_no_match(self, exit_mock):
Expand Down

0 comments on commit 8868da1

Please sign in to comment.