Re: Materialized view refreshing problem

From: Hellen Jiang <hjiang(at)federatedwireless(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Materialized view refreshing problem
Date: 2023-08-24 19:36:41
Message-ID: BLAPR17MB41931DAC530D73B87BA52BB7D21DA@BLAPR17MB4193.namprd17.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

When the materialized view was refreshing concurrently, I saw the pg_lock like this: there was no response within 30 seconds when the api calls this query, and we got api time out.

sasanalytics=> select relation::regclass, * from pg_locks where not granted;

relation | locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath

---------------------------------------------------+----------+----------+------------+------+-------+------------+---------------+---------+-------+----------+--------------------+-------+---------------+---------+----------

mvw_cbsd_status_grants_lessinfo_active_softmarker | relation | 16401 | 1886512426 | | | | | | | | 236/858 | 17332 | ExclusiveLock | f | f

(1 row)

When the materialized view was refreshing normally( without concurrently), I saw the following pg_locks: there was no response within 30 seconds when the api calls this query, and we got api time out.

sasanalytics=> select relation::regclass, * from pg_locks where not granted;

relation | locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath

---------------------------------------------------+----------+----------+------------+------+-------+------------+---------------+---------+-------+----------+--------------------+-------+---------------------+---------+----------

mvw_cbsd_status_grants_lessinfo_active_softmarker | relation | 16401 | 1886512426 | | | | | | | | 245/1163 | 15932 | AccessExclusiveLock | f | f

(1 row)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Date: Thursday, August 24, 2023 at 3:02 PM
To: Hellen Jiang <hjiang(at)federatedwireless(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Materialized view refreshing problem
Hellen Jiang <hjiang(at)federatedwireless(dot)com> writes:
> But from time and time, we found that it took forever to refresh materialized view( normally or concurrently), and there is no response to query from this materialized view.

That sounds like a locking problem. Have you looked into pg_locks
while this is happening, to see what may be waiting on what?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2023-08-24 19:57:38 Re: Materialized view refreshing problem
Previous Message Stephen Frost 2023-08-24 19:08:44 Re: Will PostgreSQL 16 supports native transparent data encryption ?