Someone's broken psql's connection-failure error reporting

Started by Tom Lanealmost 23 years ago12 messages
#1Tom Lane
tgl@sss.pgh.pa.us

In CVS tip, I'm getting only an empty string from psql where it should
print connection-failure messages.

psql 7.3 does this:

$ psql -p 5555
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5555"?
$

CVS tip does this:

$ psql -p 5555
psql: $

Have not dug to see if this is the fault of libpq or psql; but there's
been a fair amount of hacking lately in libpq's connection handling ...

regards, tom lane

#2Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#1)
Re: Someone's broken psql's connection-failure error reporting

Tom Lane wrote:

In CVS tip, I'm getting only an empty string from psql where it should
print connection-failure messages.

psql 7.3 does this:

$ psql -p 5555
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5555"?
$

CVS tip does this:

$ psql -p 5555
psql: $

Have not dug to see if this is the fault of libpq or psql; but there's
been a fair amount of hacking lately in libpq's connection handling ...

I just tried and got an error:

$ psql -p 5555
psql: could not create socket: No such file or directory

This is as of last night's CVS.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
Re: Someone's broken psql's connection-failure error reporting

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

In CVS tip, I'm getting only an empty string from psql where it should
print connection-failure messages.

[ it works here ]

Speculation time: do you have the IPv6 code compiled in? I don't.

regards, tom lane

#4Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#3)
Re: Someone's broken psql's connection-failure error reporting

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

In CVS tip, I'm getting only an empty string from psql where it should
print connection-failure messages.

[ it works here ]

Speculation time: do you have the IPv6 code compiled in? I don't.

I have IPv6 enabled in the binary, but not the kernel.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#5Shahbaz Chaudhary
chaudhar@umich.edu
In reply to: Tom Lane (#3)
java access to the backend (non jdbc)?

Hi All,
I was wondering if there is a libq or libqxx type library written in
java. Even if it is done through jni. I would like to do some
experiments, perhaps make a utility that reads server information such
as currently executing query, current locks, amount of disk/ram taken up
by pgsql. Basically some very useful information for admins. I've
forgotten most of C, C++ (from college days), but would love to try my
hand at such a utility...I'm sure there are others who would like to use
java to access such a backend. Any pointers?

Shahbaz C.

#6Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Shahbaz Chaudhary (#5)
Re: java access to the backend (non jdbc)?

Well, we have jdbc at jdbc.postgresql.org.

---------------------------------------------------------------------------

Shahbaz Chaudhary wrote:

Hi All,
I was wondering if there is a libq or libqxx type library written in
java. Even if it is done through jni. I would like to do some
experiments, perhaps make a utility that reads server information such
as currently executing query, current locks, amount of disk/ram taken up
by pgsql. Basically some very useful information for admins. I've
forgotten most of C, C++ (from college days), but would love to try my
hand at such a utility...I'm sure there are others who would like to use
java to access such a backend. Any pointers?

Shahbaz C.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#7Shahbaz Chaudhary
chaudhar@umich.edu
In reply to: Bruce Momjian (#6)
Re: java access to the backend (non jdbc)?

Sorry, I don't think I made myself clear. I don't want to query the DB
every few seconds to get its current status. I want to keep an open an
open connection and have immediate access to all information like I have
when I set the debug level high and see everything going on inside the
DB right on my machine.

I guess think of it as a dashboard that constantly displays the db
status. Something like 'top' rather than 'ps -ef|grep .....'.

As far as I understand, JDBC is just a mechanism to connect to a db,
execute queries, etc., not get this kind of info.

Shahbaz C.

-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Bruce Momjian
Sent: Thursday, February 13, 2003 7:18 PM
To: Shahbaz Chaudhary
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] java access to the backend (non jdbc)?

Well, we have jdbc at jdbc.postgresql.org.

------------------------------------------------------------------------
---

Shahbaz Chaudhary wrote:

Hi All,
I was wondering if there is a libq or libqxx type library written in
java. Even if it is done through jni. I would like to do some
experiments, perhaps make a utility that reads server information such
as currently executing query, current locks, amount of disk/ram taken

up

by pgsql. Basically some very useful information for admins. I've
forgotten most of C, C++ (from college days), but would love to try my
hand at such a utility...I'm sure there are others who would like to

use

java to access such a backend. Any pointers?

Shahbaz C.

---------------------------(end of

broadcast)---------------------------

TIP 6: Have you searched our list archives?

http://archives.postgresql.org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania
19073

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

#8Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Shahbaz Chaudhary (#7)
Re: java access to the backend (non jdbc)?

Well, I wrote pgmonitor on gborg.postgresql.org, which is like top for
PostgreSQL, but is in TCL. It uses ps internally.

---------------------------------------------------------------------------

Shahbaz Chaudhary wrote:

Sorry, I don't think I made myself clear. I don't want to query the DB
every few seconds to get its current status. I want to keep an open an
open connection and have immediate access to all information like I have
when I set the debug level high and see everything going on inside the
DB right on my machine.

I guess think of it as a dashboard that constantly displays the db
status. Something like 'top' rather than 'ps -ef|grep .....'.

As far as I understand, JDBC is just a mechanism to connect to a db,
execute queries, etc., not get this kind of info.

Shahbaz C.

-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Bruce Momjian
Sent: Thursday, February 13, 2003 7:18 PM
To: Shahbaz Chaudhary
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] java access to the backend (non jdbc)?

