I installed memcached on Debian squeeze using the package memcached. The memcached instance starts with 384 MB. Then I try to connect:

jcisio@cecile:~$ telnet 11211
Connected to
Escape character is '^]'.
set mykey 0 60 5
get mykey
CLIENT_ERROR bad data chunk
stats items

What does it means? Normally get mykey should return 5.

The stats command gives

STAT pid 5456
STAT uptime 21334
STAT time 1326180707
STAT version 1.4.5
STAT pointer_size 64
STAT rusage_user 0.168010
STAT rusage_system 0.204012
STAT curr_connections 5
STAT total_connections 9
STAT connection_structures 6
STAT cmd_get 0
STAT cmd_set 1
STAT cmd_flush 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 184
STAT bytes_written 2463
STAT limit_maxbytes 402653184
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT evictions 0
STAT reclaimed 0

Server log with -vv:

<27 server listening (udp)
<28 new auto-negotiating client connection
28: Client using the ascii protocol
<28 set mykey 0 60 5
>28 CLIENT_ERROR bad data chunk
<28 ey
<28 stats items
<28 quit
<28 connection closed.
  • Added result from stats command. – jcisio Jan 10 '12 at 7:34
  • You can start memcached with more verbosity to check for possible erorrs. Use -vv. – Khaled Jan 10 '12 at 8:36
  • I've just added log data. – jcisio Jan 10 '12 at 19:36
  • I see no reason to assume that would return 5. – Dustin Jan 10 '12 at 19:54
  • What happens if you run the get mykey first? – becomingwisest Jan 10 '12 at 19:57

Given the examples at another site, I bet that you didn't set the mykey to the value you expected. And thus your getkey is also failing. Try a get key first, or try deleting the mykey, then using the provided examples.

  • 1
    That's it. I thought "5" was the value, but it was the length of byte block instead. – jcisio Jan 10 '12 at 20:47

Just encountered this error and sadly the responses here weren't sufficient to understand and solve the problem.

From this article (scroll down to "testing the memcached daemon with telnet":

set <key> <flag> <exptime> <bytes>\r\n

The flag is an arbitrary number that you can use in your client logic. It is intended to be metadata that you can assign to each cached object. In the examples this is shown as 1 but here it has no meaning. I set the exptime to zero (never expire), and the bytes to the number of characters I want to store. Note in the last example that if the bytes and the number of characters don't match, an error occurs.

So the root problem here when you see this error is that you're setting the value to something that is larger than the number of bytes you're allocating in the set command.

In the OP's case, 5 bytes are being allocated but the value attempting to be set is "get mykey" which is more than 5 bytes (and also a syntax error, as the OP has stated).

Hopefully this makes it clearer for other memcached newbs like me when they encounter this error and have no clue what it means.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.