From e98a9373063ac62dc089cb76054340b210f3f65c Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 16 Sep 2014 16:53:15 -0700 Subject: 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 --- tooz/drivers/memcached.py | 12 ++++++++++-- 1 file 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) -- cgit v1.2.1