Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

memcached-pool silent umemcache exception #10

Closed
fernandogrd opened this issue Feb 19, 2013 · 3 comments
Closed

memcached-pool silent umemcache exception #10

fernandogrd opened this issue Feb 19, 2013 · 3 comments
Labels
ARCHIVED - http://mzl.la/ghe-archive CLOSED at time of archiving

Comments

@fernandogrd
Copy link
Contributor

I had a hard time to debug a problem, looks like memcached pool is silencing something it shouldn't

My problem was an invalid cache key (whitespace), as we can see, while pure umemcache shows a warning on set and a exception on get, when using memcached-pool, it just returns None on get, and as I could observe, it get slow when that happens.

In [1]: import umemcache

In [2]: c = umemcache.Client('127.0.0.1:11211')

In [3]: c.connect()

In [4]: key = 'inva lid'

In [5]: c.set(key, 'value', 999)
Out[5]: 'CLIENT_ERROR bad command line format'

In [6]: c.get(key)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/home/fernando/.virtualenvs/th/src/django/django/core/management/commands/shell.pyc in <module>()
----> 1 c.get(key)

RuntimeError: umemcache: Unspecified error
In [7]: from django.core.cache import cache

In [8]: cache.set(key, 'value', 999)

In [9]: cache.get(key)

In [12]: cache._lib
Out[12]: <module 'memcachepool.client' from '/home/fernando/.virtualenvs/th/lib/python2.7/site-packages/memcachepool/client.pyc'>
@fernandogrd
Copy link
Contributor Author

I'm using memcached-pool 0.4 from pypi.
Just tried with master, and now it seems to stuck in a infinity loop on set:

In [8]: cache.set(key, 'value', 999)

^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/home/fernando/.virtualenvs/th/src/django/django/core/management/commands/shell.pyc in <module>()
----> 1 cache.set(key, 'value', 999)

/home/fernando/.virtualenvs/th/src/memcached-pool/memcachepool/cache.pyc in set(self, key, value, timeout, version)
    163             value = '%d' % value
    164         key = self.make_key(key, version=version)
--> 165         self.call('set', key, value, self._get_memcache_timeout(timeout), flag)
    166 
    167     def delete(self, key, version=None):

/home/fernando/.virtualenvs/th/src/memcached-pool/memcachepool/cache.pyc in call(self, func, *args, **kwargs)
     45             with self._pool.reserve() as conn:
     46                 try:
---> 47                     return getattr(conn, func)(*args, **kwargs)
     48                 except Exception, exc:
     49                     # log

/home/fernando/.virtualenvs/th/src/memcached-pool/memcachepool/client.pyc in __with_retry(*args, **kw)
     80                     self._create_client()
     81                     current_func = getattr(self._client, func.__name__)
---> 82                     time.sleep(delay)
     83                     retries += 1
     84                     delay *= 3      # growing the delay

KeyboardInterrupt: 

@tarekziade
Copy link
Contributor

are you using gevent ? a blocking sleep sounds like a blocking greenlet

@fernandogrd
Copy link
Contributor Author

No, I remember having eventlet installed, but gunicorn worker was not using it, and tests above I did in manage.py shell. I wasn't importing it anywhere too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ARCHIVED - http://mzl.la/ghe-archive CLOSED at time of archiving
Projects
None yet
Development

No branches or pull requests

3 participants