Re: What is the life of a postgres back end process?

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Eliot Gable <egable+pgsql-general(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: What is the life of a postgres back end process?
Date: 2012-02-13 23:01:24
Message-ID: 4F399644.6030004@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 02/13/2012 02:45 PM, Jeff Davis wrote:
> On Mon, 2012-02-13 at 17:30 -0500, Eliot Gable wrote:
>> Are postgres back end processes connection specific? In other words,
>> can we assume / trust that they will be terminated and cleaned up when
>> we close a connection and that they will not live on and be reused by
>> other connections?
> Yes, one backend per connection. When you close the connection, the
> backend process should go away.
>
> Under some circumstances, that might not always happen immediately if
> the backend is in the middle of doing some work.
>
> Regards,
> Jeff Davis
But to amplify on Jeff's comment, he is referring to the actual final
connection to the PostgreSQL server. The OP did not actually specify who
"we" are and what led to the question. An end client completing its work
and need for a connection (or even specifically terminating the
connection) may not actually release and close the connection to the
server for a variety of reasons. PHP persistent connections, Java
connection pooling or one or more layers of external connection pooling
services like pgbouncer are just three common scenarios.

If you suspect a connection is not being closed properly you can run
"select * from pg_stat_activity();" to view current database
connections. To view information about connections from other than the
current user you will need database superuser privileges.

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-02-14 05:09:36 Re: Why this regexp matches?!
Previous Message Jeff Davis 2012-02-13 22:45:45 Re: What is the life of a postgres back end process?