Skip to content

Commit

Permalink
Merge pull request twitter#637 from twitter/stats-listen
Browse files Browse the repository at this point in the history
Make error messages starting the stats server clearer
  • Loading branch information
TysonAndre authored Jul 4, 2021
2 parents 4700e93 + be8fa00 commit 4cb2e86
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
exactly one server (tyson)
Support memcache 'version' requests by proxying the request to a single
backend memcache server to fetch the server version. (tyson)
Make error messages for creating the stats server during startup clearer. (tyson)

2015-22-06 Manju Rajashekhar <[email protected]>
* twemproxy: version 0.4.1 release
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ Twemproxy can be configured through a YAML file specified by the -c or --conf-fi
+ murmur
+ jenkins
+ **hash_tag**: A two character string that specifies the part of the key used for hashing. Eg "{}" or "$$". [Hash tag](notes/recommendation.md#hash-tags) enable mapping different keys to the same server as long as the part of the key within the tag is the same.
+ **distribution**: The key distribution mode. Possible values are:
+ ketama
+ modula
+ random
+ **distribution**: The key distribution mode for choosing backend servers based on the computed hash value. Possible values are:
+ ketama (default, recommended. An implementation of https://en.wikipedia.org/wiki/Consistent_hashing)
+ modula (use hash modulo number of servers to choose the backend)
+ random (choose a random backend for each key of each request)
+ **timeout**: The timeout value in msec that we wait for to establish a connection to the server or receive a response from a server. By default, we wait indefinitely.
+ **backlog**: The TCP backlog argument. Defaults to 512.
+ **preconnect**: A boolean value that controls if twemproxy should preconnect to all the servers in this pool on process start. Defaults to false.
Expand Down
9 changes: 5 additions & 4 deletions src/nc_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,24 +831,25 @@ stats_listen(struct stats *st)

status = nc_set_reuseaddr(st->sd);
if (status < 0) {
log_error("set reuseaddr on m %d failed: %s", st->sd, strerror(errno));
log_error("set reuseaddr on m %d failed for stats server: %s", st->sd, strerror(errno));
return NC_ERROR;
}

status = bind(st->sd, (struct sockaddr *)&si.addr, si.addrlen);
if (status < 0) {
log_error("bind on m %d to addr '%.*s:%u' failed: %s", st->sd,
log_error("bind on m %d to stats server addr '%.*s:%u' failed: %s", st->sd,
st->addr.len, st->addr.data, st->port, strerror(errno));
return NC_ERROR;
}

status = listen(st->sd, SOMAXCONN);
if (status < 0) {
log_error("listen on m %d failed: %s", st->sd, strerror(errno));
log_error("listen on m %d for stats server '%.*s:%u' failed: %s", st->sd,
st->addr.len, st->addr.data, st->port, strerror(errno));
return NC_ERROR;
}

log_debug(LOG_NOTICE, "m %d listening on '%.*s:%u'", st->sd,
log_debug(LOG_NOTICE, "m %d listening on stats server '%.*s:%u'", st->sd,
st->addr.len, st->addr.data, st->port);

return NC_OK;
Expand Down
1 change: 1 addition & 0 deletions src/proto/nc_memcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,7 @@ memcache_copy_bulk(struct msg *dst, struct msg *src)
for (; p < last && ('\r' != *p); p++) { /* eat cas for gets */
;
}
/* "*p" should be pointing to '\r' */

len += CRLF_LEN * 2;
len += (p - mbuf->pos);
Expand Down

0 comments on commit 4cb2e86

Please sign in to comment.