Many connections lingering

Поиск
Список
Период
Сортировка
От Slavisa Garic
Тема Many connections lingering
Дата
Msg-id bcb55890050412192911e953c@mail.gmail.com
обсуждение исходный текст
Ответы Re: Many connections lingering  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Hi all,

I've just noticed an interesting behaviour with PGSQL. My software is
made up of few different modules that interact through PGSQL database.
Almost every query they do is an individual transaction and there is a
good reason for that. After every query done there is some processing
done by those modules and I didn't want to lock the database in a
single transaction while that processing is happening. Now, the
interesting behaviour is this. I've ran netstat on the machine where
my software is running and I searched for tcp connections to my PGSQL
server. What i found was hundreds of lines like this:

tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:39504 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:40720 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:39135 TIME_WAIT
tcp        0      0 remus.dstc.monash:43002 remus.dstc.monash:41631 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:41119 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:41311 TIME_WAIT
tcp        0      0 remus.dstc.monash.:8649 remus.dstc.monash:41369 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:40479 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:39454 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:39133 TIME_WAIT
tcp        0      0 remus.dstc.monash:43002 remus.dstc.monash:41501 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:39132 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:41308 TIME_WAIT
tcp        0      0 remus.dstc.monash:43002 remus.dstc.monash:40667 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:41179 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:39323 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:41434 TIME_WAIT
tcp        0      0 remus.dstc.monash:43002 remus.dstc.monash:40282 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:41050 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:41177 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:39001 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:41305 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:38937 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:39128 TIME_WAIT
tcp        0      0 remus.dstc.monash:43001 remus.dstc.monash:40600 TIME_WAIT
tcp        0      0 remus.dstc.monash:43002 remus.dstc.monash:41624 TIME_WAIT
tcp        0      0 remus.dstc.monash:43002 remus.dstc.monash:39000 TIME_WAIT

Now could someone explain to me what this really means and what effect
it might have on the machine (the same machine where I ran this
query)? Would there eventually be a shortage of available ports if
this kept growing? The reason I am asking this is because one of my
modules was raising exception saying that TCP connection could not be
establish to a server it needed to connect to. This may sound
confusing so I'll try to explain this.

We have this scenario, there is a PGSQL server (postmaster) which is
running on machine A. Then there is a custom server called DBServer
which is running on machine B. This server accepts connections from a
client called an Agent. Agent may ran on any machine out there and it
would connect back to DBServer asking for some information. The
communication between these two is in the form of SQL queries. When
agent sends a query to DBServer it passes that query to machine A
postmaster and then passes back the result of the query to that Agent.
The connection problem I mentioned in the paragraph above happens when
Agent tries to connect to DBServer.

So the only question I have here is would those lingering socket
connections above have any effect on the problem I am having. If not I
am sorry for bothering you all with this, if yes I would like to know
what I  could do to avoid that.

Any help would be appreciated,
Regards,
Slavisa

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Greg Sabino Mullane"
Дата:
Сообщение: Re: select top N entries from several groups (Modified by David Orme)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Many connections lingering