From 72010f68cc633e97b108d9eb79235d8a9b1a37d8 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Fri, 8 May 2015 16:21:09 +0200 Subject: [PATCH] Bugfix: two calls has_lock and update_lock are not atomic Having a lock a few moments ago, doesn't mean that you will be able to update it. --- helpers/ha.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/helpers/ha.py b/helpers/ha.py index 1c2426d8..ed9f11f4 100644 --- a/helpers/ha.py +++ b/helpers/ha.py @@ -59,9 +59,7 @@ class Ha: self.state_handler.follow_the_leader(self.fetch_current_leader()) return "following a different leader because i am not the healthiest node" else: - if self.has_lock(): - self.update_lock() - + if self.has_lock() and self.update_lock() if not self.state_handler.is_leader(): self.state_handler.promote() return "promoted self to leader because i had the session lock"