rm -rf lib autom4te*
# clean autoconf results
-realclean: distclean
+realclean: distclean doc-realclean
rm -f aclocal* config.h.in configure depcomp install-sh missing
rm -f tags
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
+XMLTO = @XMLTO@
+ASCIIDOC = @ASCIIDOC@
+
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
AC_PROG_CC
AC_PROG_CPP
+dnl asciidoc >= 8.2
+AC_CHECK_PROGS(ASCIIDOC, asciidoc)
+if test -n "$ASCIIDOC"; then
+ AC_MSG_CHECKING([for asciidoc version >= 8.2])
+ ver=`$ASCIIDOC --version | sed 's/asciidoc //'`
+ case "$ver" in
+ [0-7].*|8.[01]|8.[01].*)
+ AC_MSG_RESULT([$ver, too old])
+ ASCIIDOC=""
+ ;;
+ *)
+ AC_MSG_RESULT([$ver, ok])
+ ;;
+ esac
+fi
+
+dnl check for xmlto, but only if asciidoc is found
+if test -n "$ASCIIDOC"; then
+ AC_CHECK_PROGS(XMLTO, xmlto)
+fi
+
dnl Additional gcc tuning
if test x"$GCC" = xyes; then
AC_MSG_CHECKING([for working warning swithces])
devupload.sh usage.txt $(wiki)/UsageInfo
devupload.sh config.txt $(wiki)/ConfigFile
+ifneq ($(XMLTO),)
pgbouncer.1: pgbouncer.cmdline.xml
xmlto man $<
pgbouncer.5: pgbouncer.config.xml
xmlto man $<
+endif
+ifneq ($(ASCIIDOC),)
%.xml: %.txt
+ #asciidoc -b docbook -d manpage -o - $< > $@
asciidoc -b docbook -d manpage -o - $< \
| python fixman.py > $@
%.html: %.txt
asciidoc -a toc $<
-
-manpage.xml: manpage.txt
- asciidoc8 -d manpage -b docbook $<
+endif
clean:
- rm -f pgbouncer.8 manpage.xml *.[1-9] *.html *.xml
+ rm -f *.html *.xml
+
+distclean: clean
-realclean distclean: clean
+realclean: distclean
+ rm -f *.[1-9]
#! /usr/bin/env python
+
import sys,re
-# add empty <simpara> after <literallayout> to force line break
-sys.stdout.write(re.sub(r"</literallayout>\s+<simpara>", r"\g<0></simpara><simpara>", sys.stdin.read()))
+
+# hacks to force empty lines into manpage
+ln1 = r"\1<simpara></simpara>\2"
+xml = sys.stdin.read()
+xml = re.sub(r"(</literallayout>\s*)(<simpara)", ln1, xml)
+xml = re.sub(r"(</variablelist>\s*)(<simpara)", ln1, xml)
+sys.stdout.write(xml)
+
--- /dev/null
+.\" Title: pgbouncer
+.\" Author:
+.\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
+.\" Date: 09/06/2007
+.\" Manual:
+.\" Source:
+.\"
+.TH "PGBOUNCER" "1" "09/06/2007" "" ""
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH "NAME"
+pgbouncer \- Lightweight connection pooler for PostgreSQL.
+.SH "SYNOPSIS"
+.sp
+.RS 4
+.nf
+pgbouncer [\-d][\-R][\-v] <pgbouncer.ini>
+pgbouncer \-V|\-h
+.fi
+.RE
+.SH "DESCRIPTION"
+pgbouncer is a PostgreSQL connection pooler. Any target application can be connected to pgbouncer as if it were a PostgreSQL server, and pgbouncer will manage to connect to the server, or to reuse one of its existing connections.
+.sp
+The aim of pgbouncer is to lower the performance impact of opening new connections to PostgreSQL.
+.sp
+In order not to compromise transaction semantics for connection pooling, pgbouncer supports several levels of brutality when rotating connections:
+.sp
+.PP
+Session pooling
+.RS 4
+Most polite method. When client connects, a server connection will be assigned to it for the whole duration it stays connected. When client disconnects, the server connection will be put back into pool.
+.RE
+.PP
+Transaction pooling
+.RS 4
+Server connection is assigned to client only during a transaction. When PgBouncer notices that transaction is over, the server will be put back into pool.
+.RE
+.PP
+Statement pooling
+.RS 4
+Most aggressive method. The server connection will be put back into pool immidiately after a query completes. Multi\-statement transactions are disallowed in this mode as they would break.
+.RE
+.sp
+The administration interface of pgbouncer consists of some new SHOW commands available when connected to a special \fIvirtual\fR database pgbouncer.
+.sp
+.SH "QUICK\-START"
+Basic setup and usage as following.
+.sp
+.TP 4
+1.
+Create config file. Details in
+pgbouncer(5). Simplest:
+.sp
+.RS 4
+.nf
+[databases]
+template1 = host=127.0.0.1 port=5432 dbname=template1
+.fi
+.RE
+.sp
+.RS 4
+.nf
+[pgbouncer]
+listen_port = 6543
+listen_addr = 127.0.0.1
+auth_type = md5
+auth_file = users.txt
+logfile = pgbouncer.log
+pidfile = pgbouncer.pid
+admin_users = someuser
+.fi
+.RE
+.TP 4
+2.
+Create users.txt file:
+.sp
+.RS 4
+.nf
+"someuser" "same_password_as_in_server"
+.fi
+.RE
+.TP 4
+3.
+Launch
+pgbouncer:
+.sp
+.RS 4
+.nf
+$ pgbouncer \-d pgbouncer.ini
+.fi
+.RE
+.TP 4
+4.
+have your application (or the
+psql
+client) connect to
+pgbouncer
+instead of directly to PostgreSQL server.
+.sp
+.RS 4
+.nf
+$ psql \-h 127.0.0.1 \-p 6543 \-U someuser template1
+.fi
+.RE
+.TP 4
+5.
+manage
+pgbouncer
+by connecting to special administration database
+pgbouncer
+and issue
+show help;
+to begin:
+.sp
+.RS 4
+.nf
+$ psql \-h 127.0.0.1 \-p 6543 \-U someuser pgbouncer
+pgbouncer=# show help;
+NOTICE: Console usage
+DETAIL:
+ SHOW [HELP|CONFIG|DATABASES|FDS|POOLS|CLIENTS|SERVERS|SOCKETS|LISTS|VERSION]
+ SET key = arg
+ RELOAD
+ PAUSE
+ SUSPEND
+ RESUME
+ SHUTDOWN
+.fi
+.RE
+.TP 4
+6.
+If you change some changeable configuration settings in the configuration file, you can reload the file with:
+.sp
+.RS 4
+.nf
+pgbouncer=# RELOAD;
+.fi
+.RE
+.SH "COMMAND LINE SWITCHES"
+.PP
+\-d
+.RS 4
+Run in background. Without it the process will run in foreground.
+.RE
+.PP
+\-R
+.RS 4
+Do a online restart. That means connecting to running process, loading open sockets from it and using them.
+.RE
+.PP
+\-v
+.RS 4
+Increase verbosity.
+.RE
+.PP
+\-V
+.RS 4
+Show version.
+.RE
+.PP
+\-h
+.RS 4
+Show short help.
+.RE
+.SH "ADMIN CONSOLE"
+Console is available by connecting into standard listen_addr/listen_port and specifying string pgbouncer as database.
+.sp
+.sp
+.RS 4
+.nf
+$ psql \-h 127.0.0.1 \-p 6543 pgbouncer
+.fi
+.RE
+.SS "SHOW COMMANDS"
+There is always a extra database available: "pgbouncer". When connecected to it, there is possible to look and change pooler settings.
+.sp
+The SHOW commands output some rows, the columns contained are described here.
+.sp
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSHOW STATS;\fR
+.RS
+Shows statistics.
+.sp
+.PP
+database
+.RS 4
+Statistics are presented per database.
+.RE
+.PP
+total_requests
+.RS 4
+Total number of
+SQL
+requests pooled by
+pgbouncer.
+.RE
+.PP
+total_received
+.RS 4
+Total volume in bytes of network trafic received by
+pgbouncer.
+.RE
+.PP
+total_sent
+.RS 4
+Total volume in bytes of network trafic sent by
+pgbouncer.
+.RE
+.PP
+total_query_time
+.RS 4
+Total number of milliseconds spent by
+pgloader
+when actively connected to PostgreSQL.
+.RE
+.PP
+avg_req
+.RS 4
+Average requests per second in last stat period.
+.RE
+.PP
+avg_recv
+.RS 4
+Average received (from clients) bytes per second.
+.RE
+.PP
+avg_sent
+.RS 4
+Average sent (to clients) bytes per second.
+.RE
+.PP
+avg_query
+.RS 4
+Average query duration in milliseconds.
+.RE
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSHOW SERVERS;\fR
+.RS
+.PP
+type
+.RS 4
+S, for server.
+.RE
+.PP
+user
+.RS 4
+
+pgbouncer
+connected user.
+.RE
+.PP
+database
+.RS 4
+database name.
+.RE
+.PP
+state
+.RS 4
+State of the pgbouncer server connection, one of
+active,
+used
+or
+idle.
+.RE
+.PP
+addr
+.RS 4
+IP address of PostgreSQL server.
+.RE
+.PP
+port
+.RS 4
+Port of PostgreSQL server.
+.RE
+.PP
+connect_time
+.RS 4
+When the connection was made.
+.RE
+.PP
+request_time
+.RS 4
+When last request was issued.
+.RE
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSHOW CLIENTS;\fR
+.RS
+.PP
+type
+.RS 4
+C, for client.
+.RE
+.PP
+user
+.RS 4
+Client connected user.
+.RE
+.PP
+database
+.RS 4
+database name.
+.RE
+.PP
+state
+.RS 4
+State of the client connection, one of
+active,
+used,
+waiting
+or
+idle.
+.RE
+.PP
+addr
+.RS 4
+IP address of client.
+.RE
+.PP
+port
+.RS 4
+port client is connected to.
+.RE
+.PP
+connect_time
+.RS 4
+Timestamp of later client connection.
+.RE
+.PP
+request_time
+.RS 4
+Timestamp of later client request.
+.RE
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSHOW POOLS;\fR
+.RS
+A new pool entry is made for each couple of (database, user).
+.sp
+.PP
+database
+.RS 4
+database name.
+.RE
+.PP
+user
+.RS 4
+username.
+.RE
+.PP
+cl_active
+.RS 4
+Count of currently
+active
+client connections.
+.RE
+.PP
+cl_waiting
+.RS 4
+Count of currently
+waiting
+client connections.
+.RE
+.PP
+sv_active
+.RS 4
+Count of currently
+active
+server connections.
+.RE
+.PP
+sv_idle
+.RS 4
+Count of currently
+idle
+server connections.
+.RE
+.PP
+sv_used
+.RS 4
+Count of currently
+used
+server connections.
+.RE
+.PP
+sv_tested
+.RS 4
+Count of currently
+tested
+server connections.
+.RE
+.PP
+sv_login
+.RS 4
+Count of server connections currently
+login
+to PostgreSQL.
+.RE
+.PP
+maxwait
+.RS 4
+How long has first (oldest) client in queue waited, in second. If this start increasing, then current pool of servers does not handle requests quick enough. Reason may be either overloaded server or just too small pool_size.
+.RE
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSHOW LISTS;\fR
+.RS
+Show following internal information, in columns (not rows):
+.sp
+.PP
+databases
+.RS 4
+Count of databases.
+.RE
+.PP
+users
+.RS 4
+Count of users.
+.RE
+.PP
+pools
+.RS 4
+Count of pools.
+.RE
+.PP
+free_clients
+.RS 4
+Count of free clients.
+.RE
+.PP
+used_clients
+.RS 4
+Count of used clients.
+.RE
+.PP
+login_clients
+.RS 4
+Count of clients in
+login
+state.
+.RE
+.PP
+free_servers
+.RS 4
+Count of free servers.
+.RE
+.PP
+used_servers
+.RS 4
+Count of used servers.
+.RE
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSHOW USERS;\fR
+.RS
+Show one line per user, under the name column name.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSHOW DATABASES;\fR
+.RS
+.PP
+name
+.RS 4
+name of configured database entry.
+.RE
+.PP
+host
+.RS 4
+Host pgbouncer connects to.
+.RE
+.PP
+port
+.RS 4
+Port pgbouncer connects to.
+.RE
+.PP
+database
+.RS 4
+Actual database name pgbouncer connects to.
+.RE
+.PP
+force_user
+.RS 4
+When user is part of the connection string, the connection between pgbouncer and PostgreSQL is forced to the given user, whatever the client user.
+.RE
+.PP
+pool_size
+.RS 4
+Maximum number of server connections.
+.RE
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSHOW FDS;\fR
+.RS
+Shows list of fds in use. When the connected user has username "pgbouncer", connects thru unix socket and has same UID as running process, the actual fds are passed over connection. This mechanism is used to do online restart.
+.sp
+.PP
+fd
+.RS 4
+File descriptor numeric value.
+.RE
+.PP
+task
+.RS 4
+One of
+pooler,
+client
+or
+server.
+.RE
+.PP
+user
+.RS 4
+User of the connection using the FD.
+.RE
+.PP
+database
+.RS 4
+database of the connection using the FD.
+.RE
+.PP
+addr
+.RS 4
+IP address of the connection using the FD,
+unix
+if a unix socket is used.
+.RE
+.PP
+port
+.RS 4
+port used by the connection using the FD.
+.RE
+.PP
+cancel
+.RS 4
+cancel key for this connection.
+.RE
+.PP
+link
+.RS 4
+fd for corresponding server/client. NULL if idle.
+.RE
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSHOW CONFIG;\fR
+.RS
+Show the current configuration settings, one per row, with following columns:
+.sp
+.PP
+key
+.RS 4
+configuration variable name
+.RE
+.PP
+value
+.RS 4
+configures value
+.RE
+.PP
+changeable
+.RS 4
+Either
+yes
+or
+no, shows if the variable is changeable when running. If
+no, the variable can be changed only boot\-time.
+.RE
+.RE
+.SS "PROCESS CONTROLING COMMANDS"
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBPAUSE;\fR
+.RS
+PgBouncer tries to disconnect from all servers, first waiting for all queries to complete. The command will not return before all is done.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSUSPEND;\fR
+.RS
+All socket buffers are flushed and PgBouncer stops listening data on them. The command will not return before all is done.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBRESUME;\fR
+.RS
+Resume work from previous PAUSE or SUSPEND command.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBSHUTDOWN;\fR
+.RS
+The PgBouncer process will exit.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBRELOAD;\fR
+.RS
+The PgBouncer process will reload its configuration file and update changeable settings.
+.sp
+.RE
+.SS "SIGNALS"
+.PP
+SIGHUP
+.RS 4
+Reload config. Same as issuing command
+RELOAD;
+on console.
+.RE
+.PP
+SIGINT
+.RS 4
+Safe shutdown. Same as issuing
+PAUSE;
+and
+SHUTDOWN;
+on console.
+.RE
+.PP
+SIGTERM
+.RS 4
+Immediate shutdown. Same as issuing
+SHUTDOWN;
+on console.
+.RE
+.SS "LIBEVENT SETTINGS"
+From libevent docs:
+.sp
+.sp
+.RS 4
+.nf
+It is possible to disable support for epoll, kqueue, devpoll, poll
+or select by setting the environment variable EVENT_NOEPOLL,
+EVENT_NOKQUEUE, EVENT_NODEVPOLL, EVENT_NOPOLL or EVENT_NOSELECT,
+respectively.
+.fi
+.RE
+.sp
+.RS 4
+.nf
+By setting the environment variable EVENT_SHOW_METHOD, libevent
+displays the kernel notification method that it uses.
+.fi
+.RE
+.SS "AUTHENTICATION FILE FORMAT"
+PgBouncer needs its own user database. The users are loaded from text file that should be in same format as PostgreSQL's pg_auth/pg_pwd file.
+.sp
+.sp
+.RS 4
+.nf
+"username1" "password" ...
+"username2" "md12342345234" ...
+.fi
+.RE
+.sp
+There shoud be at least 2 fields, surrounded by double quotes. First is username and second either plain\-text or md5\-hashed password. PgBouncer ignores rest of the line.
+.sp
+Such file format allows to direct PgBouncer directly to PostgreSQL user file under data directory.
+.sp
+.SH "SEE ALSO"
+pgbouncer(5) \- configuration settings descriptions.
+.sp
+\fIhttps://developer.skype.com/SkypeGarage/DbProjects/PgBouncer\fR
+.sp
--- /dev/null
+.\" Title: pgbouncer
+.\" Author:
+.\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
+.\" Date: 09/06/2007
+.\" Manual:
+.\" Source:
+.\"
+.TH "PGBOUNCER" "5" "09/06/2007" "" ""
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH "NAME"
+pgbouncer \- Lightweight connection pooler for PostgreSQL.
+.SH "SYNOPSIS"
+.sp
+.RS 4
+.nf
+[databases]
+db = ...
+.fi
+.RE
+.sp
+.RS 4
+.nf
+[pgbouncer]
+...
+.fi
+.RE
+.SH "DESCRIPTION"
+Config file is in "ini" format. Section names are between " and ". Lines starting with ";" or "" are taken as comment and ignored. The characters ";" and "" are not recognized when they appear later in the line.
+.sp
+.SH "SECTION [PGBOUNCER]"
+.SS "Generic settings"
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBlogfile\fR
+.RS
+Specifies log file. Logging is done by open/write/close, so it can be safely rotasted, without informing pooler.
+.sp
+Default: not set.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBpidfile\fR
+.RS
+Specifies pid file. Without pidfile, the daemonization is not allowed.
+.sp
+Default: not set.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBlisten_addr\fR
+.RS
+Specifies IPv4 address, where to listen for TCP connections. Or "*" meaning \fIlisten on all addresses\fR. When not set, only unix socket connections are allowed.
+.sp
+Default: not set.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBlisten_port\fR
+.RS
+On which port to listen on. Applies to both TCP and Unix sockets.
+.sp
+Default: 6000
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBunix_socket_dir\fR
+.RS
+Specifies location for Unix sockets. Applies to both listening socket and server connections. If set to empty string, Unix sockets are disabled.
+.sp
+Default: /tmp
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBauth_file\fR
+.RS
+Load user names and passwords from this file. File format used is same as for PostgreSQL pg_auth/pg_pwd file, so can be pointed directly to backend file.
+.sp
+Default: not set.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBauth_type\fR
+.RS
+How to authenticate users.
+.sp
+.PP
+md5
+.RS 4
+Use MD5\-based password check. auth_file may contain both md5\-encrypted or plain\-text passwords. Default.
+.RE
+.PP
+crypt
+.RS 4
+Use crypt(3) based bassword check. auth_file must contain plain\-text passwords.
+.RE
+.PP
+plain
+.RS 4
+Clear\-text password is sent over wire.
+.RE
+.PP
+trust
+.RS 4
+No authentication is done. Username must still exists in auth_file.
+.RE
+.PP
+any
+.RS 4
+Like trust but username given is ignored. Requires that all databases have configured to log in as specific user.
+.RE
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBpool_mode\fR
+.RS
+Specifies when server connection is tagged as reusable for other clients.
+.sp
+.PP
+session
+.RS 4
+Server is released back to pool after client disconnects. Default.
+.RE
+.PP
+transaction
+.RS 4
+Server is released back to pool after transaction finishes.
+.RE
+.PP
+statement
+.RS 4
+Server is released back to pool after query finishes. Long transactions spanning multiple statements are disallowed in this mode.
+.RE
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBmax_client_conn\fR
+.RS
+Maximum number of client connections allowed. When increased then the file descriptor limits should also be increased. Note that actual number of file descriptiors used is more that max_client_conn. Theoretical maximum used is:
+.sp
+.sp
+.RS 4
+.nf
+max_client_conn * max_pool_size * total_databases * total_users
+.fi
+.RE
+.sp
+if each user connects under it's own username to server. If database user is specified in connect string (all users connect under same username), the theoretical maximum is:
+.sp
+.sp
+.RS 4
+.nf
+max_client_conn * max_pool_size * total_databases
+.fi
+.RE
+.sp
+The theoretical maximum is never reaches, unless somebody deliberately crafts special load for it. Still, it means you should give fds liberately.
+.sp
+Search for ulimit in your favourite shell man page.
+.sp
+Default: 100
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBdefault_pool_size\fR
+.RS
+How many server connection to allow per user/database pair. Can be overrided in per\-database config.
+.sp
+Default: 20
+.sp
+.RE
+.SS "Log settings"
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBlog_connections\fR
+.RS
+Log successful logins.
+.sp
+Default: 1
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBlog_disconnections\fR
+.RS
+Log disconnections with reasons.
+.sp
+Default: 1
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBlog_pooler_errors\fR
+.RS
+Log error messaged pooler sends to clients.
+.sp
+Default: 1
+.sp
+.RE
+.SS "Console access control"
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBadmin_users\fR
+.RS
+List of users that are allowed to run all commands on console.
+.sp
+Default: empty
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBstats_users\fR
+.RS
+List of users that are allowed to run read\-only queries on console. Thats means all SHOW commands except SHOW FDS.
+.sp
+Default: empty.
+.sp
+.RE
+.SS "Connection sanity checks, timeouts"
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBserver_check_delay\fR
+.RS
+How long to keep released immidiately available, without running sanity\-check query on it. If 0 then the query is ran always.
+.sp
+Default: 30
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBserver_check_query\fR
+.RS
+Simple do\-nothing query to check if server connection is alive.
+.sp
+If empty string, then sanity checking is disabled.
+.sp
+Default: SELECT 1;
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBserver_lifetime\fR
+.RS
+Pooler tries to close server connections that are been connected longer than this.
+.sp
+Default: 3600
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBserver_idle_timeout\fR
+.RS
+If server connection has been idle more than this then there's too many connections in the pool and this one can be dropped.
+.sp
+Default: 600
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBserver_connect_timeout\fR
+.RS
+If connection and login wont finish in this time, the connection will be closed.
+.sp
+Default: 15
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBserver_login_retry\fR
+.RS
+If login failed, because of failure from connect() or authentication that pooler waits this much before retrying to connect.
+.sp
+Default: 15
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBclient_login_timeout\fR
+.RS
+If client connect but does not manage to login in this time, it will be disconnected. Mainly needed to avoid dead connections stalling SUSPEND and thus online restart.
+.sp
+Default: 60
+.sp
+.RE
+.SS "Dangerous timeouts"
+Setting following timeouts cause unexcpected errors.
+.sp
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBquery_timeout\fR
+.RS
+Queries running longer than that are canceled. This should be used only with slightly smaller server\-side statement_timeout, to apply only for network problems.
+.sp
+Default: 0 (disabled)
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBclient_idle_timeout\fR
+.RS
+Client connections idling longer than that are closed. This should be larger then client\-side connection lifetime settings, to apply only for network problems.
+.sp
+Default: 0 (disabled)
+.sp
+.RE
+.SS "Low\-level network settings"
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBpkt_buf\fR
+.RS
+Internal buffer size for packets. Affects size of TCP packets sent and general memory usage. Actual libpq packets can be larger than this so no need to set it large.
+.sp
+Default: 2048
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBtcp_defer_accept\fR
+.RS
+Details about following options shouldbe looked from man 7 tcp
+.sp
+Default: 45 on Linux, otherwise 0
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBtcp_socket_buffer\fR
+.RS
+Default: not set
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBtcp_keepalive\fR
+.RS
+Default: Not set
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBtcp_keepcnt\fR
+.RS
+Default: not set
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBtcp_keepidle\fR
+.RS
+Default: not set
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBtcp_keepintvl\fR
+.RS
+Default: not set
+.sp
+.RE
+.SH "SECTION [DATABASES]"
+This contains key=value pairs where key will be taken as database name and value as libpq\-connstring style list of key=value pairs. As actual libpq is not used, so not all features from libpq can be used (service=, quoting).
+.sp
+.SS "Location parameters"
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBdbname\fR
+.RS
+Destination database name.
+.sp
+Default: same as client\-side database name.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBhost\fR
+.RS
+IP\-address to connect to.
+.sp
+Default: not set, meaning to use unix\-socket.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBport\fR
+.RS
+Default: 5432
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBuser, password\fR
+.RS
+If user= is set, all connections to destination database will be done with that user, meaning that there will be only one pool for this database.
+.sp
+Otherwise pgbouncer tries to log into destination database with client username, meaning that there will be one pool per user.
+.sp
+.RE
+.SS "Extra parameters"
+They allow setting default parameters on server connection.
+.sp
+Note that since version 1.1 PgBouncer honours client changes for there values, so their use in pgbouncer.ini is deprecated.
+.sp
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBclient_encoding\fR
+.RS
+Ask specific client_encoding from server.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBdatestyle\fR
+.RS
+Ask specific datestyle from server.
+.sp
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+\fBtimezone\fR
+.RS
+Ask specific timezone from server.
+.sp
+.RE
+.SH "EXAMPLE"
+.SS "Minimal config"
+.sp
+.RS 4
+.nf
+[databases]
+template1 = host=127.0.0.1 dbname=template1
+.fi
+.RE
+.sp
+.RS 4
+.nf
+[pgbouncer]
+pool_mode = session
+listen_port = 6543
+listen_addr = 127.0.0.1
+auth_type = md5
+auth_file = users.txt
+logfile = pgbouncer.log
+pidfile = pgbouncer.pid
+admin_users = someuser
+stats_users = stat_collector
+.fi
+.RE
+.SS "Database defaults"
+.sp
+.RS 4
+.nf
+[databases]
+.fi
+.RE
+.sp
+.RS 4
+.nf
+; foodb over unix socket
+foodb =
+.fi
+.RE
+.sp
+.RS 4
+.nf
+; redirect bardb to bazdb on localhost
+bardb = host=127.0.0.1 dbname=bazdb
+.fi
+.RE
+.sp
+.RS 4
+.nf
+; acceess to dest database will go with single user
+forcedb = host=127.0.0.1 port=300 user=baz password=foo client_encoding=UNICODE datestyle=ISO
+.fi
+.RE
+.SH "SEE ALSO"
+pgbouncer(1)
+.sp
+\fIhttps://developer.skype.com/SkypeGarage/DbProjects/PgBouncer\fR
+.sp