Merge lp:~mattknox/libmemcached/twitter-compat into lp:~tangent-org/libmemcached/trunk

Proposed by matt knox
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mattknox/libmemcached/twitter-compat
Merge into: lp:~tangent-org/libmemcached/trunk
Diff against target: None lines
To merge this branch: bzr merge lp:~mattknox/libmemcached/twitter-compat
Reviewer Review Type Date Requested Status
Libmemcached-developers Pending
Review via email: mp+8030@code.launchpad.net
To post a comment you must log in.
Revision history for this message
matt knox (mattknox) wrote :

The code in this branch caches memcached server errors in the memcached_server_st struct to give better visibility into failures. I've tested it both with its own suite and that of the ruby interface to it, and also run it in a development environment. So far it looks fine on all counts.

543. By matt knox

oops! Now I'm using the malloc api, rather than direct malloc

544. By matt knox

removed free

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

> The code in this branch caches memcached server errors in the
> memcached_server_st struct to give better visibility into failures. I've
> tested it both with its own suite and that of the ruby interface to it, and
> also run it in a development environment. So far it looks fine on all counts.

There are a few problems with this.

1) You don't test for memory failures.
2) Lets say you have a failure, how do you know which server it was that had the error?
3) How do you clean up the error (aka reset the error)?
4) There is no function to encapsulate the error message. Which means any future changes to the structure are going to break if any renaming occurs.

I'll clean this up a bit... but something needs to be figured out so that you know via some vector about which servers got errors in the last run.

I can certainly see the usefulness in this for debugging on production sites.

545. By matt knox

corrected a spelling error in libmemcached_examples

Revision history for this message
matt knox (mattknox) wrote :

hey-I just made what I think are some improvements to the twitter-compat
branch. Among other things, I pulled the setting of the cached_server_error
out into its own function. I'll wrap the access also.

On Wed, Jul 15, 2009 at 2:38 AM, Brian Aker <email address hidden> wrote:

> > The code in this branch caches memcached server errors in the
> > memcached_server_st struct to give better visibility into failures. I've
> > tested it both with its own suite and that of the ruby interface to it,
> and
> > also run it in a development environment. So far it looks fine on all
> counts.
>
> There are a few problems with this.
>
> 1) You don't test for memory failures.
> 2) Lets say you have a failure, how do you know which server it was that
> had the error?
> 3) How do you clean up the error (aka reset the error)?
> 4) There is no function to encapsulate the error message. Which means any
> future changes to the structure are going to break if any renaming occurs.
>
> I'll clean this up a bit... but something needs to be figured out so that
> you know via some vector about which servers got errors in the last run.
>
> I can certainly see the usefulness in this for debugging on production
> sites.
>
>
> --
>
> https://code.launchpad.net/~mattknox/libmemcached/twitter-compat/+merge/8030<https://code.launchpad.net/%7Emattknox/libmemcached/twitter-compat/+merge/8030>
> You are the owner of lp:~mattknox/libmemcached/twitter-compat.
>

--
(def (eval e l d c)
 (if (atom? e)
     ((ahandler (type e)) e l d c)
     (eval (car e) l d
             (fun (x)
                (evapp x (cdr e) l d c)))))

Revision history for this message
matt knox (mattknox) wrote :

I've made several changes, including wrapping the cached_server_error in a
function and moving all that out into its own set of files, with docs and
such. How's that look now?

matt

On Wed, Jul 15, 2009 at 2:38 AM, Brian Aker <email address hidden> wrote:

> > The code in this branch caches memcached server errors in the
> > memcached_server_st struct to give better visibility into failures. I've
> > tested it both with its own suite and that of the ruby interface to it,
> and
> > also run it in a development environment. So far it looks fine on all
> counts.
>
> There are a few problems with this.
>
> 1) You don't test for memory failures.
> 2) Lets say you have a failure, how do you know which server it was that
> had the error?
> 3) How do you clean up the error (aka reset the error)?
> 4) There is no function to encapsulate the error message. Which means any
> future changes to the structure are going to break if any renaming occurs.
>
> I'll clean this up a bit... but something needs to be figured out so that
> you know via some vector about which servers got errors in the last run.
>
> I can certainly see the usefulness in this for debugging on production
> sites.
>
>
> --
>
> https://code.launchpad.net/~mattknox/libmemcached/twitter-compat/+merge/8030<https://code.launchpad.net/%7Emattknox/libmemcached/twitter-compat/+merge/8030>
> You are the owner of lp:~mattknox/libmemcached/twitter-compat.
>

