twemproxy icon indicating copy to clipboard operation
twemproxy copied to clipboard

stray message on server connection if \0 in the key for memcache

Open allenlz opened this issue 10 years ago • 3 comments

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

allenlz avatar May 10 '14 16:05 allenlz

@idning is this still a problem with support for empty keys?

manjuraj avatar Dec 10 '14 18:12 manjuraj

@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

idning avatar Dec 11 '14 03:12 idning

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)

TysonAndre avatar Jul 01 '21 23:07 TysonAndre