pgbouncer-admin

PgBouncer Administration Console.

Synopsis

  1. psql -p <port> pgbouncer

Description

The PgBouncer Adminstration Console is available via psql. Connect to the PgBouncer port and the virtual database named pgbouncer to log in to the console.

Users listed in the pgbouncer.ini configuration parameters admin_users and stats_users have privileges to log in to the PgBouncer Administration Console.

You can control connections between PgBouncer and Greenplum Database from the console. You can also set PgBouncer configuration parameters.

Options

-p port

The PgBouncer port number.

Command Syntax

  1. pgbouncer=# SHOW help;
  2. NOTICE: Console usage
  3. DETAIL:
  4. SHOW HELP|CONFIG|DATABASES|POOLS|CLIENTS|SERVERS|VERSION
  5. SHOW FDS|SOCKETS|ACTIVE_SOCKETS|LISTS|MEM
  6. SHOW DNS_HOSTS|DNS_ZONES
  7. SHOW STATS|STATS_TOTALS|STATS_AVERAGES
  8. SET key = arg
  9. RELOAD
  10. PAUSE [<db>]
  11. RESUME [<db>]
  12. DISABLE <db>
  13. ENABLE <db>
  14. KILL <db>
  15. SUSPEND
  16. SHUTDOWN

Administration Commands

The following PgBouncer administration commands control the running pgbouncer process.

PAUSE [db]

If no database is specified, PgBouncer tries to disconnect from all servers, first waiting for all queries to complete. The command will not return before all queries are finished. This command is to be used to prepare to restart the database.

If a database name is specified, PgBouncer pauses only that database.

If you run a PAUSE db command, and then a PAUSE command to pause all databases, you must execute two RESUME commands, one for all databases, and one for the named database.

SUSPEND

All socket buffers are flushed and PgBouncer stops listening for data on them. The command will not return before all buffers are empty. To be used when rebooting PgBouncer online.

RESUME [ db ]

Resume work from a previous PAUSE or SUSPEND command.

If a database was specified for the PAUSE command, the database must also be specified with the RESUME command.

After pausing all databases with the PAUSE command, resuming a single database with RESUME db is not supported.

DISABLE db

Reject all new client connections on the database.

ENABLE db

Allow new client connections on the database.

KILL db

Immediately drop all client and server connections to the named database.

SHUTDOWN

Stop PgBouncer process. To exit from the psql command line session, enter \q.

RELOAD

The PgBouncer process reloads the current configuration file and updates the changeable settings.

SET key = value

Override specified configuration setting. See the SHOW CONFIG; command.

SHOW Command

The SHOW category command displays different types of PgBouncer information. You can specify one of the following categories:

ACTIVE_SOCKETS

ColumnDescription
typeS, for server, C for client.
userUsername pgbouncer uses to connect to server.
databaseDatabase name.
stateState of the server connection, one of active, used or idle.
addrIP address of PostgreSQL server.
portPort of PostgreSQL server.
local_addrConnection start address on local machine.
local_portConnection start port on local machine.
connect_timeWhen the connection was made.
request_timeWhen last request was issued.
waitTime waiting.
wait_usTime waiting (microseconds).
ptrAddress of internal object for this connection. Used as unique ID.
linkAddress of client connection the server is paired with.
remote_pidProcess identifier of backend server process.
tlsTLS context.
recv_posReceive position in the I/O buffer.
pkt_posParse position in the I/O buffer.
pkt_remainNumber of packets remaining on the socket.
send_posSend position in the packet.
send_remainTotal packet length remaining to send.
pkt_availAmount of I/O buffer left to parse.
send_availAmount of I/O buffer left to send.

CLIENTS

ColumnDescription
typeC, for client.
userClient connected user.
databaseDatabase name.
stateState of the client connection, one of active, used, waiting or idle.
addrIP address of client, or unix for a socket connection.
portPort client is connected to.
local_addrConnection end address on local machine.
local_portConnection end port on local machine.
connect_timeTimestamp of connect time.
request_timeTimestamp of latest client request.
waitTime waiting.
wait_usTime waiting (microseconds).
ptrAddress of internal object for this connection. Used as unique ID.
linkAddress of server connection the client is paired with.
remote_pidProcess ID, if client connects with Unix socket and the OS supports getting it.
tlsClient TLS context.

CONFIG

List of current PgBouncer parameter settings

ColumnDescription
keyConfiguration variable name
valueConfiguration value
changeableEither yes or no. Shows whether the variable can be changed while running. If no, the variable can be changed only at boot time.

DATABASES

ColumnDescription
nameName of configured database entry.
hostHost pgbouncer connects to.
portPort pgbouncer connects to.
databaseActual database name pgbouncer connects to.
force_userWhen user is part of the connection string, the connection between pgbouncer and the database server is forced to the given user, whatever the client user.
pool_sizeMaximum number of server connections.
reserve_poolThe number of additional connections that can be created if the pool reaches pool_size.
pool_modeThe database’s override pool_mode or NULL if the default will be used instead.
max_connectionsMaximum number of connections for all pools for this database.
current_connectionsThe total count of connections for all pools for this database.
pausedPaused/unpaused state of the database.
deactivatedEnabled/deactivated state of the database.

DNS_HOSTS

ColumnDescription
hostnameHost name
ttlHow many seconds until next lookup.
addrsComma-separated list of addresses.

DNS_ZONES

ColumnDescription
zonenameZone name
serialCurrent DNS serial number
countHostnames belonging to this zone

FDS

SHOW FDS is an internal command used for an online restart, for example when upgrading to a new PgBouncer version. It displays a list of file descriptors in use with the internal state attached to them. This command blocks the internal event loop, so it should not be used while PgBouncer is in use.

When the connected user has username “pgbouncer”, connects through a Unix socket, and has the same UID as the running process, the actual file descriptors are passed over the connection.

ColumnDescription
fdFile descriptor numeric value.
taskOne of pooler, client, or server.
userUser of the connection using the file descriptor.
databaseDatabase of the connection using the file descriptor.
addrIP address of the connection using the file descriptor, “unix” if a Unix socket is used.
portPort used by the connection using the file descriptor.
cancelCancel key for this connection.
linkFile descriptor for corresponding server/client. NULL if idle.
client_encodingCharacter set used for the database.
std_stringsThis controls whether ordinary string literals (‘…’) treat backslashes literally, as specified in the SQL standard.
datestyleDisplay format for date and time values.
timezoneThe timezone for interpreting and displaying time stamps.
passwordauth_user‘s password.

LISTS

Shows the following PgBouncer statistcs in two columns: the item label and value.

ItemDescription
databasesCount of databases.
usersCount of users.
poolsCount of pools.
free_clientsCount of free clients.
used_clientsCount of used clients.
login_clientsCount of clients in login state.
free_serversCount of free servers.
used_serversCount of used servers.
dns_namesCount of DNS names.
dns_zonesCount of DNS zones.
dns_queriesCount of DNS queries.
dns_pendingCount of in-flight DNS queries.

MEM

Shows cache memory information for these PgBouncer caches:

  • user_cache
  • db_cache
  • pool_cache
  • server_cache
  • client_cache
  • iobuf_cache
ColumnDescription
nameName of cache.
sizeThe size of a single slot in the cache.
usedNumber of used slots in the cache.
freeThe number of available slots in the cache.
memtotalTotal bytes used by the cache.

POOLS

A new pool entry is made for each pair of (database, user).

ColumnDescription
databaseDatabase name.
userUser name.
cl_activeClient connections that are linked to server connection and can process queries.
cl_waitingClient connections have sent queries but have not yet got a server connection.
sv_activeServer connections that linked to client.
sv_idleServer connections that are unused and immediately usable for client queries.
sv_usedServer connections that have been idle more than server_check_delay. The server_check_query query must be run on them before they can be used.
sv_testedServer connections that are currently running either server_reset_query or server_check_query.
sv_loginServer connections currently in process of logging in.
maxwaitHow long the first (oldest) client in the queue has waited, in seconds. If this begins to increase, the current pool of servers does not handle requests fast enough. The cause may be either an overloaded server or the pool_size setting is too small.
maxwait_usmax_wait (microseconds).
pool_modeThe pooling mode in use.

SERVERS

ColumnDescription
typeS, for server.
userUser ID that pgbouncer uses to connect to server.
databaseDatabase name.
stateState of the pgbouncer server connection, one of active, used, or idle.
addrIP address of the Greenplum or PostgreSQL server.
portPort of the Greenplum or PostgreSQL server.
local_addrConnection start address on local machine.
local_portConnection start port on local machine.
connect_timeWhen the connection was made.
request_timeWhen the last request was issued.
waitTime waiting.
wait_usTime waiting (microseconds).
ptrAddress of the internal object for this connection. Used as unique ID.
linkAddress of gthe client connection the server is paired with.
remote_pidPid of backend server process. If the connection is made over Unix socket and the OS supports getting process ID info, it is the OS pid. Otherwise it is extracted from the cancel packet the server sent, which should be PID in case server is PostgreSQL, but it is a random number in case server is another PgBouncer.
tlsTLS context.

STATS

Shows statistics.

ColumnDescription
databaseStatistics are presented per database.
total_xact_countTotal number of SQL transactions pooled by PgBouncer.
total_query_countTotal number of SQL queries pooled by PgBouncer.
total_receivedTotal volume in bytes of network traffic received by pgbouncer.
total_sentTotal volume in bytes of network traffic sent by pgbouncer.
total_xact_timeTotal number of microseconds spent by PgBouncer when connected to Greenplum Database in a transaction, either idle in transaction or executing queries.
total_query_timeTotal number of microseconds spent by pgbouncer when actively connected to the database server.
total_wait_timeTime spent (in microseconds) by clients waiting for a server.
avg_xact_countAverage number of SQL transactions pooled by PgBouncer.
avg_query_countAverage queries per second in last stats period.
avg_recvAverage received (from clients) bytes per second.
avg_sentAverage sent (to clients) bytes per second.
avg_xact_timeAverage transaction duration in microseconds.
avg_query_timeAverage query duration in microseconds.
avg_wait_timeTime spent by clients waiting for a server in microseconds (average per second).

STATS_AVERAGES

Subset of SHOW STATS showing the average values for selected statistics.

STATS_TOTALS

Subset of SHOW STATS showing the total values for selected statistics.

USERS

ColumnDescription
nameThe user name
pool_modeThe user’s override pool_mode, or NULL if the default will be used instead.

VERSION

Display PgBouncer version information.

Note: This reference documentation is based on the PgBouncer 1.8.1 documentation.

See Also

pgbouncer, pgbouncer.ini