pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid killing btree items that are already dead
Date: Fri, 15 May 2020 20:51:55 +0000
Message-ID: <E1jZhJD-0000QY-Gm@gemulon.postgresql.org> (raw)

Avoid killing btree items that are already dead

_bt_killitems marks btree items dead when a scan leaves the page where
they live, but it does so with only share lock (to improve concurrency).
This was historicall okay, since killing a dead item has no
consequences.  However, with the advent of data checksums and
wal_log_hints, this action incurs a WAL full-page-image record of the
page.  Multiple concurrent processes would write the same page several
times, leading to WAL bloat.  The probability of this happening can be
reduced by only killing items if they're not already dead, so change the
code to do that.

The problem could eliminated completely by having _bt_killitems upgrade
to exclusive lock upon seeing a killable item, but that would reduce
concurrency so it's considered a cure worse than the disease.

Backpatch all the way back to 9.5, since wal_log_hints was introduced in
9.4.

Author: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Discussion: https://postgr.es/m/CA+fd4k6PeRj2CkzapWNrERkja5G0-6D-YQiKfbukJV+qZGFZ_Q@mail.gmail.com

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0a319699d59c26538bd78742cdfc3817509d82bf

Modified Files
--------------
src/backend/access/nbtree/nbtutils.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1jZhJD-0000QY-Gm@gemulon.postgresql.org>
Permalink:  ../E1jZhJD-0000QY-Gm@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jZhJD-0000QY-Gm@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Avoid killing btree items that are already dead
  In-Reply-To: <E1jZhJD-0000QY-Gm@gemulon.postgresql.org>
  References: <E1jZhJD-0000QY-Gm@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox