flush_all caveat

Peter van Dijk peter at nextgear.nl
Tue Jan 17 13:53:17 UTC 2006


Hi,

from protocol.txt:
<quote>
The most precise definition
of what flush_all does is the following: it causes all items whose
update time is earlier than the time at which flush_all was set to be
executed to be ignored for retrieval purposes.
</quote>

However, this 'time' is measured in full seconds. An illustration
of unexpected behaviour:
-bash-2.05b$ ( echo -ne 'flush_all\r\nset habbietest1 0 0 1\r\ny\r\nget habbietest1\r\nquit\r\n' )| nc localhost 11211 
OK
STORED
END

Illustrating the whole-second difference:
-bash-2.05b$ ( echo -ne 'flush_all\r\n' ; sleep 1; echo -ne 'set habbietest1 0 0 1\r\ny\r\nget habbietest1\r\nquit\r\n' )| nc localhost 11211 
OK
STORED
VALUE habbietest1 0 1
y
END



Of course, as memcached is a 'cache' it is in fact allowed to lose
items for no reason at all - but this behaviour *looks* so weird
that I wanted to report it as a caveat, as this can come up in
debugging and confuse developers.

One 'fix/workaround' could be to not report STORED - as memcached
can know at that time that the object will never ever be served,
by just comparing timestamps.

A real fix would be to use some incremental counter instead of
a timestamp, or other implementations I can't think of right now -
but this is not worth the trouble I think.

Regards,
Peter van Dijk


More information about the memcached mailing list