pgsql: Avoid pin scan for replay of XLOG_BTREE_VACUUM

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid pin scan for replay of XLOG_BTREE_VACUUM
Date: 2016-01-09 10:13:27
Message-ID: E1aHqWV-0004Mo-C9@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Avoid pin scan for replay of XLOG_BTREE_VACUUM
Replay of XLOG_BTREE_VACUUM during Hot Standby was previously thought to require
complex interlocking that matched the requirements on the master. This required
an O(N) operation that became a significant problem with large indexes, causing
replication delays of seconds or in some cases minutes while the
XLOG_BTREE_VACUUM was replayed.

This commit skips the “pin scan” that was previously required, by observing in
detail when and how it is safe to do so, with full documentation. The pin scan
is skipped only in replay; the VACUUM code path on master is not touched here.

The current commit still performs the pin scan for toast indexes, though this
can also be avoided if we recheck scans on toast indexes. Later patch will
address this.

No tests included. Manual tests using an additional patch to view WAL records
and their timing have shown the change in WAL records and their handling has
successfully reduced replication delay.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/687f2cd7a0150647794efe432ae0397cb41b60ff

Modified Files
--------------
src/backend/access/nbtree/README | 24 ++++++++++++++++++++++++
src/backend/access/nbtree/nbtree.c | 23 ++++++++++++++++++++++-
src/backend/access/nbtree/nbtxlog.c | 18 ++++++++++++++++--
src/backend/access/rmgrdesc/nbtdesc.c | 2 +-
src/include/access/nbtree.h | 6 ++++--
5 files changed, 67 insertions(+), 6 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2016-01-09 12:23:55 Re: pgsql: Avoid pin scan for replay of XLOG_BTREE_VACUUM
Previous Message Alvaro Herrera 2016-01-08 16:19:27 pgsql: Revert "Blind attempt at a Cygwin fix"

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2016-01-09 12:23:55 Re: pgsql: Avoid pin scan for replay of XLOG_BTREE_VACUUM
Previous Message Piotr Stefaniak 2016-01-09 07:08:22 Re: [PATCH] Add STRICT to some regression test C functions.