Well, we have jdbc at jdbc.postgresql.org.

------------------------------------------------------------------------
---

Shahbaz Chaudhary wrote:

Hi All,
I was wondering if there is a libq or libqxx type library written in
java. Even if it is done through jni. I would like to do some
experiments, perhaps make a utility that reads server information such
as currently executing query, current locks, amount of disk/ram taken

up

by pgsql. Basically some very useful information for admins. I've
forgotten most of C, C++ (from college days), but would love to try my
hand at such a utility...I'm sure there are others who would like to

use

java to access such a backend. Any pointers?

Shahbaz C.

---------------------------(end of

broadcast)---------------------------

TIP 6: Have you searched our list archives?

http://archives.postgresql.org

-- 
Bruce Momjian                        |  http://candle.pha.pa.us
pgman@candle.pha.pa.us               |  (610) 359-1001
+  If your life is a hard drive,     |  13 Roberts Road
+  Christ can be your backup.        |  Newtown Square, Pennsylvania
19073

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#4)
Re: Someone's broken psql's connection-failure error reporting

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

Speculation time: do you have the IPv6 code compiled in? I don't.

I have IPv6 enabled in the binary, but not the kernel.

Sure enough, the IPV6 patch had broken error handling in the non-IPV6
path.

I've done a little bit of cleanup, but that code is still a mess...
someone should rewrite these routines.

regards, tom lane

#10Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#9)
Re: Someone's broken psql's connection-failure error reporting

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

Speculation time: do you have the IPv6 code compiled in? I don't.

I have IPv6 enabled in the binary, but not the kernel.

Sure enough, the IPV6 patch had broken error handling in the non-IPV6
path.

I've done a little bit of cleanup, but that code is still a mess...
someone should rewrite these routines.

Yes, I looked at it and struggled to get both IPv4 and IPv6 cleanly
working. Any ideas on how to improve it?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#11Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#10)
Re: Someone's broken psql's connection-failure error reporting

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

I've done a little bit of cleanup, but that code is still a mess...
someone should rewrite these routines.

Yes, I looked at it and struggled to get both IPv4 and IPv6 cleanly
working. Any ideas on how to improve it?

The major problem is the huge amount of #ifdefs, most of which seem to
come from the fact that we deal with a list of possible addresses in
one case and not the other. It would help a lot if we fixed things so
that we dealt with a list in either case --- only a one-element list,
if we don't have getaddrinfo, but getaddrinfo2 could hide that and
provide a uniform API regardless.

The SSL patch is contributing a lot of ugliness too. It would be more
functional as well as cleaner if someone rewrote that code to work in
non-blocking style (which AFAICT should be feasible with the openssl
API, it just wasn't done).

regards, tom lane

In reply to: Tom Lane (#11)
Re: Someone's broken psql's connection-failure error reporting

On Thu, Feb 13, 2003 at 08:55:23PM -0500, Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

I've done a little bit of cleanup, but that code is still a mess...
someone should rewrite these routines.

Yes, I looked at it and struggled to get both IPv4 and IPv6 cleanly
working. Any ideas on how to improve it?

The major problem is the huge amount of #ifdefs, most of which seem to
come from the fact that we deal with a list of possible addresses in
one case and not the other. It would help a lot if we fixed things so
that we dealt with a list in either case --- only a one-element list,
if we don't have getaddrinfo, but getaddrinfo2 could hide that and
provide a uniform API regardless.

I'm actually working on getting rid of all those #ifdef's, but
it's going slowly. (I have very little free time.)

Kurt