Connection to the database fails - Mailing list pgsql-bugs

From vganapathy@hss.hns.com
Subject Connection to the database fails
Date
Msg-id 65256D27.0042755A.00@sampark.hss.hns.com
Whole thread Raw
List pgsql-bugs
Hi All,

PostgreSQL version - 7.2.1
Client Library - Solaris 5.8
Database server - Linux

I am facing a problem while developing an application
that connects to the postgresql database through a
seperate thread. Let me explain the problem and the
approches that I tried to overcome the issue...

1) I am developing an application that launches a thread
which tries to connect to the database through the PQconnectdb
call.

2) When I tried to get the status of the connection the return
value was CONNECTION_BAD.

I observed the following strange behaviours

a) When I tried to do the same operation from the main thread rather
than from the newly launched thread the connection got established
successfully.

b) I opened up the postgres source and analysed the failure point.
In the connectDBStart connect system call was returning an error
code EADDRINUSE.

c) Commented out the invocation of connectMakeNonblocking in the
same function. This makes the connect system call block until the
connection succeed. This time the connection got established
successfully.

d) Ignored the error returned by the connect and went ahead to
select on the  socket. Even in this case the connection succeeds.

e) Wrote a stub that would listen on 5432 (a stub instead of the
postmaster). The client library connected successfully.


Whenever the connection fails the error code is 125 EADDRINUSE.
Checked the following range of ephemeral ports on both client
and server systems the range was 32768 to 61000.

Can you please help me getting through this issue. Has it got
something to do with the threading or something to do with my
OS settings...if that is the case how could the connection
succeed consistently when tried from the main thread.

Can you please give me some pointers in solving this issue.

Thnx in advance,

Regards,
- Vijay






This message is proprietary to Hughes Software Systems Limited (HSS) and is
intended solely for the use of the individual to whom it is addressed.  It
may contain privileged or confidential information and should not be
circulated or used for any purpose other than for what it is intended.  If
you have received this message in error, please notify the originator
immediately.  If you are not the intended recipient, you are notified that
you are strictly prohibited from using, copying, altering, or disclosing
the contents of this message.  HSS accepts no responsibility for loss or
damage arising from the use of the information transmitted by this email
including damage from virus.

pgsql-bugs by date:

Previous
From: Todd Nemanich
Date:
Subject: Re: shared memory corruption
Next
From: "scott.marlowe"
Date:
Subject: Re: [PERFORM] [SQL] Unanswered Questions WAS: An unresolved performance