2013-02-28 14:05:05 |
Martin C. Martin |
description |
When I restart my memcached server, libmemcached never reconnects as long as I'm continuously trying to send data to it. If the client stops activity for a few seconds then starts sending again, the reconnection happens just fine.
It turns out to be a problem with how next_rety is set. Even when we don't try to connect because it's too soon, we still update next_retry.
That's because the socket is invalid, so the server state is MEMCACHED_SERVER_STATE_NEW, not MEMCACHED_SERVER_STATE_IN_TIMEOUT. memcached_mark_server_for_timeout() only skips updating next_retry in the latter state, not the former.
I'm not sure what the right solution is here. Maybe make memcached_quit_server() idempotent by checking for MEMCACHED_SERVER_STATE_NEW or fd == INVALID_SOCKET at the start and returing right away? I'm reluctant to do the same in memcached_mark_server_for_timeout(), in case that skips setting it when we really do need to set it. |
When I restart my memcached server, libmemcached never reconnects as long as I'm continuously trying to send data to it. If the client stops activity for a few seconds then starts sending again, the reconnection happens just fine.
It turns out to be a problem with how next_rety is set. Even when we don't try to connect because it's too soon, we still update next_retry.
That's because the socket is invalid, so the server state is MEMCACHED_SERVER_STATE_NEW, not MEMCACHED_SERVER_STATE_IN_TIMEOUT. memcached_mark_server_for_timeout() only skips updating next_retry in the latter state, not the former.
I'm not sure what the right solution is here. Maybe make memcached_quit_server() idempotent by checking for MEMCACHED_SERVER_STATE_NEW at the start and returing right away? I'm reluctant to do the same in memcached_mark_server_for_timeout(), in case that skips setting it when we really do need to set it. |
|