twemproxy
twemproxy copied to clipboard
stray message on server connection if \0 in the key for memcache
Example: echo -en "set a\0 0 0 1\r\na\r\n"
\0 is invalid in the key for memcache. If \0 is included, memcache will return 'ERROR' before continue to read the data in the connection. It will cause twemproxy to find stray message. This case is much like #149 .
In most cases, client side should do the validation for the key. However, its also needed to check the key again in twemproxy. Because, if twemproxy find stray message, it will close the server connection. 'Doing so would affect other clients that have request pending/outstanding on this given server connection.'
The fix is simple. https://github.com/allenlz/twemproxy/commit/5fddf251919a402f30690651ff20439c3fbbf34d
@idning is this still a problem with support for empty keys?
@manjuraj @allenlz this is not empty key but '\0' in the key. (redis support '\0' in the key but memcache ascii protocol does not)
I will merge this PR latter
I'm able to reproduce that
In most cases, client side should do the validation for the key.
I see - so twemproxy should close the connection to the client if it sees \0
or \n
in a key or argument (memcached handles \n
differently from twemproxy, which looks for \r
)