#define MEMCACHED_SERVER_FAILURE_LIMIT 5
#define MEMCACHED_SERVER_FAILURE_RETRY_TIMEOUT 2
#define MEMCACHED_SERVER_FAILURE_DEAD_TIMEOUT 0
-
+#define MEMCACHED_SERVER_TIMEOUT_LIMIT 0
int32_t snd_timeout;
int32_t rcv_timeout;
uint32_t server_failure_limit;
+ uint32_t server_timeout_limit;
uint32_t io_msg_watermark;
uint32_t io_bytes_watermark;
uint32_t io_key_prefetch;
uint32_t request_id;
uint32_t server_failure_counter;
uint64_t server_failure_counter_query_id;
+ uint32_t server_timeout_counter;
+ uint64_t server_timeout_counter_query_id;
uint32_t weight;
uint32_t version;
enum memcached_server_state_t state;
MEMCACHED_BEHAVIOR_LOAD_FROM_FILE,
MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS,
MEMCACHED_BEHAVIOR_DEAD_TIMEOUT,
+ MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT,
MEMCACHED_BEHAVIOR_MAX
};
ptr->server_failure_limit= uint32_t(data);
break;
+ case MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT:
+ ptr->server_timeout_limit= uint32_t(data);
+ break;
+
case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL:
send_quit(ptr); // We need t shutdown all of the connections to make sure we do the correct protocol
if (data)
case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT:
return ptr->server_failure_limit;
+ case MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT:
+ return ptr->server_timeout_limit;
+
case MEMCACHED_BEHAVIOR_SORT_HOSTS:
return ptr->flags.use_sort_hosts;
if (_gettime_success and server->next_retry < curr_time.tv_sec)
{
server->state= MEMCACHED_SERVER_STATE_NEW;
+ server->server_timeout_counter= 0;
}
else
{
self->request_id= 0;
self->server_failure_counter= 0;
self->server_failure_counter_query_id= 0;
+ self->server_timeout_counter= 0;
+ self->server_timeout_counter_query_id= 0;
self->weight= weight ? weight : 1; // 1 is the default weight value
self->io_wait_count.read= 0;
self->io_wait_count.write= 0;
void mark_server_as_clean()
{
server_failure_counter= 0;
+ server_timeout_counter= 0;
next_retry= 0;
}
uint32_t request_id;
uint32_t server_failure_counter;
uint64_t server_failure_counter_query_id;
+ uint32_t server_timeout_counter;
+ uint32_t server_timeout_counter_query_id;
uint32_t weight;
uint32_t version;
enum memcached_server_state_t state;
self->snd_timeout= 0;
self->rcv_timeout= 0;
self->server_failure_limit= MEMCACHED_SERVER_FAILURE_LIMIT;
+ self->server_timeout_limit= MEMCACHED_SERVER_TIMEOUT_LIMIT;
self->query_id= 1; // 0 is considered invalid
/* TODO, Document why we picked these defaults */
new_clone->get_key_failure= source->get_key_failure;
new_clone->delete_trigger= source->delete_trigger;
new_clone->server_failure_limit= source->server_failure_limit;
+ new_clone->server_timeout_limit= source->server_timeout_limit;
new_clone->io_msg_watermark= source->io_msg_watermark;
new_clone->io_bytes_watermark= source->io_bytes_watermark;
new_clone->io_key_prefetch= source->io_key_prefetch;
* sent to the server.
*/
instance->server_failure_counter= 0;
+ instance->server_timeout_counter= 0;
}
}
self->request_id= 0;
self->server_failure_counter= 0;
self->server_failure_counter_query_id= 0;
+ self->server_timeout_counter= 0;
+ self->server_timeout_counter_query_id= 0;
self->weight= weight ? weight : 1; // 1 is the default weight value
self->io_wait_count.read= 0;
self->io_wait_count.write= 0;
{
if (server->state != MEMCACHED_SERVER_STATE_IN_TIMEOUT)
{
- if (server->root->retry_timeout != 0)
+ if (server->server_timeout_counter_query_id != server->root->query_id)
+ {
+ server->server_timeout_counter++;
+ server->server_timeout_counter_query_id= server->root->query_id;
+ }
+
+ if (server->server_timeout_counter >= server->root->server_timeout_limit)
{
struct timeval next_time;
if (gettimeofday(&next_time, NULL) == 0)
}
server->state= MEMCACHED_SERVER_STATE_IN_TIMEOUT;
+ if (server->server_failure_counter_query_id != server->root->query_id)
+ {
+ server->server_failure_counter++;
+ server->server_failure_counter_query_id= server->root->query_id;
+ }
+ set_last_disconnected_host(server);
}
- if (server->server_failure_counter_query_id != server->root->query_id)
- {
- server->server_failure_counter++;
- server->server_failure_counter_query_id= server->root->query_id;
- }
- set_last_disconnected_host(server);
}
}
test_true(memc_clone->retry_timeout == memc->retry_timeout);
test_true(memc_clone->send_size == memc->send_size);
test_true(memc_clone->server_failure_limit == memc->server_failure_limit);
+ test_true(memc_clone->server_timeout_limit == memc->server_timeout_limit);
test_true(memc_clone->snd_timeout == memc->snd_timeout);
test_true(memc_clone->user_data == memc->user_data);