Re: [HACKERS] Re: SIGPIPE gripe - Mailing list pgsql-hackers

From Peter T Mount
Subject Re: [HACKERS] Re: SIGPIPE gripe
Date
Msg-id Pine.LNX.3.95.980504204642.27875A-100000@retep.org.uk
Whole thread Raw
In response to Re: SIGPIPE gripe  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Mon, 4 May 1998, Tom Lane wrote:

[snip]

> Meanwhile, once the client receives the "AUTH OK" it initiates
> an empty query cycle (which is commented as intending to discover
> whether the database exists!):
>
>     ...
>
>     Client receives "AUTH_OK"
>
>     Client sends "Q " query
>
>     Client waits for response
>
> The problem, of course, is that if the backend manages to exit
> before the client gets to send its empty query, then the client
> is writing on a closed connection.  Boom, SIGPIPE.

[snip]

> So ... since we're altering the protocol anyway ... the right fix is
> to alter the protocol a little more.  Remember that "Z" message that
> the backend is now sending at the end of every query cycle?  What
> we ought to do is make the BE send "Z" at completion of startup,
> as well.  (In other words, "Z" will really mean "Ready for Query"
> rather than "Query Done".  This is actually easier to implement in
> postgres.c than the other way.)  Now the client's startup procedure
> looks like
>
>     ...
>
>     Client receives "AUTH_OK"
>
>     Client waits for "Z" ; if get "E" instead, BE startup failed.

This sounds fair enough. Infact we could then throw a more meaningful
error message when this occurs.

> I suspect it's not really necessary to do an empty query after this,
> but we may as well leave that in there for additional reliability.

In JDBC, I replaced (back in 6.2) the empty query with one to get the
current DateStyle (which the driver then uses to handle dates correctly).

--
Peter T Mount peter@retep.org.uk or petermount@earthling.net
Main Homepage: http://www.retep.org.uk
************ Someday I may rebuild this signature completely ;-) ************
Work Homepage: http://www.maidstone.gov.uk Work EMail: peter@maidstone.gov.uk


pgsql-hackers by date:

Previous
From: "Jackson, DeJuan"
Date:
Subject: RE: [QUESTIONS] Best way to halt an unending query.
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Postgresql6.3.2 libdld and the twilight zone.