Skip site navigation (1) Skip section navigation (2)

Idea: quicker abort after loss of client connection

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Idea: quicker abort after loss of client connection
Date: 2001-06-06 00:01:02
Message-ID: 21746.991785662@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Currently, if the client application dies (== closes the connection),
the backend will observe this and exit when it next returns to the
outer loop and tries to read a new command.  However, we might detect
the loss of connection much sooner; for example, if we are doing a
SELECT that outputs large amounts of data, we will see failures from
send().

We have deliberately avoided trying to abort as soon as the connection
drops, for fear that that might cause unexpected problems.  However,
it's moderately annoying to see the postmaster log fill with
"pq_flush: send() failed" messages when something like this happens.

It occurs to me that a fairly safe way to abort after loss of connection
would be for pq_flush or pq_recvbuf to set QueryCancel when they detect
a communications problem.  This would not immediately abort the query in
progress, but would ensure a cancel at the next safe time in the
per-tuple loop.  You wouldn't get very much more output before that
happened, typically.

Thoughts?  Is there anything about this that might be unsafe?  Should
QueryCancel be set after *any* failure of recv() or send(), or only
if certain errno codes are detected (and if so, which ones)?

			regards, tom lane

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2001-06-06 00:03:24
Subject: Re: Australian timezone configure option
Previous:From: Chris DunlopDate: 2001-06-05 23:55:30
Subject: Re: Australian timezone configure option

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group