pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Rijkers <er@xs4all.nl>
To: pgsql-bugs@postgresql.org
Subject: pgbench confused between service + PGPORT
Date: Thu, 17 Mar 2016 21:16:45 +0000
Message-ID: <e83918c316a773ace4b6a3cc13fac417@xs4all.nl> (raw)
In-Reply-To: <a29046e6807dad3437d3058792232b30@xs4all.nl>
References: <a29046e6807dad3437d3058792232b30@xs4all.nl>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

I noticed that pgbench gets confused about what instance to connect to 
when there is both a service *and* an PGPORT given.

I can avoid it rather easily but I report it as it looks like a bug to 
me; I can't think of a reason why it might be deliberate behaviour.


Below is a test case where:
instance 9.5 and 9.6 have
database testdb95 and testdb96, and
services '95' and '96'.


$ cat benchservice.sh

# wipe out PG* variables
unset PGSERVICEFILE PGSERVICE PGPORT PGDATA PGHOST PGDATABASE PGPASSFILE

export PGSERVICEFILE=$HOME/.pg_service.conf PGSERVICE=95 
PGPASSFILE=$HOME/.pg_aardvark

cat $PGSERVICEFILE

env | grep PG

which pgbench
pgbench --version

# these two calls to pgbench are OK (PGPORT is unset)
pgbench -qis 1 "service=95"
pgbench -qis 2 "service=96"

# just to show that both calls succeeded, and in the right database:
echo 'show port; \dt+ pgbench_accounts' | psql -X "service=95"
echo 'show port; \dt+ pgbench_accounts' | psql -X "service=96"


# now, with PGPORT set to the 9.6 instance, the same pgbench invocation 
(with a service) will fail:

export PGPORT=6546

pgbench -qis 1 "service=95"

#--------------------------

And its output:

$ ./benchservice.sh
[96]
port=6546
host=/tmp
user=aardvark
dbname=testdb96

[95]
port=6545
host=/tmp
user=aardvark
dbname=testdb95

PGSERVICEFILE=/home/aardvark/.pg_service.conf
PGSERVICE=95
PGPASSFILE=/home/aardvark/.pg_aardvark
/opt/pgsql95/bin/pgbench
pgbench (PostgreSQL) 9.5.1
creating tables...
100000 of 100000 tuples (100%) done (elapsed 0.11 s, remaining 0.00 s)
vacuum...
set primary keys...
done.
creating tables...
200000 of 200000 tuples (100%) done (elapsed 0.25 s, remaining 0.00 s)
vacuum...
set primary keys...
done.
  port
------
  6545
(1 row)

                          List of relations
  Schema |       Name       | Type  |  Owner   | Size  | Description
--------+------------------+-------+----------+-------+-------------
  public | pgbench_accounts | table | aardvark | 13 MB |
(1 row)

  port
------
  6546
(1 row)

                          List of relations
  Schema |       Name       | Type  |  Owner   | Size  | Description
--------+------------------+-------+----------+-------+-------------
  public | pgbench_accounts | table | aardvark | 26 MB |
(1 row)

connection to database "service=95" failed:
FATAL:  database "testdb95" does not exist


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



Message-ID: <e83918c316a773ace4b6a3cc13fac417@xs4all.nl>
Permalink:  ../e83918c316a773ace4b6a3cc13fac417@xs4all.nl/
Also on:    postgresql.org/message-id/e83918c316a773ace4b6a3cc13fac417@xs4all.nl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: er@xs4all.nl
  Subject: Re: pgbench confused between service + PGPORT
  In-Reply-To: <e83918c316a773ace4b6a3cc13fac417@xs4all.nl>
  References: <a29046e6807dad3437d3058792232b30@xs4all.nl> <e83918c316a773ace4b6a3cc13fac417@xs4all.nl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox