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

What is the life of a postgres back end process?

From
Eliot Gable
Date:
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?

What is a good way to test this is the case which would account for differences in load?

--
Eliot Gable

"We do not inherit the Earth from our ancestors: we borrow it from our children." ~David Brower

"I decided the words were too conservative for me. We're not borrowing from our children, we're stealing from them--and it's not even considered to be a crime." ~David Brower

"Esse oportet ut vivas, non vivere ut edas." (Thou shouldst eat to live; not live to eat.) ~Marcus Tullius Cicero

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

From
Jeff Davis
Date:
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




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

From
Steve Crawford
Date:
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