flush_all is broken?

Martin Blais blais at furius.ca
Sat May 13 21:49:38 UTC 2006


Hello memcached'ers,


This will break with memcached-1.1.12:


#!/usr/bin/env python

# Have some data, will store.
value = ("Some value",)

# Connect to memcached.
import memcache
mc = memcache.Client(['127.0.0.1:11211'], debug=0)

# Flush everything (this triggers the bug).
mc.flush_all()

# Set the value.
mc.set("some_key", value)

# Get it.
newvalue = mc.get("some_key")

# Check that we have what we stored.
assert newvalue == value  ## <-- fails!



Am I missing something about the meaning of flush_all?
I just tested with 1.1.13-pre, and I get the same problem.



Here is the verbose output from the server:

<7 new client connection
<7 flush_all
>7 OK
<7 set some_key 1 0 20
>7 STORED
<7 get some_key
>7 END
<7 connection closed.


(Rummaging in the code)

Ah, found it, the problem is due to the resolution of the
clock (1 second) and the way that the flush_all is
implemented.  It simply sets the oldest's time to NOW, but
the set/get that follow also happen within that second,
and the get is thus ignored.  Looking at it more, I think
that the O(1) flush_all implementation is not possible at
all...

Any commments/info welcome.

cheers,


More information about the memcached mailing list