pgsql: Make materialized views participate in predicate locking

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make materialized views participate in predicate locking
Date: 2022-12-01 06:43:06
Message-ID: E1p0dHl-001Wor-CL@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Make materialized views participate in predicate locking

Matviews have been discarded from needing predicate locks since 3bf3ab8
and their introduction. At this point, there was no concurrent flavor
of REFRESH yet, hence there was no meaning in having materialized views
look at read/write conflicts with concurrent transactions using
themselves the serializable isolation level because they could only be
refreshed with an access exclusive lock. CONCURRENTLY, on the contrary,
allows reads and writes during a refresh as it holds a share update
exclusive lock.

Some isolation tests are added to show the effect of the change, with a
combination of one table and a matview based on it, using a mix of
REFRESH CONCURRENTLY and read/write queries.

This could arguably be considered as a bug, but as it is a subtle
behavior change potentially impacting applications no backpatch is
done.

Author: Yugo Nagata
Reviewed-by: Richard Guo, Dilip Kumar, Michael Paquier
Discussion: https://postgr.es/m/20220726164434.42d4e33911b4b4fcf751c4e7@sraoss.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/43351557d0d2b9c5e20298b5fee2849abef86aff

Modified Files
--------------
src/backend/storage/lmgr/predicate.c | 5 +-
src/test/isolation/expected/matview-write-skew.out | 121 +++++++++++++++++++++
src/test/isolation/isolation_schedule | 1 +
src/test/isolation/specs/matview-write-skew.spec | 51 +++++++++
4 files changed, 175 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2022-12-01 08:25:33 Re: pgsql: Revoke PUBLIC CREATE from public schema, now owned by pg_databas
Previous Message Robert Haas 2022-12-01 04:32:40 Re: pgsql: Revoke PUBLIC CREATE from public schema, now owned by pg_databas