summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2014-09-16 16:53:15 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2014-09-16 16:55:14 -0700
commite98a9373063ac62dc089cb76054340b210f3f65c (patch)
treef4741ff1e26c69845b7c419a223a68b28fc12732
parentc5e1c3f96f016c9ddfff8206d1bebeaf4ea44e6c (diff)
downloadtooz-e98a9373063ac62dc089cb76054340b210f3f65c.tar.gz
LOG a warning if the heartbeat can not be validated
If for some reason the heartbeat can not occur instead of failing silently it is better to at least log a message so that operators can investigate the underlying issue. Change-Id: Ide88314c413afa389d6c039478324d6e47f63e82
-rw-r--r--tooz/drivers/memcached.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/tooz/drivers/memcached.py b/tooz/drivers/memcached.py
index 085923c..2ac025b 100644
--- a/tooz/drivers/memcached.py
+++ b/tooz/drivers/memcached.py
@@ -17,6 +17,7 @@
# under the License.
import collections
+import logging
import msgpack
import pymemcache.client
@@ -27,6 +28,9 @@ from tooz import coordination
from tooz import locking
+LOG = logging.getLogger(__name__)
+
+
class Retry(Exception):
"""Exception raised if we need to retry."""
@@ -68,8 +72,12 @@ class MemcachedLock(locking.Lock):
def heartbeat(self):
"""Keep the lock alive."""
- self.coord.client.touch(self.name,
- expire=self.timeout)
+ poked = self.coord.client.touch(self.name,
+ expire=self.timeout,
+ noreply=False)
+ if not poked:
+ LOG.warn("Unable to heartbeat by updating key '%s' with extended"
+ " expiry of %s seconds", self.name, self.timeout)
def get_owner(self):
return self.coord.client.get(self.name)