dragonflydb / dragonfly

A modern replacement for Redis and Memcached
https://www.dragonflydb.io/
Other
25.8k stars 948 forks source link

Incorrect Storage of Flags in DragonflyDB Memcache #2777

Closed badraxas closed 7 months ago

badraxas commented 7 months ago

Describe the bug The bug involves the incorrect storage of flags in DragonflyDB Memcache under certain conditions.

To Reproduce Steps to reproduce the behavior:

$ telnet 127.0.0.1 11211
Connected to localhost.
Escape character is '^]'.

set myKey 3 0 7
myValue
STORED

get myKey 
VALUE myKey 3 7
myValue
END

set myKey 4 0 8
myValue2
STORED

get myKey
VALUE myKey 3 8
myValue2
END

Expected behavior We expected the flag to change to the right value after executing the second set.

Environment (please complete the following information):

r-pierre-viously commented 7 months ago

Hi, I think there is an issue with this condition: https://github.com/dragonflydb/dragonfly/blob/main/src/server/string_family.cc#L659

When the flag was set to zero, the flag is updated, but no more since this is other than zero.

romange commented 7 months ago

Confirming it is a bug - memcached updates the flag for the existing entries.