python-memcached icon indicating copy to clipboard operation
python-memcached copied to clipboard

Change in FLAGS set by 1.59 breaks compatibility with earlier python-memcached clients

Open microwavenby opened this issue 7 years ago • 2 comments

Hi there,

I had a server environment (with a shared AWS ElastiCache Memcached node between servers) where some clients were using python-memcached 1.58 and others had upgraded to 1.59 (not pinned versions, unfortunately)

When the 1.58 client attempted to read a key set by 1.59, I get the following exception

mc.get('tz:14059607')
MemCached: unknown flags on get: 10

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/plotwatt/app-deploy/pip/memcache.py", line 1129, in get
    return self._get('get', key)
  File "/usr/local/plotwatt/app-deploy/pip/memcache.py", line 1113, in _get
    return _unsafe_get()
  File "/usr/local/plotwatt/app-deploy/pip/memcache.py", line 1101, in _unsafe_get
    value = self._recv_value(server, flags, rlen)
  File "/usr/local/plotwatt/app-deploy/pip/memcache.py", line 1293, in _recv_value
    raise ValueError('Unknown flags on get: %x' % flags)
ValueError: Unknown flags on get: 10

When upgrading this client to 1.59, the issue no longer occurs:

mc.get('tz:14059607')
u'America/Los_Angeles'

microwavenby avatar Jan 25 '18 20:01 microwavenby

Presumably the incompatibility was introduced by https://github.com/linsomniac/python-memcached/pull/135

dropwhile avatar Jan 25 '18 20:01 dropwhile

The reverse problem also happens: keys set by 1.58 as strings are now returned as bytes on 1.59, breaking code that expects them to be strings.

marcan avatar Dec 01 '19 20:12 marcan