]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
14 years ago[MEDIUM] stats: add the ability to adjust the global maxconnrate
Willy Tarreau [Wed, 7 Sep 2011 14:13:44 +0000 (16:13 +0200)] 
[MEDIUM] stats: add the ability to adjust the global maxconnrate

Using "set rate-limit connections global <xxx>" on the CLI, we can now
adjust the per-process connection rate limiting (equal to global.maxconnrate).

14 years ago[MINOR] stats: report the current and max global connection rates
Willy Tarreau [Wed, 7 Sep 2011 13:26:48 +0000 (15:26 +0200)] 
[MINOR] stats: report the current and max global connection rates

The HTML page reports the current process connection rate, and the
"show info" command on the stats socket also reports the conn rate
limit and the max conn rate that was once reached.

Note that the max value can be cleared using "clear counters".

14 years ago[MEDIUM] add support for global.maxconnrate to limit the per-process conn rate.
Willy Tarreau [Wed, 7 Sep 2011 13:17:21 +0000 (15:17 +0200)] 
[MEDIUM] add support for global.maxconnrate to limit the per-process conn rate.

This one enforces a per-process connection rate limit, regardless of what
may be set per frontend. It can be a way to limit the CPU usage of a process
being severely attacked.

The side effect is that the global process connection rate is now measured
for each incoming connection, so it will be possible to report it.

14 years ago[MEDIUM] stats: add the "set maxconn" setting to the command line interface
Willy Tarreau [Wed, 7 Sep 2011 12:38:31 +0000 (14:38 +0200)] 
[MEDIUM] stats: add the "set maxconn" setting to the command line interface

This option permits to change the global maxconn setting within the
limit that was set by the initial value, which is now reported as the
hard maxconn value. This allows to immediately accept more concurrent
connections or to stop accepting new ones until the value passes below
the indicated setting.

The main use of this option is on systems where many haproxy instances
are loaded and admins need to re-adjust resource sharing at run time
to regain a bit of fairness between processes.

14 years ago[CLEANUP] remove a useless test in manage_global_listener_queue()
Willy Tarreau [Wed, 7 Sep 2011 12:26:33 +0000 (14:26 +0200)] 
[CLEANUP] remove a useless test in manage_global_listener_queue()

The test for the empty list was done twice.

14 years ago[MEDIUM] stats: disable complex socket reservation for stats socket
Willy Tarreau [Wed, 7 Sep 2011 10:13:34 +0000 (12:13 +0200)] 
[MEDIUM] stats: disable complex socket reservation for stats socket

The way the unix socket is initialized is awkward. Some of the settings are put
in the sockets itself, other ones in the backend. And more importantly the
global.maxsock value is adjusted so that the stats socket evades the global
maxconn value. This complexifies maxsock computations for nothing, since the
stats socket is not supposed to receive hundreds of concurrent connections when
the global maxconn is very low. What is needed however is to ensure that there
are always connections left for the stats socket even when traffic sockets are
saturated, but this guarantee is not offered anymore by current code.

So as of now, the stats socket is subject to the global maxconn limitation just
as any other socket until a reservation mechanism is implemented.

14 years ago[CLEANUP] remove dirty left-over of a debugging message
Willy Tarreau [Wed, 7 Sep 2011 09:55:40 +0000 (11:55 +0200)] 
[CLEANUP] remove dirty left-over of a debugging message

This debug message was added in commit e9b2602a and not noticed once
committed.

14 years ago[MINOR] halog: support backslash-escaped quotes
Willy Tarreau [Tue, 6 Sep 2011 06:11:27 +0000 (08:11 +0200)] 
[MINOR] halog: support backslash-escaped quotes

Some syslog servers escape quotes, which make the resulting logs unusable
for URL processing since the parser looks for the first field beginning
with a quote. It now supports also fields starting with backslash and
quote in order to address this. No performance impact was measured.

14 years ago[MINOR] halog: add -hs/-HS to filter by HTTP status code range
Willy Tarreau [Mon, 5 Sep 2011 00:07:23 +0000 (02:07 +0200)] 
[MINOR] halog: add -hs/-HS to filter by HTTP status code range

The code was merged with the error code checking which is very similar and
which shares the same information. The new test adds about 1% slowdown to
error checking but makes it more reliable when facing wrongly formated
status codes.

14 years ago[CLEANUP] cfgparse: fix reported options for the "bind" keyword
Willy Tarreau [Sun, 4 Sep 2011 23:17:06 +0000 (01:17 +0200)] 
[CLEANUP] cfgparse: fix reported options for the "bind" keyword

14 years ago[DOC] add a few old and uncommitted docs
Willy Tarreau [Sun, 4 Sep 2011 23:04:44 +0000 (01:04 +0200)] 
[DOC] add a few old and uncommitted docs

These docs were still lying in my directory uncommitted. They're not
very important but can be useful for developers who seek info about
internals.

14 years ago[MINOR] http: take a capture of bad content-lengths.
Willy Tarreau [Fri, 2 Sep 2011 18:33:27 +0000 (20:33 +0200)] 
[MINOR] http: take a capture of bad content-lengths.

Sometimes a bad content-length header is encountered and this causes
an abort. It's hard to debug without a trace, so let's take a capture
of the contents when this happens.

14 years ago[MINOR] http: take a capture of truncated responses
Willy Tarreau [Fri, 2 Sep 2011 18:16:24 +0000 (20:16 +0200)] 
[MINOR] http: take a capture of truncated responses

If a server starts to respond but stops before the body, then we
capture the truncated response. We don't do this on the request
because it would happen too often upon stupid attacks.

14 years ago[MINOR] http: take a capture of too large requests and responses
Willy Tarreau [Fri, 2 Sep 2011 18:04:57 +0000 (20:04 +0200)] 
[MINOR] http: take a capture of too large requests and responses

It's hard to prove a request or response is too large if there is no
capture, so let's take a snapshot of those too.

14 years ago[MINOR] stats: display "<NONE>" instead of the frontend name when unknown
Willy Tarreau [Fri, 2 Sep 2011 15:33:05 +0000 (17:33 +0200)] 
[MINOR] stats: display "<NONE>" instead of the frontend name when unknown

"show sess" should display "<NONE>" instead of the frontend's name as
the backend's.

14 years ago[BUG] http: trailing white spaces must also be trimmed after headers
Willy Tarreau [Thu, 1 Sep 2011 20:22:28 +0000 (22:22 +0200)] 
[BUG] http: trailing white spaces must also be trimmed after headers

Trailing spaces after headers were not trimmed, only the leading ones
were. An issue was detected today with a content-length value which
was padded with spaces and which was rejected. Recent updates to the
http-bis draft made it a lot more clear that such spaces must be ignored,
so this is what this patch does.

It should be backported to 1.4.

14 years ago[MINOR] make use of addr_to_str() and get_host_port() to replace many inet_ntop()
Willy Tarreau [Sun, 4 Sep 2011 22:36:48 +0000 (00:36 +0200)] 
[MINOR] make use of addr_to_str() and get_host_port() to replace many inet_ntop()

Many inet_ntop calls were partially right, which was hard to detect given
the complex combinations. Some of them were relying on the listener's proto
instead of the address itself, which could have been different when dealing
with an accept-proxy connection.

The new addr_to_str() function does the dirty job and returns the family, which
makes it particularly suited to calls from switch/case statements. A large number
of if/else statements were removed and the stats output could even be cleaned up
in the case of session dump.

As a side effect of doing this, the resulting code is smaller by almost 1kB.
All changed parts have been tested and provided expected output.

14 years ago[DOC] fixed a few "sensible" -> "sensitive" errors
Willy Tarreau [Sun, 28 Aug 2011 07:45:47 +0000 (09:45 +0200)] 
[DOC] fixed a few "sensible" -> "sensitive" errors

Similar words in different languages meaning different things...
Reported by Bryce Jasmer.

14 years ago[MINOR] make use of set_host_port() and get_host_port() to get rid of family mismatches
Willy Tarreau [Sat, 27 Aug 2011 10:29:07 +0000 (12:29 +0200)] 
[MINOR] make use of set_host_port() and get_host_port() to get rid of family mismatches

This also simplifies the code and makes it more auditable.

14 years ago[BUG] backend: risk of picking a wrong port when mapping is used with crossed families
Willy Tarreau [Sat, 27 Aug 2011 10:07:49 +0000 (12:07 +0200)] 
[BUG] backend: risk of picking a wrong port when mapping is used with crossed families

A similar issue as the previous one causes port mapping to fail in some
combinations of client and server address families. Using the macros fixes
the issue.

14 years ago[BUG] checks: use the correct destination port for sending checks
Willy Tarreau [Sat, 27 Aug 2011 09:51:36 +0000 (11:51 +0200)] 
[BUG] checks: use the correct destination port for sending checks

In the number of switch/case statements added for IPv6 changes,
one was wrong and caused the check port to be ignored for outgoing
connection because the socket's family was not taken at the right
place. Use the set_host_port() macro instead to fix the issue.

The same cleanup could be performed at a number of other places
and should follow shortly.

Special thanks to Stephane Bakhos of Techboom for reporting a
detailed analysis of this bug.

14 years ago[BUG] possible crash in 'show table' on stats socket
Willy Tarreau [Wed, 24 Aug 2011 06:23:34 +0000 (08:23 +0200)] 
[BUG] possible crash in 'show table' on stats socket

Patch d5b9fd95 was missing an initialisation of "ctx.table.target", which caused
"show table" to segfault if it was issued after a "show errors" (target pointer == -1).

14 years ago[CLEANUP] update the year in the copyright banner
Willy Tarreau [Mon, 22 Aug 2011 22:23:54 +0000 (00:23 +0200)] 
[CLEANUP] update the year in the copyright banner

It was still 2010 !

14 years ago[REORG] build: move syscall redefinition to specific places
Willy Tarreau [Mon, 22 Aug 2011 15:12:02 +0000 (17:12 +0200)] 
[REORG] build: move syscall redefinition to specific places

Some older libc don't define splice() and and don't define _syscall*()
either, which causes build errors if splicing is enabled.

To solve this, we now split the syscall redefinition into two layers :
  - one file per syscall (epoll, splice)
  - one common file to declare the _syscall*() macros

The code is cleaner because files using the syscalls just have to include
their respective file. It's not adviced to merge multiple syscall families
into a same file if all are not intended to be used simultaneously, because
defining unused static functions causes warnings to be emitted during build.

As a result, the new USE_MY_SPLICE parameter was added in order to be able
to define the splice() syscall separately.

14 years ago[MEDIUM] http: make x-forwarded-for addition conditional
Willy Tarreau [Fri, 19 Aug 2011 20:57:24 +0000 (22:57 +0200)] 
[MEDIUM] http: make x-forwarded-for addition conditional

If "option forwardfor" has the "if-none" argument, then the header is
only added when the request did not already have one. This option has
security implications, and should not be set blindly.

14 years ago[BUG] check: http-check expect + regex would crash in defaults section
Willy Tarreau [Fri, 19 Aug 2011 18:04:17 +0000 (20:04 +0200)] 
[BUG] check: http-check expect + regex would crash in defaults section

Manoj Kumar reported a case where haproxy would crash upon start-up. The
cause was an "http-check expect" statement declared in the defaults section,
which caused a NULL regex to be used during the check. This statement is not
allowed in defaults sections precisely because this requires saving a copy
of the regex in the default proxy. But the check was not made to prevent it
from being declared there, hence the issue.

Instead of adding code to detect its abnormal use, we decided to implement
it. It was not that much complex because the expect_str part was not used
with regexes, so it could hold the string form of the regex in order to
compile it again for every backend (there's no way to clone regexes).

This patch has been tested and works. So it's both a bugfix and a minor
feature enhancement.

It should be backported to 1.4 though it's not critical since the config
was not supposed to be supported.

14 years ago[MINOR] Use DPRINTF in assign_server()
Simon Horman [Fri, 12 Aug 2011 23:03:52 +0000 (08:03 +0900)] 
[MINOR] Use DPRINTF in assign_server()

Use DPRINTF in assign_server() rather than open-coding its logic.

14 years ago[MINOR] Fix build error in stream_int_register_handler()
Simon Horman [Fri, 12 Aug 2011 23:03:51 +0000 (08:03 +0900)] 
[MINOR] Fix build error in stream_int_register_handler()

There is no parameter or variable fct in stream_int_register_handler()
so the build fails when DPRINTF is active.

14 years ago[MINOR] Correct type in table dump examples
Simon Horman [Fri, 12 Aug 2011 23:03:50 +0000 (08:03 +0900)] 
[MINOR] Correct type in table dump examples

When dumping tables the table type is displayed
as a type name  not an integer.

14 years ago[MEDIUM] Correct ipmask() logic
Simon Horman [Fri, 12 Aug 2011 23:03:49 +0000 (08:03 +0900)] 
[MEDIUM] Correct ipmask() logic

The netmask applied to table entries as configured using ipmask() is
stored in arg_p->data.ip not arg_i (which will be 1 if the netmask is set).

14 years ago[MEDIUM] Fix stick-table replication on soft-restart
Simon Horman [Fri, 12 Aug 2011 23:03:48 +0000 (08:03 +0900)] 
[MEDIUM] Fix stick-table replication on soft-restart

"[MINOR] session: add a pointer to the new target into the session" (664beb8)
introduced a regression by changing the type of a peer's target from
TARG_TYPE_PROXY to TARG_TYPE_NONE. The effect of this is that during
a soft-restart the new process no longer tries to connect to the
old process to replicate its stick tables.

This patch sets the type of a peer's target as TARG_TYPE_PROXY and
replication on soft-restart works once again.

14 years ago[MINOR] session-counters: add the ability to clear the counters
Willy Tarreau [Fri, 12 Aug 2011 23:45:16 +0000 (01:45 +0200)] 
[MINOR] session-counters: add the ability to clear the counters

Sometimes it can be useful to reset a counter : one condition increments
it and another one resets it. It can be used to better detect abuses.

14 years ago[MINOR] halog: add support for termination code matching (-tcn/-TCN)
Hervé COMMOWICK [Wed, 10 Aug 2011 15:42:41 +0000 (17:42 +0200)] 
[MINOR] halog: add support for termination code matching (-tcn/-TCN)

It is now possible to filter by termination code with -tcn <termcode>, to be
able to track one kind of errors, for example after counting it with -tc.
Use -TCN <termcode> gives you the opposite.

14 years ago[MEDIUM] checks: group health checks methods by values and save option bits
Willy Tarreau [Sat, 6 Aug 2011 15:05:02 +0000 (17:05 +0200)] 
[MEDIUM] checks: group health checks methods by values and save option bits

Adding health checks has become a real pain, with cross-references to all
checks everywhere because they're all a single bit. Since they're all
exclusive, let's change this to have a check number only. We reserve 4
bits allowing up to 16 checks (15+tcp), only 7 of which are currently
used. The code has shrunk by almost 1kB and we saved a few option bits.

The "dispatch" option has been moved to px->options, making a few tests
a bit cleaner.

14 years ago[DOC] small fixes to clearly distinguish between keyword
Hervé COMMOWICK [Fri, 5 Aug 2011 16:48:51 +0000 (18:48 +0200)] 
[DOC] small fixes to clearly distinguish between keyword
and variables

Variables needs to be presented inside <> to be distinguished from keywords

14 years ago[MINOR] check: add redis check support
Hervé COMMOWICK [Fri, 5 Aug 2011 14:23:48 +0000 (16:23 +0200)] 
[MINOR] check: add redis check support

This patch provides a new "option redis-check" statement to enable server health checks based on redis PING request (http://www.redis.io/commands/ping).

14 years ago[MINOR] acl: add srv_conn acl to count connections on a
Hervé COMMOWICK [Fri, 5 Aug 2011 10:09:44 +0000 (12:09 +0200)] 
[MINOR] acl: add srv_conn acl to count connections on a
specific backend server

These ACLs are used to check the number of active connections on the specified server in the specified backend.

14 years ago[MEDIUM] stats: add support for changing frontend's maxconn at runtime
Willy Tarreau [Tue, 2 Aug 2011 09:49:05 +0000 (11:49 +0200)] 
[MEDIUM] stats: add support for changing frontend's maxconn at runtime

The new "set maxconn frontend XXX" statement on the stats socket allows
the admin to change a frontend's maxconn value. If some connections are
queued, they will immediately be accepted up to the new limit. If the
limit is lowered, new connections acceptation might be delayed. This can
be used to temporarily reduce or increase the impact of a specific frontend's
traffic on the whole process.

14 years ago[DOC] fix typos, "#" is a sharp, not a dash
Willy Tarreau [Tue, 2 Aug 2011 09:32:07 +0000 (11:32 +0200)] 
[DOC] fix typos, "#" is a sharp, not a dash

That's what happens when the same text is copy-pasted over and over...

14 years ago[MINOR] proxy: make findproxy() return proxies from numeric IDs too
Willy Tarreau [Tue, 2 Aug 2011 09:25:54 +0000 (11:25 +0200)] 
[MINOR] proxy: make findproxy() return proxies from numeric IDs too

Sometimes it's useful to be able to search a proxy by its numeric ID,
so let's add support for names such as #<id>.

14 years ago[MEDIUM] listeners: add a global listener management task
Willy Tarreau [Mon, 1 Aug 2011 18:57:55 +0000 (20:57 +0200)] 
[MEDIUM] listeners: add a global listener management task

This global task is used to periodically check for end of resource shortage
and to try to enable queued listeners again. This is important in case some
temporary system-wide shortage is encountered, so that we don't have to wait
for an existing connection to be released before checking the queue again.

For situations where listeners are queued due to the global maxconn being
reached, the task is woken up at least every second. For situations where
a system resource shortage is detected (memory, sockets, ...) the task is
woken up at least every 100 ms. That way, recovery from severe events can
still be achieved under acceptable conditions.

14 years ago[BUG] proxy: stats frontend and peers were missing many initializers
Willy Tarreau [Thu, 28 Jul 2011 23:49:03 +0000 (01:49 +0200)] 
[BUG] proxy: stats frontend and peers were missing many initializers

This was revealed with one of the very latest patches which caused
the listener_queue not to be initialized on the stats socket frontend.
And in fact a number of other ones were missing too. This is getting so
boring that now we'll always make use of the same function to initialize
any proxy. Doing so has even saved about 500 bytes on the binary due to
the avoided code redundancy.

No backport is needed.

14 years ago[MAJOR] proxy: finally get rid of maintain_proxies()
Willy Tarreau [Mon, 25 Jul 2011 14:33:49 +0000 (16:33 +0200)] 
[MAJOR] proxy: finally get rid of maintain_proxies()

This function is finally not needed anymore, as it has been replaced with
a per-proxy task that is scheduled when some limits are encountered on
incoming connections or when the process is stopping. The savings should
be noticeable on configs with a large number of proxies. The most important
point is that the rate limiting is now enforced in a clean and solid way.

14 years ago[MINOR] task: new function task_schedule() to schedule a wake up
Willy Tarreau [Mon, 25 Jul 2011 12:30:42 +0000 (14:30 +0200)] 
[MINOR] task: new function task_schedule() to schedule a wake up

This function is used when a task should be woken up at most at a given
date. This will be used with rate shapers.

14 years ago[CLEANUP] proxy: merge maintain_proxies() operation inside a single loop
Willy Tarreau [Mon, 25 Jul 2011 09:54:17 +0000 (11:54 +0200)] 
[CLEANUP] proxy: merge maintain_proxies() operation inside a single loop

This will help transforming the processing into per-proxy tasks.

14 years ago[BUG] proxy: peers must only be stopped once, not upon every call to maintain_proxies
Willy Tarreau [Mon, 25 Jul 2011 09:16:24 +0000 (11:16 +0200)] 
[BUG] proxy: peers must only be stopped once, not upon every call to maintain_proxies

Peers were stopped on every call to maintain_proxies when stopping=1,
while they should only be stopped once upon call to soft_stop(). This
bug has little impact, mostly increased CPU usage. It's not needed to
backport it.

14 years ago[MINOR] sessions: only wake waiting listeners up if rate limit is OK
Willy Tarreau [Mon, 25 Jul 2011 06:37:44 +0000 (08:37 +0200)] 
[MINOR] sessions: only wake waiting listeners up if rate limit is OK

Instead of waking a listener up then making it sleep, we only wake them up
if we know their rate limit is fine. In the future we could improve on top
of that by deciding to wake a proxy-specific task in XX milliseconds to
take care of enabling the listeners again.

14 years ago[MINOR] proxy: make session rate-limit more accurate
Willy Tarreau [Mon, 25 Jul 2011 06:30:51 +0000 (08:30 +0200)] 
[MINOR] proxy: make session rate-limit more accurate

Patch d9bbe17b used to limit the rate-limit to off-by-one to avoid
a busy loop when the limit is reached. Now that the listeners are
automatically disabled and queued when a limit is reached, we don't
need this workaround anymore and can bring back the most accurate
computation.

14 years ago[MINOR] stats: report a "WAITING" state for sockets waiting for resource
Willy Tarreau [Mon, 25 Jul 2011 06:16:20 +0000 (08:16 +0200)] 
[MINOR] stats: report a "WAITING" state for sockets waiting for resource

This is useful when enabling socket-stats to know that a socket is being
waiting for some resource (RAM, global connections, etc...).

14 years ago[CLEANUP] proxy: rename a few proxy states (PR_STIDLE and PR_STRUN)
Willy Tarreau [Mon, 25 Jul 2011 06:11:52 +0000 (08:11 +0200)] 
[CLEANUP] proxy: rename a few proxy states (PR_STIDLE and PR_STRUN)

Those states have been replaced with PR_STFULL and PR_STREADY respectively,
as it is what matches them the best now. Also, two occurrences of PR_STIDLE
in peers.c have been removed as this did not provide any form of error recovery
anyway.

14 years ago[MEDIUM] listeners: don't change listeners states anymore in maintain_proxies
Willy Tarreau [Mon, 25 Jul 2011 05:37:28 +0000 (07:37 +0200)] 
[MEDIUM] listeners: don't change listeners states anymore in maintain_proxies

Now maintain_proxies() only changes proxies states and does not affect their
listeners anymore since they are autonomous. A proxy will switch between the
PR_STIDLE and PR_STRUN states depending whether it's saturated or not. Next
step will consist in renaming PR_STIDLE to PR_STFULL. This state is now only
used to report the proxy state in the stats.

14 years ago[MEDIUM] listeners: don't stop proxies when global maxconn is reached
Willy Tarreau [Mon, 25 Jul 2011 05:08:45 +0000 (07:08 +0200)] 
[MEDIUM] listeners: don't stop proxies when global maxconn is reached

Now we don't have to stop proxies anymore since their listeners will be
queued if they attempt to accept a connection past the global limits.

14 years ago[MEDIUM] listeners: queue proxy-bound listeners at the proxy's
Willy Tarreau [Sun, 24 Jul 2011 21:55:06 +0000 (23:55 +0200)] 
[MEDIUM] listeners: queue proxy-bound listeners at the proxy's

All listeners that are limited by a proxy-specific resource are now
queued at the proxy's and not globally. This allows finer-grained
wakeups when releasing resource.

14 years ago[MEDIUM] listeners: put listeners in queue upon resource shortage
Willy Tarreau [Sun, 24 Jul 2011 20:58:00 +0000 (22:58 +0200)] 
[MEDIUM] listeners: put listeners in queue upon resource shortage

When an accept() fails because of a connection limit or a memory shortage,
we now disable it and queue it so that it's dequeued only when a connection
is released. This has improved the behaviour of the process near the fd limit
as now a listener with a no connection (eg: stats) will not loop forever
trying to get its connection accepted.

The solution is still not 100% perfect, as we'd like to have this used when
proxy limits are reached (use a per-proxy list) and for safety, we'd need
to have dedicated tasks to periodically re-enable them (eg: to overcome
temporary system-wide resource limitations when no connection is released).

14 years ago[MINOR] listeners: add support for queueing resource limited listeners
Willy Tarreau [Sun, 24 Jul 2011 20:03:52 +0000 (22:03 +0200)] 
[MINOR] listeners: add support for queueing resource limited listeners

When a listeners encounters a resource shortage, it currently stops until
one re-enables it. This is far from being perfect as it does not yet handle
the case where the single connection from the listener is rejected (eg: the
stats page).

Now we'll have a special status for resource limited listeners and we'll
queue them into one or multiple lists. That way, each time we have to stop
a listener because of a resource shortage, we can enqueue it and change its
state, so that it is dequeued once more resources are available.

This patch currently does not change any existing behaviour, it only adds
the basic building blocks for doing that.

14 years ago[MINOR] listeners: add listen_full() to mark a listener full
Willy Tarreau [Sun, 24 Jul 2011 17:23:38 +0000 (19:23 +0200)] 
[MINOR] listeners: add listen_full() to mark a listener full

This is just a cleanup which removes calls to EV_FD_CLR() and state
setting everywhere in the code.

14 years ago[BUG] stream_sock: ensure orphan listeners don't accept too many connections
Willy Tarreau [Sun, 24 Jul 2011 17:16:52 +0000 (19:16 +0200)] 
[BUG] stream_sock: ensure orphan listeners don't accept too many connections

For listeners that are not bound to a frontend, the limit on the
number of accepted connections is tested at the end of the accept()
loop, but we don't break out of the loop, meaning that if more
connections than what the listener allows are available and if this
is less than the proxy's limits and within the size of a batch, then
they could be accepted. In practice, this problem currently cannot
appear since all listeners are bound to a frontend, and it's a very
minor issue anyway.

1.4 has the same issue (which cannot happen there either), but there
is some code after it, so it's the code cleanup which revealed it.

14 years ago[MEDIUM] proxy: add a PAUSED state to listeners and move socket tricks out of proxy.c
Willy Tarreau [Sun, 24 Jul 2011 16:28:10 +0000 (18:28 +0200)] 
[MEDIUM] proxy: add a PAUSED state to listeners and move socket tricks out of proxy.c

Managing listeners state is difficult because they have their own state
and can at the same time have theirs dictated by their proxy. The pause
is not done properly, as the proxy code is fiddling with sockets. By
introducing new functions such as pause_listener()/resume_listener(), we
make it a bit more obvious how/when they're supposed to be used. The
listen_proxies() function was also renamed to resume_proxies() since
it's only used for pause/resume.

This patch is the first in a series aiming at getting rid of the maintain_proxies
mess. In the end, proxies should not call enable_listener()/disable_listener()
anymore.

14 years ago[BUG] stream_sock: disable listener when system resources are exhausted
Willy Tarreau [Fri, 22 Jul 2011 14:56:33 +0000 (16:56 +0200)] 
[BUG] stream_sock: disable listener when system resources are exhausted

When an accept() returns -1 ENFILE du to system limits, it leaves the
connection pending in the backlog and epoll() comes back immediately
afterwards trying to make it accept it again. This causes haproxy to
remain at 100% CPU until something makes an accept() possible again.
Now upon such resource shortage, we mark the listener FULL so that we
only enable it again once at least one connection has been released.
In fact we only do that if there are some active connections on this
proxy, so that it has a chance to be marked not full again. This makes
haproxy remain idle when all resources are used, which helps a lot
releasing those resource as fast as possible.

Backport to 1.4 might be desirable but difficult and tricky.

14 years ago[OPTIM] stream_sock: reduce the default number of accepted connections at once
Willy Tarreau [Fri, 22 Jul 2011 19:59:59 +0000 (21:59 +0200)] 
[OPTIM] stream_sock: reduce the default number of accepted connections at once

By default on a single process, we accept 100 connections at once. This is too
much on recent CPUs where the cache is constantly thrashing, because we visit
all those connections several times. We should batch the processing slightly
less so that all the accepted session may remain in cache during their initial
processing.

Lowering the batch size from 100 to 32 has changed the connection rate for
concurrencies between 5-10k from 67 kcps to 94 kcps on a Core i5 660 (4M L3),
and forward rates from 30k to 39.5k.

Tests on this hardware show that values between 10 and 30 seem to do the job fine.

14 years ago[MINOR] session: try to emit a 500 response on memory allocation errors
Willy Tarreau [Fri, 22 Jul 2011 15:36:27 +0000 (17:36 +0200)] 
[MINOR] session: try to emit a 500 response on memory allocation errors

When we fail to create a session because of memory shortage, let's at
least try to send a 500 message directly on the socket. Even if we don't
have any buffers left, the kernel's orphans management will take care of
delivering the message as long as there are socket buffers left.

14 years ago[BUG] session: risk of crash on out of memory (1.5-dev regression)
Willy Tarreau [Tue, 19 Jul 2011 22:17:39 +0000 (00:17 +0200)] 
[BUG] session: risk of crash on out of memory (1.5-dev regression)

Patch af5149 introduced an issue which can be detected only on out of
memory conditions : a LIST_DEL() may be performed on an uninitialized
struct member instead of a LIST_INIT() during the accept() phase,
causing crashes and memory corruption to occur.

This issue was detected and diagnosed by the Exceliance R&D team.

This is 1.5-specific and very recent, so no existing deployment should
be impacted.

14 years ago[MINOR] Free stick rules on denint()
Simon Horman [Fri, 15 Jul 2011 04:14:11 +0000 (13:14 +0900)] 
[MINOR] Free stick rules on denint()

The motivation for this is that when soft-restart is merged
it will be come more important to free all relevant memory in deinit()

Discovered using valgrind.

14 years ago[MINOR] Free stick table pool on denint()
Simon Horman [Fri, 15 Jul 2011 04:14:10 +0000 (13:14 +0900)] 
[MINOR] Free stick table pool on denint()

The motivation for this is that when soft-restart is merged
it will be come more important to free all relevant memory in deinit()

Discovered using valgrind.

14 years ago[MINOR] Free tcp rules on denint()
Simon Horman [Fri, 15 Jul 2011 04:14:09 +0000 (13:14 +0900)] 
[MINOR] Free tcp rules on denint()

The motivation for this is that when soft-restart is merged
it will be come more important to free all relevant memory in deinit()

Discovered using valgrind.

14 years ago[MINOR] Free rdp_cookie_name on denint()
Simon Horman [Fri, 15 Jul 2011 04:14:08 +0000 (13:14 +0900)] 
[MINOR] Free rdp_cookie_name on denint()

The motivation for this is that when soft-restart is merged
it will be come more important to free all relevant memory in deinit()

Discovered using valgrind.

14 years ago[MINOR] Consistently free expr on error in cfg_parse_listen()
Simon Horman [Fri, 15 Jul 2011 04:14:07 +0000 (13:14 +0900)] 
[MINOR] Consistently free expr on error in cfg_parse_listen()

It seems to me that without this change cfg_parse_listen()
may leak memory.

14 years ago[MINOR] Consistently use error in tcp_parse_tcp_req()
Simon Horman [Fri, 15 Jul 2011 04:14:06 +0000 (13:14 +0900)] 
[MINOR] Consistently use error in tcp_parse_tcp_req()

It seems to me that without this change tcp_parse_tcp_req()
may leak memory.

14 years ago[OPTIM] halog: remove support for tab delimiters in input data
Willy Tarreau [Sun, 10 Jul 2011 20:11:17 +0000 (22:11 +0200)] 
[OPTIM] halog: remove support for tab delimiters in input data

Haproxy does not use tabs when sending logs, and checking for them
wastes no less than 4% of CPU cycles. Better get rid of these tests.

14 years ago[OPTIM] halog: remove many 'if' by using a function pointer for the filters
Willy Tarreau [Sun, 10 Jul 2011 19:39:35 +0000 (21:39 +0200)] 
[OPTIM] halog: remove many 'if' by using a function pointer for the filters

There were too many filters, we were losing time in all the "if" statements.
By moving all the filters to independant functions, we made the code cleaner
and slightly faster (3%).

One minor bug was found, the -tc and -st options did not report the number
of output lines, but always zero.

14 years ago[OPTIM] halog: check once for correct line format and reuse the pointer
Willy Tarreau [Sun, 10 Jul 2011 17:47:48 +0000 (19:47 +0200)] 
[OPTIM] halog: check once for correct line format and reuse the pointer

Almost all filters first check the line format, which takes a lot of code
and requires parsing back and forth. By centralizing this test, we can
save about 15-20 more percent of performance for all filters.

Also, the test was wrong, it was checking that the source IP address was
starting with a digit, which is not always true with local IPv6 addresses.
Instead, we now check that the next field (accept field) starts with an
opening bracket and is followed by a digit between 0 and 3 (day of the
month). Doing this has contributed a 2% speedup because all other field
calculations were relative to a closer field.

14 years ago[OPTIM] halog: cache some common fields positions
Willy Tarreau [Sun, 10 Jul 2011 16:53:44 +0000 (18:53 +0200)] 
[OPTIM] halog: cache some common fields positions

Since many fields are relative and some are used a lot, try to cache them
the first time they're used in order to avoid skipping them twice. The
status counts with HTTP pre-check enabled has sped up by 40%.

14 years ago[MINOR] halog: gain back performance before SKIP_CHAR fix
Willy Tarreau [Sun, 10 Jul 2011 16:15:08 +0000 (18:15 +0200)] 
[MINOR] halog: gain back performance before SKIP_CHAR fix

The SKIP_CHAR fix caused a measurable performance drop. Since we can
consider all chars below 0x20 as delimiters, we can avoid a cache lookup
which requires a char to pointer conversion.

14 years ago[MINOR] halog: add support for HTTP log matching (-H)
Willy Tarreau [Sun, 10 Jul 2011 15:27:40 +0000 (17:27 +0200)] 
[MINOR] halog: add support for HTTP log matching (-H)

Now it's possible to restrict analysis to HTTP-looking logs when passing -H.
-H -v gives the opposite (most likely TCP logs).

14 years ago[MINOR] halog: make SKIP_CHAR stop on field delimiters
Willy Tarreau [Sun, 10 Jul 2011 15:25:33 +0000 (17:25 +0200)] 
[MINOR] halog: make SKIP_CHAR stop on field delimiters

The SKIP_CHAR() macro did not consider field delimiters, causing the timer parser
to be able to search timers at wrong places when fed with TCP logs.

14 years ago[BUG] halog: correctly handle truncated last line
Willy Tarreau [Sat, 9 Jul 2011 12:28:01 +0000 (14:28 +0200)] 
[BUG] halog: correctly handle truncated last line

If last line is truncated (eg: truncated file), then halog would loop on
it forever.

14 years ago[MEDIUM] http: add support for 'cookie' and 'set-cookie' patterns
Willy Tarreau [Fri, 1 Jul 2011 14:16:17 +0000 (16:16 +0200)] 
[MEDIUM] http: add support for 'cookie' and 'set-cookie' patterns

This is used to perform cookie-based stickiness with table replication
between multiple masters and across restarts. This partially overrides
some of the appsession capabilities.

14 years ago[DOC] add missing entry or stick store-response
Willy Tarreau [Fri, 1 Jul 2011 09:33:25 +0000 (11:33 +0200)] 
[DOC] add missing entry or stick store-response

14 years ago[MINOR] Add non-stick server option
Simon Horman [Sat, 25 Jun 2011 00:39:49 +0000 (09:39 +0900)] 
[MINOR] Add non-stick server option

Never add connections allocated to this sever to a stick-table.
This may be used in conjunction with backup to ensure that
stick-table persistence is disabled for backup servers.

14 years ago[CLEANUP] Remove unnecessary casts
Simon Horman [Fri, 24 Jun 2011 06:11:37 +0000 (15:11 +0900)] 
[CLEANUP] Remove unnecessary casts

There is no need to cast when going to or from void *

14 years ago[MINOR] Add rdp_cookie pattern fetch function
Simon Horman [Fri, 24 Jun 2011 05:50:20 +0000 (14:50 +0900)] 
[MINOR] Add rdp_cookie pattern fetch function

This pattern fetch function extracts the value of the rdp cookie <name> as
a string and uses this value to match. This enables implementation of
persistence based on the mstshash cookie. This is typically done if there
is no msts cookie present.

This differs from "balance rdp-cookie" in that any balancing algorithm may
be used and thus the distribution of clients to backend servers is not
linked to a hash of the RDP cookie. It is envisaged that using a balancing
algorithm such as "balance roundrobin" or "balance leastconnect" will lead
to a more even distribution of clients to backend servers than the hash
used by "balance rdp-cookie".

Example :
listen tse-farm
    bind 0.0.0.0:3389
    # wait up to 5s for an RDP cookie in the request
    tcp-request inspect-delay 5s
    tcp-request content accept if RDP_COOKIE
    # apply RDP cookie persistence
    persist rdp-cookie
    # Persist based on the mstshash cookie
    # This is only useful makes sense if
    # balance rdp-cookie is not used
    stick-table type string size 204800
    stick on rdp_cookie(mstshash)
    server srv1 1.1.1.1:3389
    server srv1 1.1.1.2:3389

14 years ago[MINOR] Make appsess{,ion}_refresh static
Simon Horman [Fri, 24 Jun 2011 05:49:57 +0000 (14:49 +0900)] 
[MINOR] Make appsess{,ion}_refresh static

apsession_refresh() and apsess_refressh are only used inside apsession.c
and thus can be made static.

The only use of apsession_refresh() is appsession_task_init().
These functions have been re-ordered to avoid the need for
a forward-declaration of apsession_refresh().

14 years ago[MINOR] Add down termination condition
Simon Horman [Tue, 21 Jun 2011 05:34:59 +0000 (14:34 +0900)] 
[MINOR] Add down termination condition

If a connection is closed by because the backend became unavailable
then log 'D' as the termination condition.

Signed-off-by: Simon Horman <horms@verge.net.au>
14 years ago[MINOR] Allow shutdown of sessions when a server becomes unavailable
Simon Horman [Tue, 21 Jun 2011 05:34:58 +0000 (14:34 +0900)] 
[MINOR] Allow shutdown of sessions when a server becomes unavailable

This adds the "on-marked-down shutdown-sessions" statement on "server" lines,
which causes all sessions established on a server to be killed at once when
the server goes down. The task's priority is reniced to the highest value
(1024) so that servers holding many tasks don't cause a massive slowdown due
to the wakeup storm.

14 years ago[MINOR] Add active connection list to server
Simon Horman [Tue, 21 Jun 2011 05:34:57 +0000 (14:34 +0900)] 
[MINOR] Add active connection list to server

The motivation for this is to allow iteration of all the connections
of a server without the expense of iterating over the global list
of connections.

The first use of this will be to implement an option to close connections
associated with a server when is is marked as being down or in maintenance
mode.

14 years ago[CLEANUP] session.c: Make functions static where possible
Simon Horman [Wed, 8 Jun 2011 00:19:07 +0000 (09:19 +0900)] 
[CLEANUP] session.c: Make functions static where possible

14 years ago[CLEANUP] peers.h: fix declarations
Simon Horman [Wed, 8 Jun 2011 00:18:51 +0000 (09:18 +0900)] 
[CLEANUP] peers.h: fix declarations

* The declaration of peer_session_create() does
  not match its definition. As it is only
  used inside of peers.c make it static.

* Make the declaration of peers_register_table()
  match its definition.

* Also, make all functions in peers.c that
  are not also in peers.h static

14 years ago[CLEANUP] Remove assigned but unused variables
Simon Horman [Tue, 7 Jun 2011 02:07:50 +0000 (11:07 +0900)] 
[CLEANUP] Remove assigned but unused variables

gcc (Debian 4.6.0-2) 4.6.1 20110329 (prerelease)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

...
src/proto_http.c:3029:14: warning: variable â\80\98del_clâ\80\99 set but not used [-Wunused-but-set-variable]
In file included from ebtree/eb64tree.c:23:0:
ebtree/eb64tree.h: In function â\80\98__eb64_lookupâ\80\99:
ebtree/eb64tree.h:128:6: warning: variable â\80\98node_bitâ\80\99 set but not used [-Wunused-but-set-variable]
ebtree/eb64tree.h: In function â\80\98__eb64i_lookupâ\80\99:
ebtree/eb64tree.h:180:6: warning: variable â\80\98node_bitâ\80\99 set but not used [-Wunused-but-set-variable]
In file included from ebtree/ebpttree.h:26:0,
                 from ebtree/ebimtree.c:23:
ebtree/eb64tree.h: In function â\80\98__eb64_lookupâ\80\99:
ebtree/eb64tree.h:128:6: warning: variable â\80\98node_bitâ\80\99 set but not used [-Wunused-but-set-variable]
ebtree/eb64tree.h: In function â\80\98__eb64i_lookupâ\80\99:
ebtree/eb64tree.h:180:6: warning: variable â\80\98node_bitâ\80\99 set but not used [-Wunused-but-set-variable]
In file included from ebtree/ebpttree.h:26:0,
                 from ebtree/ebistree.h:25,
                 from ebtree/ebistree.c:23:
ebtree/eb64tree.h: In function â\80\98__eb64_lookupâ\80\99:
ebtree/eb64tree.h:128:6: warning: variable â\80\98node_bitâ\80\99 set but not used [-Wunused-but-set-variable]
ebtree/eb64tree.h: In function â\80\98__eb64i_lookupâ\80\99:
ebtree/eb64tree.h:180:6: warning: variable â\80\98node_bitâ\80\99 set but not used [-Wunused-but-set-variable]

14 years ago[MINOR] Allow showing and clearing by key of string stick tables
Simon Horman [Wed, 15 Jun 2011 06:18:52 +0000 (15:18 +0900)] 
[MINOR] Allow showing and clearing by key of string stick tables

14 years ago[MINOR] Allow showing and clearing by key of integer stick tables
Simon Horman [Wed, 15 Jun 2011 06:18:51 +0000 (15:18 +0900)] 
[MINOR] Allow showing and clearing by key of integer stick tables

14 years ago[MINOR] Allow showing and clearing by key of ipv6 stick tables
Simon Horman [Wed, 15 Jun 2011 06:18:50 +0000 (15:18 +0900)] 
[MINOR] Allow showing and clearing by key of ipv6 stick tables

14 years ago[MINOR] More flexible clearing of stick table
Simon Horman [Wed, 15 Jun 2011 06:18:49 +0000 (15:18 +0900)] 
[MINOR] More flexible clearing of stick table

* Allow clearing of all entries of a table
* Allow clearing of all entries of a table
  that match a data filter

14 years ago[MINOR] Break out all stick table socat command parsing
Simon Horman [Wed, 15 Jun 2011 06:18:48 +0000 (15:18 +0900)] 
[MINOR] Break out all stick table socat command parsing

This will allow reuse for clearing table entries
other than by key

14 years ago[MINOR] Allow listing of stick table by key
Simon Horman [Wed, 15 Jun 2011 06:18:47 +0000 (15:18 +0900)] 
[MINOR] Allow listing of stick table by key

14 years ago[MINOR] Break out processing of clear table
Simon Horman [Wed, 15 Jun 2011 06:18:46 +0000 (15:18 +0900)] 
[MINOR] Break out processing of clear table

This will allow the code to be reused
for showing a table filtered by key

14 years ago[MINOR] Break out dumping table
Simon Horman [Wed, 15 Jun 2011 06:18:45 +0000 (15:18 +0900)] 
[MINOR] Break out dumping table

This will allow the code to be reused
for showing a table filtered by key

Signed-off-by: Simon Horman <horms@verge.net.au>
14 years ago[CLEANUP] dumpstats: make symbols static where possible
Simon Horman [Wed, 15 Jun 2011 06:18:44 +0000 (15:18 +0900)] 
[CLEANUP] dumpstats: make symbols static where possible

14 years ago[BUG] checks: fix support of Mysqld >= 5.5 for mysql-check
Hervé COMMOWICK [Fri, 10 Jun 2011 12:05:59 +0000 (14:05 +0200)] 
[BUG] checks: fix support of Mysqld >= 5.5 for mysql-check

mysqld >= 5.5 want the client to announce 4.1+ authentication support, even if we have no password, so we do this.
I also check on a debian potato mysqld 3.22 and it works too so i assume we are good from 3.22 to 5.5.

[WT: this must be backported to 1.4]

14 years ago[CLEANUP] config: remove some left-over printf debugging code from previous patch
Willy Tarreau [Tue, 14 Jun 2011 05:49:12 +0000 (07:49 +0200)] 
[CLEANUP] config: remove some left-over printf debugging code from previous patch

Last patch fbb784 unexpectedly left some debugging printf messages which can be
seen in debug mode.

14 years ago[MINOR] config: automatically compute a default fullconn value
Willy Tarreau [Sun, 5 Jun 2011 13:38:35 +0000 (15:38 +0200)] 
[MINOR] config: automatically compute a default fullconn value

The fullconn value is not easy to get right when doing dynamic regulation,
as it should depend on the maxconns of the frontends that can reach a
backend. Since the parameter is mandatory, many configs are found with
an inappropriate default value.

Instead of rejecting configs without a fullconn value, we now set it to
10% of the sum of the configured maxconns of all the frontends which are
susceptible to branch to the backend. That way if new frontends are added,
the backend's fullconn automatically adjusts itself.