pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Michael Paquier <michael@paquier.xyz>
Cc: Andrey Borodin <x4mmm@yandex-team.ru>
Cc: Ben Chobot <bench@silentmedia.com>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17401: REINDEX TABLE CONCURRENTLY creates a race condition on a streaming replica
Date: Thu, 10 Feb 2022 18:18:12 -0800
Message-ID: <20220211021812.wgv324etfaz4v4yu@alap3.anarazel.de> (raw)
In-Reply-To: <YgW+Gl+VC+QGFZF4@paquier.xyz>
References: <17401-9df851bb16dde397@postgresql.org>
	<49421F62-E34E-4CEA-8372-F0454DC71CA0@yandex-team.ru>
	<CAH2-Wzm0Vf8VJfGaNhzCtnteaCCCeSGJcTdJX6YuRuBKZ_KjHA@mail.gmail.com>
	<7625EC28-D102-450F-86CE-3D37095636F5@yandex-team.ru>
	<CAH2-WznyJT_TJ9gc=_YBkEZ5D1ddt-NfOWzbYURg4jq6QDFStw@mail.gmail.com>
	<C50E352E-FE90-46EC-94C2-3E96D9DDB141@yandex-team.ru>
	<bafcc4ab-8732-0503-ef17-0ee0420cf527@silentmedia.com>
	<04D2D137-102E-400D-B66B-C073C27A1327@yandex-team.ru>
	<20220211001240.47idtavhfyzi4aa3@alap3.anarazel.de>
	<YgW+Gl+VC+QGFZF4@paquier.xyz>

Hi,

On 2022-02-11 10:38:34 +0900, Michael Paquier wrote:
> My impression is that we don't really need to change the WAL format
> based on the existing APIs we already have, or that in the worst case
> it would be possible to make things backward-compatible enough that it
> would not be a worry as long as the standbys are updated before the
> primaries.

I think it's a question of how "concurrently" we want concurrently to be on
hot standby nodes.

If we are OK with "not at all", we can just lock an AEL at the end of
WaitForLockersMultiple(). It's a bit harder to cause the necessary snapshot
conflict, but we could e.g. extend xl_running_xacts and use the record length
to keep both older primary -> newer replica, and the reverse working.

If we want to actually make concurrently work concurrently on the replica,
we'd have to work harder. That doesn't strike me as feasible for backpatching.

The most important bit bit would be to make WaitForOlderSnapshots() wait for
the xmin of hot_standby_feedback walsenders and/or physical slot xmin
horizons. For phase 5 & 6 we would probably have to do something like waiting
for snapshot conflicts vs walsenders/slots in addition to the
WaitForLockersMultiple() for conflicts on the primary.

Greetings,

Andres Freund





view thread (25+ messages)  latest in thread

Message-ID: <20220211021812.wgv324etfaz4v4yu@alap3.anarazel.de>
Permalink:  ../20220211021812.wgv324etfaz4v4yu@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20220211021812.wgv324etfaz4v4yu@alap3.anarazel.de

 · 

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-bugs@postgresql.org
  Cc: andres@anarazel.de, michael@paquier.xyz, x4mmm@yandex-team.ru, bench@silentmedia.com, pg@bowt.ie
  Subject: Re: BUG #17401: REINDEX TABLE CONCURRENTLY creates a race condition on a streaming replica
  In-Reply-To: <20220211021812.wgv324etfaz4v4yu@alap3.anarazel.de>
  References: <17401-9df851bb16dde397@postgresql.org> <49421F62-E34E-4CEA-8372-F0454DC71CA0@yandex-team.ru> <CAH2-Wzm0Vf8VJfGaNhzCtnteaCCCeSGJcTdJX6YuRuBKZ_KjHA@mail.gmail.com> <7625EC28-D102-450F-86CE-3D37095636F5@yandex-team.ru> <CAH2-WznyJT_TJ9gc=_YBkEZ5D1ddt-NfOWzbYURg4jq6QDFStw@mail.gmail.com> <C50E352E-FE90-46EC-94C2-3E96D9DDB141@yandex-team.ru> <bafcc4ab-8732-0503-ef17-0ee0420cf527@silentmedia.com> <04D2D137-102E-400D-B66B-C073C27A1327@yandex-team.ru> <20220211001240.47idtavhfyzi4aa3@alap3.anarazel.de> <YgW+Gl+VC+QGFZF4@paquier.xyz> <20220211021812.wgv324etfaz4v4yu@alap3.anarazel.de>

* 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