Fixes a SERVER_ERROR when value length is just under the max value length#272
Fixes a SERVER_ERROR when value length is just under the max value length#272mgetz wants to merge 2 commits into3rd-Eden:masterfrom
Conversation
There was a problem hiding this comment.
A comment explaining the logic behind this (and the magic constant that is 71) would be appreciated :)
There was a problem hiding this comment.
Documentation I found said that 71 is the length of the metadata that memcache uses to store information about each key value pair. That may need to be adjusted or set as a system variable.
There was a problem hiding this comment.
Something to keep in mind is that memcache clients can also talk to Couchbase servers. I don't know what the limitations are there? In any case, I think a code comment or well chosen constant name would be nice.
There was a problem hiding this comment.
Thank you for the tips. We use it with both memcached and couchbase ourselves. I will do a bit more research and tweak the code accordingly.
Thanks!
There is a small window of value size just under the max value size that causes a SERVER_ERROR. That window is the key length + the length of meta data stored with the key value pair. When the value size is over the max value length, the driver nicely throws an error back to the client without causing the SERVER_ERROR. This closes that small window that is left.
I hardcoded in the size of the metadata that I found on my system but I am not sure that is correct for all systems. The places where I found the meta data length mentioned cited a shorter length for most systems so hopefully this takes care of those systems as well with only a few bytes of unusable space.