Re: Lock a viewe

From: Luis Marin <luismarinaray(at)gmail(dot)com>
To: Gaetano Mendola <mendola(at)gmail(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Lock a viewe
Date: 2016-12-26 19:34:53
Message-ID: CAEp6HQWvTKCR+4g08iF4RoxKYC2zO4z4mmN--+Dm7O1Ez+jGtg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi,

Have you tried,

https://wiki.postgresql.org/wiki/Lock_Monitoring
https://www.postgresql.org/docs/9.1/static/explicit-locking.html
https://www.postgresql.org/docs/9.1/static/sql-lock.html

Regards

2016-12-20 16:17 GMT-04:00 Gaetano Mendola <mendola(at)gmail(dot)com>:

> Hi,
> I was wondering if there is a clean view to lock the usage of a view.
>
> Basically during a schema migration, with applications still running a
> typical
> schema change is:
>
> BEGIN;
> ALTER TABLE x ADD COLUMN (a INTEGER);
> CREATE OR REPLACE VIEW v_x
> AS
> SELECT a,b FROM x;
> COMMIT;
>
> now the issue is that if an application performs a:
>
> SELECT * from v_x;
>
> between the ALTER and the view redefinition then a deadlock happens.
>
> I'm preventing this issue doing a:
>
> ALTER VIEW v_x ALTER COLUMN b DROP DEFAULT;
> (anyway there was no default on the view)
> before the ALTER TABLE, that's basically reorders the locks sequence
> avoiding the dead lock.
>
> Is there a clean way to achieve it without the "hack"?
>
>
> GM
>
>
>
>
>
>
>
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Alvaro Herrera 2016-12-26 19:53:15 Re: Lock a viewe
Previous Message Luis Marin 2016-12-26 19:02:47 Re: Error Encrypting data folder