Search code examples
pythonmemcachedpython-memcached

Python memcached set_multi storing issue


I have discovered an issue when trying to store a lot of keys using python-memcached. Here is what I'm doing:

import memcache

# This dict has a 2270 entries that is generated on production server
v = eval(open("/home/dragoon/output").read())
a = memcache.Client(['unix:/tmp/memcached.sock'], debug=1)

Next I'm trying to set all these values:

In [94]: len(a.set_multi(v))                                       
MemCached: MemCache: unix:/tmp/memcached.sock: timed out.  Marking dead.
Out[94]: 2270

The log output of the memcached server:

...
27: going from conn_new_cmd to conn_parse_cmd
<27 set d750bde63a98579f9c2987907aaaf5f8 1 0 18
27: going from conn_parse_cmd to conn_nread
> FOUND KEY d750bde63a98579f9c2987907aaaf5f8
>27 STORED
27: going from conn_nread to conn_write
Failed to write, and not due to blocking: Broken pipe
27: going from conn_write to conn_closing
<27 connection closed.

After some time:

In [96]: len(a.set_multi({'test':1}))
Out[96]: 0

In [97]: a.get('test')
Out[97]: 1

Default timeout is 3 seconds, but increasing it even to 100 seconds doesn't help, memcached is just getting stucked. So, my question is, what is the problem with memcache?

I saw people talking about storing over 1000 000 entries in it, but for me it can't even store 2 000?


Solution

  • Ok. It seems that there is some bug in memcached 1.4.2 that is the last version in Ubuntu 10.04 LTS. Memcached 1.4.5 works fine.