Merge lp:~jc.redoutey/libmemcached/failure_number_fix into lp:~tangent-org/libmemcached/trunk

Proposed by JC Redoutey
Status: Work in progress
Proposed branch: lp:~jc.redoutey/libmemcached/failure_number_fix
Merge into: lp:~tangent-org/libmemcached/trunk
Diff against target: 131 lines
2 files modified
libmemcached/memcached_quit.c (+8/-8)
tests/function.c (+54/-0)
To merge this branch: bzr merge lp:~jc.redoutey/libmemcached/failure_number_fix
Reviewer Review Type Date Requested Status
Brian Aker Needs Fixing
Review via email: mp+13167@code.launchpad.net
To post a comment you must log in.
Revision history for this message
JC Redoutey (jc.redoutey) wrote :

This small patch aims at preventing increasing the retry counter when quitting a memcached server is intentional.

Revision history for this message
Brian Aker (brianaker) :
review: Approve
Revision history for this message
Brian Aker (brianaker) wrote :

This is causing random test failures once applied to my local Fedora box. Don't you want to clone the memc in the test?

review: Needs Fixing
601. By Jean-Charles Redoutey <jc@Jayce2009lnx>

now cloning memcached_st

Revision history for this message
Brian Aker (brianaker) wrote :

So how does this test compare to what we already have? (Which looks to be incomplete, so I suspect this is better).

BTW I will work out an example in the tests which allow you to have memcached_st release all but one server.

Revision history for this message
Brian Aker (brianaker) wrote :

I've extracted this test case (it passes and does show different behavior from the current version). Thanks.

Unmerged revisions

601. By Jean-Charles Redoutey <jc@Jayce2009lnx>

now cloning memcached_st

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libmemcached/memcached_quit.c'
--- libmemcached/memcached_quit.c 2009-07-18 17:37:40 +0000
+++ libmemcached/memcached_quit.c 2009-10-12 19:59:10 +0000
@@ -2,10 +2,10 @@
22
3/*3/*
4 This closes all connections (forces flush of input as well).4 This closes all connections (forces flush of input as well).
5 5
6 Maybe add a host specific, or key specific version? 6 Maybe add a host specific, or key specific version?
7 7
8 The reason we send "quit" is that in case we have buffered IO, this 8 The reason we send "quit" is that in case we have buffered IO, this
9 will force data to be completed.9 will force data to be completed.
10*/10*/
1111
@@ -18,7 +18,7 @@
18 memcached_return rc;18 memcached_return rc;
19 char buffer[MEMCACHED_MAX_BUFFER];19 char buffer[MEMCACHED_MAX_BUFFER];
2020
21 if (ptr->root->flags & MEM_BINARY_PROTOCOL) 21 if (ptr->root->flags & MEM_BINARY_PROTOCOL)
22 {22 {
23 protocol_binary_request_quit request = {.bytes= {0}};23 protocol_binary_request_quit request = {.bytes= {0}};
24 request.message.header.request.magic = PROTOCOL_BINARY_REQ;24 request.message.header.request.magic = PROTOCOL_BINARY_REQ;
@@ -30,7 +30,7 @@
30 rc= memcached_do(ptr, "quit\r\n", 6, 1);30 rc= memcached_do(ptr, "quit\r\n", 6, 1);
3131
32 WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED);32 WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED);
33 33
34 /* read until socket is closed, or there is an error34 /* read until socket is closed, or there is an error
35 * closing the socket before all data is read35 * closing the socket before all data is read
36 * results in server throwing away all data which is36 * results in server throwing away all data which is
@@ -49,14 +49,14 @@
49 memcached_server_response_reset(ptr);49 memcached_server_response_reset(ptr);
50 }50 }
5151
52 ptr->server_failure_counter++;52 if(io_death) ptr->server_failure_counter++;
53}53}
5454
55void memcached_quit(memcached_st *ptr)55void memcached_quit(memcached_st *ptr)
56{56{
57 unsigned int x;57 unsigned int x;
5858
59 if (ptr->hosts == NULL || 59 if (ptr->hosts == NULL ||
60 ptr->number_of_hosts == 0)60 ptr->number_of_hosts == 0)
61 return;61 return;
6262
6363
=== modified file 'tests/function.c'
--- tests/function.c 2009-10-12 16:10:17 +0000
+++ tests/function.c 2009-10-12 19:59:10 +0000
@@ -4732,6 +4732,7 @@
4732 return TEST_SUCCESS;4732 return TEST_SUCCESS;
4733}4733}
47344734
4735<<<<<<< TREE
47354736
47364737
4737/* Test memcached_server_get_last_disconnect4738/* Test memcached_server_get_last_disconnect
@@ -4786,6 +4787,58 @@
4786}4787}
47874788
47884789
4790=======
4791
4792/*
4793 * This tests ensures expected disconnections (for some behavior changes
4794 * for instance) do not wrongly increase failure counter
4795 */
4796static test_return_t wrong_failure_counter_test(memcached_st *memc)
4797{
4798 memcached_return rc;
4799
4800 memcached_st *memc_clone;
4801 memc_clone= memcached_clone(NULL, memc);
4802 assert(memc_clone);
4803
4804 /* Set value to force connection to the server */
4805 const char *key= "marmotte";
4806 const char *value= "milka";
4807 char *string = NULL;
4808 size_t string_length;
4809 uint32_t flags;
4810
4811 rc= memcached_set(memc_clone, key, strlen(key),
4812 value, strlen(value),
4813 (time_t)0, (uint32_t)0);
4814 assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
4815
4816
4817 /* put failure limit to 1 */
4818 rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, 1);
4819 assert(rc == MEMCACHED_SUCCESS);
4820 /* Put a retry timeout to effectively activate failure_limit effect */
4821 rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 1);
4822 assert(rc == MEMCACHED_SUCCESS);
4823 /* change behavior that triggers memcached_quit()*/
4824 rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
4825 assert(rc == MEMCACHED_SUCCESS);
4826
4827
4828 /* Check if we still are connected */
4829 string= memcached_get(memc_clone, key, strlen(key),
4830 &string_length, &flags, &rc);
4831
4832 assert(rc == MEMCACHED_SUCCESS);
4833 assert(string);
4834 free(string);
4835
4836 return TEST_SUCCESS;
4837}
4838
4839
4840
4841>>>>>>> MERGE-SOURCE
4789test_st udp_setup_server_tests[] ={4842test_st udp_setup_server_tests[] ={
4790 {"set_udp_behavior_test", 0, set_udp_behavior_test},4843 {"set_udp_behavior_test", 0, set_udp_behavior_test},
4791 {"add_tcp_server_udp_client_test", 0, add_tcp_server_udp_client_test},4844 {"add_tcp_server_udp_client_test", 0, add_tcp_server_udp_client_test},
@@ -4930,6 +4983,7 @@
4930 {"user_supplied_bug19", 1, user_supplied_bug19 },4983 {"user_supplied_bug19", 1, user_supplied_bug19 },
4931 {"user_supplied_bug20", 1, user_supplied_bug20 },4984 {"user_supplied_bug20", 1, user_supplied_bug20 },
4932 {"user_supplied_bug21", 1, user_supplied_bug21 },4985 {"user_supplied_bug21", 1, user_supplied_bug21 },
4986 {"wrong_failure_counter_test", 1, wrong_failure_counter_test},
4933 {0, 0, 0}4987 {0, 0, 0}
4934};4988};
49354989

Subscribers

People subscribed via source and target branches

to all changes: