如何处理MEMCACHED_SERVER_MARKED_DEAD?
我有一个由 10 个内存缓存组成的集群,使用一致性哈希。当在不可用的服务器上搜索传递给 memcached_get()
的密钥时,我仅得到 MEMCACHED_SERVER_MARKED_DEAD
响应(返回值)。
在这种情况下,我希望密钥应该重新分发到下一个可用服务器,并且我应该从下一个 memcached_get()
调用中得到 NOTFOUND
。但是我仍然收到 MEMCACHED_SERVER_MARKED_DEAD
消息,因此无法设置新值。
我发现我可以调用 memcached_behavior_set(..., MEMCACHED_BEHAVIOR_DISTRIBUTION)
。这会导致哈希重新分配,然后它就会按照我的意愿工作。但是,我认为这不是一个好方法。是吗?
I have a cluster of 10 memcaches, using consistent hashing. When the key passed to memcached_get()
is searched on the unavailable server I get just MEMCACHED_SERVER_MARKED_DEAD
response (return value).
I would expect the key should be redistributed to the next available server in this case and I should get NOTFOUND
from the next memcached_get()
call. However I'm still getting MEMCACHED_SERVER_MARKED_DEAD
and so I'm unable to set a new value.
I discovered I can call memcached_behavior_set(..., MEMCACHED_BEHAVIOR_DISTRIBUTION)
. This causes hash redistribution and it works as I wish then. However, I do not think it is a good approach. Is it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,如果您正在处理多个 memcached 池,您希望从一开始就启用 MEMCACHED_BEHAVIOR_DISTRIBUTION。所以是的,这个解决方案会起作用。
如果您遇到其他问题,请查看 MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS,它将在 x 次失败后自动从池中清除失败的服务器。
Generally you want to enable MEMCACHED_BEHAVIOR_DISTRIBUTION from the start if you are dealing with multiple memcached pools. So yes that solution will work.
If you are having further problems, take a look at MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS that will auto purge failed servers from pool after x number of failures.
我自己找到了答案。
https://bugs.launchpad.net/libmemcached/+bug/777672 补丁解决了我所有的问题。注意,我想知道它从 0.39 开始就被破坏了,而且没有人关心。
I found the answer myself.
https://bugs.launchpad.net/libmemcached/+bug/777672
Applying the patch solved all my problems. Note, I wonder it has beed broken since 0.39 and nobody has cared.