Merge lp:~y-maris/libmemcached/libmemcached into lp:libmemcached

Proposed by Maris Ruskulis
Status: Needs review
Proposed branch: lp:~y-maris/libmemcached/libmemcached
Merge into: lp:libmemcached
Diff against target: 139 lines (+28/-12)
1 file modified
libmemcached/get.cc (+28/-12)
To merge this branch: bzr merge lp:~y-maris/libmemcached/libmemcached
Reviewer Review Type Date Requested Status
Brian Aker Needs Fixing
Tangent Trunk Pending
Review via email: mp+138735@code.launchpad.net

Description of the change

Try next server from replica set if key not found on current, this feature is must have for php session storage and usage with pecl-memcached

To post a comment you must log in.
Revision history for this message
Brian Aker (brianaker) wrote :

Reviewing.

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

As is the patch causes several test failures (looking into it).

Revision history for this message
xoJIog (xojiog) wrote :

> As is the patch causes several test failures (looking into it).
Please include this in mainstream, as memcached redundancy using pecl-memcached is of vital importance to us.

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

Thanks, looking at it.

On Apr 3, 2013, at 4:22 AM, xoJIog <email address hidden> wrote:

>> As is the patch causes several test failures (looking into it).
> Please include this in mainstream, as memcached redundancy using pecl-memcached is of vital importance to us.
> --
> https://code.launchpad.net/~y-maris/libmemcached/libmemcached/+merge/138735
> Your team Tangent is subscribed to branch lp:libmemcached.

Revision history for this message
xoJIog (xojiog) wrote :

bump

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

I just did a merge of this and found that test cases failed when I ran it.

review: Needs Fixing

Unmerged revisions

1084. By Maris Ruskulis

Trying next server if key not found

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libmemcached/get.cc'
2--- libmemcached/get.cc 2012-07-07 10:04:00 +0000
3+++ libmemcached/get.cc 2012-12-07 13:44:57 +0000
4@@ -56,7 +56,7 @@
5 const char * const *keys,
6 const size_t *key_length,
7 size_t number_of_keys,
8- bool mget_mode);
9+ bool mget_mode, char **result, size_t *value_length);
10
11 char *memcached_get_by_key(memcached_st *ptr,
12 const char *group_key,
13@@ -66,6 +66,9 @@
14 uint32_t *flags,
15 memcached_return_t *error)
16 {
17+
18+ char *value;
19+
20 memcached_return_t unused;
21 if (error == NULL)
22 {
23@@ -81,7 +84,7 @@
24 /* Request the key */
25 *error= memcached_mget_by_key_real(ptr, group_key, group_key_length,
26 (const char * const *)&key, &key_length,
27- 1, false);
28+ 1, false, &value, value_length);
29 if (ptr)
30 {
31 assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented.");
32@@ -105,8 +108,6 @@
33 return NULL;
34 }
35
36- char *value= memcached_fetch(ptr, NULL, NULL,
37- value_length, flags, error);
38 assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented.");
39
40 /* This is for historical reasons */
41@@ -191,7 +192,7 @@
42 const char * const *keys,
43 const size_t *key_length,
44 size_t number_of_keys,
45- bool mget_mode);
46+ bool mget_mode, char **result, size_t *value_length);
47
48 static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr,
49 const char *group_key,
50@@ -199,7 +200,7 @@
51 const char * const *keys,
52 const size_t *key_length,
53 size_t number_of_keys,
54- bool mget_mode)
55+ bool mget_mode, char **result, size_t *value_length)
56 {
57 bool failures_occured_in_sending= false;
58 const char *get_command= "get";
59@@ -265,7 +266,7 @@
60 if (memcached_is_binary(ptr))
61 {
62 return binary_mget_by_key(ptr, master_server_key, is_group_key_set, keys,
63- key_length, number_of_keys, mget_mode);
64+ key_length, number_of_keys, mget_mode, result, value_length);
65 }
66
67 if (ptr->flags.support_cas)
68@@ -393,7 +394,7 @@
69 size_t number_of_keys)
70 {
71 return memcached_mget_by_key_real(ptr, group_key, group_key_length, keys,
72- key_length, number_of_keys, true);
73+ key_length, number_of_keys, true, NULL, NULL);
74 }
75
76 memcached_return_t memcached_mget_execute(memcached_st *ptr,
77@@ -583,11 +584,12 @@
78 bool* dead_servers,
79 const char *const *keys,
80 const size_t *key_length,
81- size_t number_of_keys)
82+ size_t number_of_keys, char **result, size_t *value_length)
83 {
84 memcached_return_t rc= MEMCACHED_NOTFOUND;
85 uint32_t start= 0;
86 uint64_t randomize_read= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ);
87+ bool empty_response = false;
88
89 if (randomize_read)
90 {
91@@ -601,8 +603,9 @@
92
93 for (uint32_t x= 0; x < number_of_keys; ++x)
94 {
95- if (hash[x] == memcached_server_count(ptr))
96+ if (hash[x] == memcached_server_count(ptr) && !empty_response){
97 continue; /* Already successfully sent */
98+ }
99
100 uint32_t server= hash[x] + replica;
101
102@@ -671,6 +674,19 @@
103
104 memcached_server_response_increment(instance);
105 hash[x]= memcached_server_count(ptr);
106+
107+ uint32_t flags = 0;
108+ *result = memcached_fetch(ptr, NULL, NULL,
109+ value_length, &flags, &rc);
110+
111+ if(*result == NULL) {
112+ success= false;
113+ empty_response = true;
114+ continue;
115+ }else{
116+ empty_response = false;
117+ success = true;
118+ }
119 }
120
121 if (success)
122@@ -688,7 +704,7 @@
123 const char * const *keys,
124 const size_t *key_length,
125 size_t number_of_keys,
126- bool mget_mode)
127+ bool mget_mode, char **result, size_t *value_length)
128 {
129 if (ptr->number_of_replicas == 0)
130 {
131@@ -722,7 +738,7 @@
132 }
133
134 memcached_return_t rc= replication_binary_mget(ptr, hash, dead_servers, keys,
135- key_length, number_of_keys);
136+ key_length, number_of_keys, result, value_length);
137
138 WATCHPOINT_IFERROR(rc);
139 libmemcached_free(ptr, hash);

Subscribers

People subscribed via source and target branches

to all changes: