It seems that many contributors already submit patches thinking that
rst is Markdown, which leads to incorrect and inconsistent formatting,
since the two are similar but not compatible. By using the more well
known Markdown, we can perhaps hope to achieve better formatted
documentation contributions.
Also, since the web site uses Markdown as its source format, by using
Markdown here we can avoid the fragile conversion process altogether.
Once upon a time, one could point auth_file to pg_auth in the
PostgreSQL data directory, but this is long obsolete (gone as of
PostgreSQL 9.0), so remove mentions of it.
Prevent too long user name or password from client
In most cases, this wouldn't work anyway, because for example the user
wouldn't be found in pgbouncer, since userlist.txt doesn't permit too
long user names. But in the case of PAM there was no such check, so
too long user names could be added by add_pam_user(), which would
truncate them, and then a subsequent search using the not-truncated
name wouldn't find it, causing duplicates to be added.
Marco Nenciarini [Fri, 28 Dec 2018 19:06:58 +0000 (20:06 +0100)]
Avoid 'unexpected response from login query' after a postgres reload
After a PostgreSQL reload, the backend could inform the frontend about
configuration changes by sending some ParameterStatus messages
together with the usual login query response. These messages can be
safely ignored in the login query response handler.
Marco Slot [Tue, 25 Sep 2018 10:10:52 +0000 (10:10 +0000)]
Do not wait server_login_retry for next connect if cancellation succeeds
If postgres restarts while there are N cancellations in the queue,
pgbouncer is currently unavailable for at least N*server_login_retry
because it uses every new connection for one queued cancellation and
then waits server_login_retry before opening a new connection because
the last_connect_failed flag is still set to 1. This can lead to
prolonged downtime.
This changes fixes the issue by introducing a last_login_failed flag.
The last_connect_failed is now reset when a cancellation succeeds, such
that launch_new_connection no longer waits if pgbouncer manages to
connect, but has queued cancellations. The last_login_failed flag has
the same semantics as the last_connect_failed flag had previously, such
that check_fast_fail still rejects connections when there are no servers
available and the last login failed.
Peter Eisentraut [Fri, 21 Sep 2018 13:35:00 +0000 (15:35 +0200)]
Add exit status to test scripts
When a test fails, exit with status 1, so automation can catch test
failures. Also add a way to skip tests that cannot be run (mainly for
lack of sudo in this case).
Peter Eisentraut [Tue, 21 Aug 2018 19:55:33 +0000 (21:55 +0200)]
Make sure file descriptor info goes to the log
Delay the call to check_limits() until after daemonization so that the
message goes to the server log and is not printed to some other output
location.
Peter Eisentraut [Fri, 17 Aug 2018 19:50:04 +0000 (21:50 +0200)]
Fix up conntest test programs
Allow asynctest to run without an explicitly specified connection
string. That way it can pick up the connection parameters from the
environment. The run-conntest.sh driver script was already calling it
that way.
Fix the location of the pgbouncer binary in run-conntest.sh.
Peter Eisentraut [Thu, 16 Aug 2018 19:10:47 +0000 (21:10 +0200)]
Improve test script robustness
Consistently exit with an error if the OS is not supported by the
firewall manipulation commands. Previously, it would in some cases
print an error but not exit.
Peter Eisentraut [Wed, 25 Jul 2018 10:57:24 +0000 (12:57 +0200)]
Fast close
Disconnect a server in session pool mode immediately if it is in
"close_needed" (reconnect) mode. This ensures that the RECONNECT
command doesn't have to wait for session end.
Peter Eisentraut [Thu, 26 Jul 2018 11:56:30 +0000 (13:56 +0200)]
test.sh: Sort out netcat zoo
The previous code distinguished between Linux and non-Linux netcat.
This didn't stand the test of time, since Linux distributions now ship
multiple variants of netcat and other operating systems also provide
multiple options. So instead try to detect the variant from the help
output. Also, the previous uses of the -q and -w options behaved
strangely with some versions and/or were inconsistent with the
documentation. So abandon those options and just rely on the existing
killall call.
The test_server_connect_timeout_establish test should now pass again on
hopefully most configurations.
Peter Eisentraut [Tue, 24 Jul 2018 10:19:18 +0000 (12:19 +0200)]
Fix -Wimplicit-fallthrough warnings
These warnings started showing up with GCC 7. The code was already
correct, but the intent is now a bit clearer. Compilation with recent
GCCs should now be warning-free again.
Peter Eisentraut [Thu, 19 Jul 2018 12:54:17 +0000 (14:54 +0200)]
doc: Small improvement in quick start
Add an indication that the "SHOW HELP" example output is not complete.
Then we don't have to feel obliged to update it every time we add
something to the actual help output.
If we fail to calloc the rule buffer, going to failed: will deref
rule via the rule_free() call. Avoid by returning false directly
and bypass the failed: block.
If the fopen() call fails parse_namefile() frees the filename buffer
fn, and the caller does the same. Avoid freeing in parse_namefile()
and leave the cleanup to the caller.
Peter Eisentraut [Tue, 26 Dec 2017 21:49:36 +0000 (16:49 -0500)]
Fix psql invocation in tests
Always run psql with -X, otherwise some tests fail if there is something
in .psqlrc producing output. Also fix some potential portability
problems in option syntax: Put non-option arguments last, don't mix
options with and without arguments.
Peter Eisentraut [Thu, 14 Dec 2017 18:54:58 +0000 (13:54 -0500)]
Fix handling of absent rst2man
The makefile line
RST2MAN ?= rst2man
didn't have the desired effect, because config.mak sets RST2MAN, and ?=
doesn't do anything if the variable is set to empty. So instead let
configure put in a default value if the program cannot be found.
Euler Taveira [Fri, 8 Dec 2017 22:00:24 +0000 (22:00 +0000)]
Use default values in config file
Instead of using arbritary values, use the default values. It is to
avoid surprises if you just remove comment character (;). I also did
some cosmetic changes. While at it, add some default information for
auth_user.
Tomas Vondra [Sun, 24 Sep 2017 16:49:35 +0000 (18:49 +0200)]
Add SHOW STATS_TOTALS / STATS_AVERAGES as admin commands
We already had SHOW STATS, but after adding the wait_time colums it
got a bit too wide for regular screens. That's incovenient, as the
admin interface does not selecting only some of the columns.
But in most cases we're only interested either in totals or averages,
not both at the same time. So let's add commands showing only the
relevant subset of columns.
Tomas Vondra [Wed, 20 Sep 2017 21:22:39 +0000 (23:22 +0200)]
Track total time spent waiting for server
There already is maxwait column in pool details, showing how long
the oldest client is currently waiting. Which is useful, but it does
not allow us to easily break client time into the three basic
categories: busy, idle and waiting.
This adds tracking of total time spent waiting for a server, and
adds it as wait_time into SHOW STATS. The total value is simply
accumulated over time, the average value is 'per second' value.
The value is only updated when a client acquires a server, so if
a client is waiting indefinitely, the wait time won't be reflected
in the value. That would require inspecting the the list of waiting
clients, which seems like overkill. Moreover, that's what maxwait
is good for.
Tomas Vondra [Wed, 20 Sep 2017 19:00:17 +0000 (21:00 +0200)]
Track separate stats for queries and transactions
The documentation claimed avg_query tracks average query duration,
but it was only updated when switching into 'idle' state. So in
transaction or session pooling modes, it was actually the duration
of the whole transaction, including 'idle in transaction' time and
time spen executing (multiple) queries.
This was causing confusion, e.g. when the application was keeping
transactions open without executing any queries. In that case the
avg_query metric was increasing although the database was handling
queries just fine (without any slow-down).
Instead of just fixing the avg_query metric, it seems quite useful
to have timing data both for queries and transactions. So this
patch replaces
This is also related to the definition of 'request' which was used
to compute the avg_query, and so it equal to a transaction. This
patch replaces the counter with two - one for transactions and one
for queries. As we also computed avg_req, the patch replaces