pgsql: Fix bug in Tid scan.

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix bug in Tid scan.
Date: 2020-02-07 13:08:26
Message-ID: E1j03Mw-0002mn-GU@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix bug in Tid scan.

Commit 147e3722f7 changed Tid scan so that it calls table_beginscan()
and uses the scan option for seq scan. This change caused two issues.

(1) The change caused Tid scan to take a predicate lock on the entire
relation in serializable transaction even when relation-level
lock is not necessary. This could lead to an unexpected
serialization error.

(2) The change caused Tid scan to increment the number of seq_scan
in pg_stat_*_tables views even though it's not seq scan. This
could confuse the users.

This commit adds the scan option for Tid scan and makes Tid scan
use it, to avoid those issues.

Back-patch to v12, where the bug was introduced.

Author: Tatsuhito Kasahara
Reviewed-by: Kyotaro Horiguchi, Masahiko Sawada, Fujii Masao
Discussion: https://postgr.es/m/CAP0=ZVKy+gTbFmB6X_UW0pP3WaeJ-fkUWHoD-pExS=at3CY76g@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/cb5b28613d553b1c750622e91cbc96c83f052a63

Modified Files
--------------
src/backend/executor/nodeTidscan.c | 5 ++---
src/backend/utils/adt/tid.c | 4 ++--
src/include/access/tableam.h | 24 +++++++++++++++++++-----
src/test/regress/expected/tidscan.out | 16 ++++++++++++++++
src/test/regress/sql/tidscan.sql | 7 +++++++
5 files changed, 46 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-02-07 18:06:46 Re: pgsql: Fix page modification outside of critical section in GIN
Previous Message Fujii Masao 2020-02-07 13:08:15 pgsql: Fix bug in Tid scan.