Thread: BUG #1088: Name resolution connecting to a database

BUG #1088: Name resolution connecting to a database

From
"PostgreSQL Bugs List"
Date:
The following bug has been logged online:

Bug reference:      1088
Logged by:          Antonino Albanese

Email address:      al.an@sitvallee.it

PostgreSQL version: 7.4

Operating system:   Linux server.sitvallee.it 2.4.20-28.7smp #1 SMP Thu Dec
18 11:18:31 EST 2003 i686 unknown

Description:        Name resolution connecting to a database

Details:

I'm using postgresql 7.4.1 exactly the rpm version:
nino@server:~$ rpm -qva|grep -i postgresql
postgresql-docs-7.4.1-1PGDG
postgresql-devel-7.4.1-1PGDG
postgresql-contrib-7.4.1-1PGDG
postgresql-server-7.4.1-1PGDG
postgresql-libs-7.4.1-1PGDG
postgresql-7.4.1-1PGDG
postgresql-pl-7.4.1-1PGDG

on a 7.3 RH Server:
Linux server.sitvallee.it 2.4.20-28.7smp #1 SMP Thu Dec 18 11:18:31 EST 2003
i686 unknown

all the tests where done directly on the database
server, but I've got the same behavior from different
clients, either using psql or the php interface

trying to connect to the server with domain name
takes long time, here an example:
nino@server:~$ time psql -h server -d newtestdb -U download -c '\q'

real    0m10.151s
user    0m0.010s
sys    0m0.000s

but every thing works fine if I use the IP address:
nino@server:~$ time psql -h 192.168.0.1 -d newtestdb -U download -c '\q'

real    0m0.023s
user    0m0.000s
sys    0m0.020s

here the content of my configuration files:
------------------------------------
/var/lib/pgsql/data/pg_hba.conf
------------------------------------
local  all    all             ident   sameuser
host    sitvallee    download    192.168.0.0    255.255.255.0    trust
host    newtestdb    download    192.168.0.0    255.255.255.0    trust
host    all    all    127.0.0.1    255.255.255.255    md5
host    all    all    192.168.0.0    255.255.255.0    md5

------------------------------------
/var/lib/pgsql/data/postgresql.conf
------------------------------------
tcpip_socket = true
max_connections = 100
shared_buffers = 64000
sort_mem = 8192
effective_cache_size = 8000
datestyle = 'sql, european'
LC_MESSAGES = 'C'
LC_MONETARY = 'C'
LC_NUMERIC = 'C'
LC_TIME = 'C'

------------------------------------
/etc/host.conf
------------------------------------
order hosts,bind

------------------------------------
/etc/hosts
------------------------------------
127.0.0.1        localhost    local     # loopback
# Local Network.
192.168.0.13        capo.sitvallee.it    capo
192.168.0.14        laptop.sitvallee.it    laptop
192.168.0.10        devwin.sitvallee.it    devwin
192.168.0.12        devgis.sitvallee.it    devgis
192.168.0.11        devweb.sitvallee.it    devweb
192.168.0.230        printer.sitvallee.it    printer
192.168.0.1        server.sitvallee.it    server
192.168.0.2        gateway.sitvallee.it    gateway
192.168.0.5        switch.sitvallee.it    switch

Hope I gave every needed information

Sincerely
Nino

Re: BUG #1088: Name resolution connecting to a database

From
Tom Lane
Date:
"PostgreSQL Bugs List" <pgsql-bugs@postgresql.org> writes:
> trying to connect to the server with domain name
> takes long time, here an example:
> ...
> but every thing works fine if I use the IP address:

There's something wrong with your DNS setup.  You'll probably find that
the same delay occurs with any program that tries to resolve a host name
(if in doubt, try "nslookup server").

I'd bet that your /etc/resolv.conf is pointing at a dead nameserver.

            regards, tom lane

Re: BUG #1088: Name resolution connecting to a database

From
Richard Huxton
Date:
On Tuesday 02 March 2004 14:09, PostgreSQL Bugs List wrote:
> The following bug has been logged online:
>
> Bug reference:      1088
> Logged by:          Antonino Albanese
> Email address:      al.an@sitvallee.it

> Description:        Name resolution connecting to a database

> trying to connect to the server with domain name
> takes long time, here an example:
> nino@server:~$ time psql -h server -d newtestdb -U download -c '\q'
>
> real    0m10.151s
> user    0m0.010s
> sys    0m0.000s

This looks like a problem in your DNS setup rather than PostgreSQL - the 10
minutes is a timeout. Possibly with reverse lookup. You may see similar
problems with a mailserver if you are running one (and mailserver lists are a
good place to search too).

You may want to investigate /etc/resolv.conf on both machines as well as the
dig/host commands. Don't forget it could be a problem with server A lookup up
server B or vice versa.

HTH
--
  Richard Huxton
  Archonet Ltd