Re: PATCH: pgagent connection string parsing

From: Thomas Krennwallner <tk+pgsql(at)postsubmeta(dot)net>
To: pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: PATCH: pgagent connection string parsing
Date: 2017-08-21 05:22:03
Message-ID: 20170821052203.GD23580@postsubmeta.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

On Mon Aug 21, 2017 06:50:03AM +0530, Ashesh Vashi wrote:
> On Aug 20, 2017 22:48, "Thomas Krennwallner" <[1]tk+pgsql(at)postsubmeta(dot)net>
> wrote:
>
> % ./pgagent -f -t60 -l2 dbname=xxx user=tkren connection_timeout=5
[...]
> Sun Aug 20 18:24:34 2017 : DEBUG: Creating DB connection: user=tkren connection_timeout=5 dbname=xxx
> Sun Aug 20 18:24:34 2017 : WARNING: Couldn't create the primary connection (attempt 1): invalid connection option "connection_timeout"
>
> This suggests pgAgent is not using the latest version of libpq.
> Please use LD_LIBRARY_PATH environment to inform pgAgent to use the libpq,
> it is compiled with.
> -- Thanks,
> Ashesh Vashi
> -- Thanks, Ashesh

Unfortunately, this does not work. On a current Debian sid system,
I've compiled pgagent from source and get

% ldd ./pgagent
[...]
libpq.so.5 => /usr/lib/x86_64-linux-gnu/libpq.so.5 (0x00007ff531382000)
[...]

The system has libpq 9.6.4 installed:

% apt-cache show libpq5
Package: libpq5
Source: postgresql-9.6
Version: 9.6.4-1
[...]

If I run pgagent from the Debian package (same ldd linkage), I get the
same error:

% /usr/bin/pgagent -f -t60 -l2 dbname=xxx user=tkren connection_timeout=5
[...]
Mon Aug 21 06:51:04 2017 : DEBUG: Creating DB connection: user=tkren connection_timeout=5 dbname=xxx
Mon Aug 21 06:51:04 2017 : WARNING: Couldn't create the primary connection (attempt 1): invalid connection option "connection_timeout"
[...]

But I don't get why connection_timeout should work at all, the
libpq documentation
https://www.postgresql.org/docs/9.6/static/libpq-connect.html#LIBPQ-CONNECT-CONNECT-TIMEOUT
states that the keyword is

connect_timeout

Maximum wait for connection, in seconds (write as a decimal
integer string). Zero or not specified means wait indefinitely. It
is not recommended to use a timeout of less than 2 seconds.

libpq.so seems to only mention connect_timeout:

% strings /usr/lib/x86_64-linux-gnu/libpq.so.5 | egrep 'connect(ion)?_timeout'
connect_timeout

The libpq source implements it in src/interfaces/libpq/fe-connect.c,
but after a quick check I didn't see a special treatment for
connection_timeout:

{"connect_timeout", "PGCONNECT_TIMEOUT", NULL, NULL,
"Connect-timeout", "", 10, /* strlen(INT32_MAX) == 10 */
offsetof(struct pg_conn, connect_timeout)},

And psql dislikes connection_timeout as well:

% psql 'dbname=xxx user=tkren connection_timeout=5'
psql: invalid connection option "connection_timeout"

% psql 'dbname=xxx user=tkren connect_timeout=5'
psql (9.6.4)
Type "help" for help.

xxx=#

TK

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Ashesh Vashi 2017-08-21 05:24:45 Re: PATCH: pgagent connection string parsing
Previous Message Ashesh Vashi 2017-08-21 01:20:03 Re: PATCH: pgagent connection string parsing