Re: REFRESH MATERIALIZED VIEW blocks pgAdmin III login

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>, "pgadmin-support(at)postgresql(dot)org" <pgadmin-support(at)postgresql(dot)org>
Subject: Re: REFRESH MATERIALIZED VIEW blocks pgAdmin III login
Date: 2015-02-20 14:33:04
Message-ID: A737B7A37273E048B164557ADEF4A58B3659E858@ntex2010i.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

I wrote:
> If you try to connect to a database while REFRESH MATERIALIZE VIEW for a
> materialized view in the database is in progress, the interface will
> "hang" (the window remains blank and does not react to the mouse).
>
> This is probably caused by the ACCESS EXCLUSIVE locks that are held
> during REFRESH MATERIALIZED VIEW. When the command finishes, pgAdmin III
> continues working as usual.
>
> I'd say that this is a bug, because it is not unusual for REFRESH
> MATERIALIZED VIEW to take a very long time, and in that time pgAdmin III
> is not working.
>
> I tried with versions 1.20.0 and 1.18.1.

I dug a bit into that, and the problem is in pgViewFactory::CreateObjects in pgView.cpp.
The query that is constructed there selects pg_get_viewdef(c.oid) for all views,
and this function takes out an ACCESS SHARE LOCK on each view.

This lock conflicts with the ACCESS EXCLUSIVE lock from REFRESH MATERIALIZE VIEW.

What about joining with pg_locks and calling pg_get_viewdef(c.oid) only for the views
on which there is no ACCESS EXCLUSIVE lock? There might be a race condition, but only
a very small one.

Yours,
Laurenz Albe

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message Deshogues Arnaud 2015-02-23 07:30:03 Web acces to pgAdminIII?
Previous Message Dmitry Voronin 2015-02-20 13:00:15 dlgView bug