--
(def (eval e l d c)
 (if (atom? e)
     ((ahandler (type e)) e l d c)
     (eval (car e) l d
             (fun (x)
                (evapp x (cdr e) l d c)))))

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libmemcached/memcached_response.c'
--- libmemcached/memcached_response.c 2009-06-15 00:51:32 +0000
+++ libmemcached/memcached_response.c 2009-06-29 20:51:23 +0000
@@ -238,7 +238,16 @@
238 return MEMCACHED_STAT;238 return MEMCACHED_STAT;
239 }239 }
240 else if (buffer[1] == 'E')240 else if (buffer[1] == 'E')
241 return MEMCACHED_SERVER_ERROR;241 {
242 /* SERVER_ERROR */
243 char *startptr= buffer + 13, *endptr= startptr;
244 while (*endptr != '\r' && *endptr != '\n') endptr++;
245 if (ptr->cached_server_error) free(ptr->cached_server_error);
246 ptr->cached_server_error= malloc(endptr - startptr + 1);
247 memcpy(ptr->cached_server_error, startptr, endptr - startptr);
248 ptr->cached_server_error[endptr - startptr]= 0;
249 return MEMCACHED_SERVER_ERROR;
250 }
242 else if (buffer[1] == 'T')251 else if (buffer[1] == 'T')
243 return MEMCACHED_STORED;252 return MEMCACHED_STORED;
244 else253 else
245254
=== modified file 'libmemcached/memcached_server.c'
--- libmemcached/memcached_server.c 2009-06-10 10:29:06 +0000
+++ libmemcached/memcached_server.c 2009-06-29 20:51:23 +0000
@@ -53,6 +53,12 @@
53{53{
54 memcached_quit_server(ptr, 0);54 memcached_quit_server(ptr, 0);
5555
56 if (ptr->cached_server_error)
57 {
58 free(ptr->cached_server_error);
59 ptr->cached_server_error= NULL;
60 }
61
56 if (ptr->address_info)62 if (ptr->address_info)
57 {63 {
58 freeaddrinfo(ptr->address_info);64 freeaddrinfo(ptr->address_info);
@@ -70,14 +76,24 @@
70*/76*/
71memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr)77memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr)
72{78{
79 memcached_server_st *rv = NULL;
80
73 /* We just do a normal create if ptr is missing */81 /* We just do a normal create if ptr is missing */
74 if (ptr == NULL)82 if (ptr == NULL)
75 return NULL;83 return NULL;
7684
77 /* TODO We should check return type */85 rv = memcached_server_create_with(ptr->root, clone,
78 return memcached_server_create_with(ptr->root, clone, 86 ptr->hostname, ptr->port, ptr->weight,
79 ptr->hostname, ptr->port, ptr->weight,87 ptr->type);
80 ptr->type);88 if (rv != NULL)
89 {
90 rv->cached_errno= ptr->cached_errno;
91 if (ptr->cached_server_error)
92 rv->cached_server_error= strdup(ptr->cached_server_error);
93 }
94
95 return rv;
96
81}97}
8298
83memcached_return memcached_server_cursor(memcached_st *ptr, 99memcached_return memcached_server_cursor(memcached_st *ptr,
84100
=== modified file 'libmemcached/memcached_server.h'
--- libmemcached/memcached_server.h 2009-05-20 15:58:02 +0000
+++ libmemcached/memcached_server.h 2009-06-29 20:51:23 +0000
@@ -21,6 +21,7 @@
21 unsigned int port;21 unsigned int port;
22 int cached_errno;22 int cached_errno;
23 int fd;23 int fd;
24 char *cached_server_error;
24 uint32_t io_bytes_sent; /* # bytes sent since last read */25 uint32_t io_bytes_sent; /* # bytes sent since last read */
25 uint32_t server_failure_counter;26 uint32_t server_failure_counter;
26 uint32_t weight;27 uint32_t weight;

Subscribers

People subscribed via source and target branches

to all changes: