MINOR: server: introduce "log-bufsize" kw

"log-bufsize" may now be used for a log server (in a log backend) to
configure the bufsize of implicit ring associated to the server (which
defaults to BUFSIZE).
This commit is contained in:
Aurelien DARRAGON 2023-10-04 10:32:45 +02:00 committed by Christopher Faulet
parent 7e70b8858f
commit 94d0f77deb
4 changed files with 34 additions and 1 deletions

View File

@ -16176,6 +16176,14 @@ downinter <delay>
"inter" setting will have a very limited effect as it will not be able to
reduce the time spent in the queue.
log-bufsize <bufsize>
The "log-bufsize" specifies the ring bufsize to use for the implicit ring
that will be associated to the log server in a log backend. When not
specified, this defaults to BUFSIZE. Use of a greater value will increase
memory usage but can help to prevent the loss of log messages with slow
servers since the buffer will be able to hold more pending messages.
This keyword may only be used in log backend sections (with "mode log")
log-proto <logproto>
The "log-proto" specifies the protocol used to forward event messages to
a server configured in a log or ring section. Possible values are "legacy"

View File

@ -306,6 +306,7 @@ struct server {
unsigned cumulative_weight; /* weight of servers prior to this one in the same group, for chash balancing */
int maxqueue; /* maximum number of pending connections allowed */
int shard; /* shard (in peers protocol context only) */
int log_bufsize; /* implicit ring bufsize (for log server only - in log backend) */
enum srv_ws_mode ws; /* configure the protocol selection for websocket */
/* 3 bytes hole here */

View File

@ -760,6 +760,27 @@ static int srv_parse_init_addr(char **args, int *cur_arg,
return 0;
}
/* Parse the "log-bufsize" server keyword */
static int srv_parse_log_bufsize(char **args, int *cur_arg,
struct proxy *curproxy, struct server *newsrv, char **err)
{
if (!*args[*cur_arg + 1]) {
memprintf(err, "'%s' expects an integer argument.",
args[*cur_arg]);
return ERR_ALERT | ERR_FATAL;
}
newsrv->log_bufsize = atoi(args[*cur_arg + 1]);
if (newsrv->log_bufsize <= 0) {
memprintf(err, "%s has to be > 0.",
args[*cur_arg]);
return ERR_ALERT | ERR_FATAL;
}
return 0;
}
/* Parse the "log-proto" server keyword */
static int srv_parse_log_proto(char **args, int *cur_arg,
struct proxy *curproxy, struct server *newsrv, char **err)
@ -1901,6 +1922,7 @@ static struct srv_kw_list srv_kws = { "ALL", { }, {
{ "ws", srv_parse_ws, 1, 1, 1 }, /* websocket protocol */
{ "id", srv_parse_id, 1, 0, 1 }, /* set id# of server */
{ "init-addr", srv_parse_init_addr, 1, 1, 0 }, /* */
{ "log-bufsize", srv_parse_log_bufsize, 1, 1, 0 }, /* Set the ring bufsize for log server (only for log backends) */
{ "log-proto", srv_parse_log_proto, 1, 1, 0 }, /* Set the protocol for event messages, only relevant in a log or ring section */
{ "maxconn", srv_parse_maxconn, 1, 1, 1 }, /* Set the max number of concurrent connection */
{ "maxqueue", srv_parse_maxqueue, 1, 1, 1 }, /* Set the max number of connection to put in queue */
@ -2421,6 +2443,7 @@ void srv_settings_cpy(struct server *srv, const struct server *src, int srv_tmpl
srv->netns = src->netns;
srv->check.via_socks4 = src->check.via_socks4;
srv->socks4_addr = src->socks4_addr;
srv->log_bufsize = src->log_bufsize;
}
/* allocate a server and attach it to the global servers_list. Returns

View File

@ -1266,6 +1266,7 @@ struct sink *sink_new_from_logger(struct logger *logger)
struct sink *sink_new_from_srv(struct server *srv, const char *from)
{
struct sink *sink = NULL;
int bufsize = (srv->log_bufsize) ? srv->log_bufsize : BUFSIZE;
/* prepare description for the sink */
chunk_reset(&trash);
@ -1274,7 +1275,7 @@ struct sink *sink_new_from_srv(struct server *srv, const char *from)
/* directly create a sink of BUF type, and use UNSPEC log format to
* inherit from caller fmt in sink_write()
*/
sink = sink_new_buf(srv->id, trash.area, LOG_FORMAT_UNSPEC, BUFSIZE);
sink = sink_new_buf(srv->id, trash.area, LOG_FORMAT_UNSPEC, bufsize);
if (!sink) {
ha_alert("unable to create a new sink buffer for server '%s'.\n", srv->id);
goto error;