Re: LOCK DATABASE - Mailing list pgsql-hackers

From Jaime Casanova
Subject Re: LOCK DATABASE
Date
Msg-id BANLkTimioq=USgp7m8Drcji=Qo0fa97tcg@mail.gmail.com
Whole thread Raw
In response to LOCK DATABASE  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: LOCK DATABASE  (Christopher Browne <cbbrowne@gmail.com>)
List pgsql-hackers
On Tue, May 17, 2011 at 10:21 PM, Alvaro Herrera
<alvherre@alvh.no-ip.org> wrote:
>
> So we would have a new command LOCK DATABASE [FOR SESSION] or something
> like that; the pooler software would call that and then kill other
> existing application connections (using pg_terminate_backend() perhaps),
> then drop the database.  This LOCK DATABASE thingy would just be a
> simple function on top of LockSharedObject.  Since establishing a new
> connection requires grabbing a lock on the database via
> LockSharedObject, things would Just Work (or at least so it seems to
> me).
>
> UNLOCK DATABASE would be needed to release a session-level lock acquired
> by LOCK DATABASE FOR SESSION for the cases where you want to lock a
> database to safely do schema upgrades and the like.
>

So we the lock will be released at end of the session or when the
UNLOCK DATABASE command is invoked, right?
A question: why will we beign so rude by killing other sessions
instead of avoid new connections and wait until the current sessions
disconnect?

--
Jaime Casanova         www.2ndQuadrant.com
Professional PostgreSQL: Soporte y capacitación de PostgreSQL


pgsql-hackers by date:

Previous
From: Devrim GÜNDÜZ
Date:
Subject: Re: deprecating contrib for PGXN
Next
From: Max Bourinov
Date:
Subject: Passing an array or record to a stored procedure in PostgreSQL