Re: client socket TIME_WAIT state after PQfinish

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Guillaume Du Pasquier <guillaume(dot)dupasquier(at)sensometrix(dot)ch>
Cc: Nicolas Barbier <nicolas(dot)barbier(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: client socket TIME_WAIT state after PQfinish
Date: 2010-09-27 17:33:05
Message-ID: AANLkTinh0sM+FwWfAPPfHVu3FkAq4MWtOywqciZLcTq2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 27, 2010 at 12:56 PM, Guillaume Du Pasquier
<guillaume(dot)dupasquier(at)sensometrix(dot)ch> wrote:
> Dear Nicolas, Dear Robert,
>
> Thank you for your quick answers.
> We do not have such behavior using SSL, how do you explain it ?
> I suppose that openssl is using the setsockopt SO_LINGER that
> removes this behavior. Therefore, there is a RST sent to close
> the socket.
>
> We work with an environment that uses a lot of socket connections.
> Therefore, many file descriptors are opened. If after each
> Sql requests a TIME_WAIT arises we will end up with many
> file descriptors opened. By default the maximum number of file descriptors
> is set to 1024 and we reach that number quite fast.

Hrm. Does a socket in the TIME_WAIT state count against the number of
open file descriptors? Certainly, it shouldn't count against the
per-process limit, as the process has already closed it.

> Do you have any advices to get rid of this TIME_WAIT problem ?
> Our client runs on the same machine as the postgresql server.
> Would it be possible to use PF_UNIX sockets ?

Yeah, actually that's the default, if you just run "psql" with no
parameters. It looks for a socket in /tmp/.s.PGSQL.5432.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2010-09-27 17:34:00 Re: trailing whitespace in psql table output
Previous Message Robert Haas 2010-09-27 17:27:35 Re: PlaceHolderVars versus join ordering