Re: Replication & recovery_min_apply_delay

From: Asim R P <apraveen(at)pivotal(dot)io>
To: Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Hao Wu <hawu(at)pivotal(dot)io>
Subject: Re: Replication & recovery_min_apply_delay
Date: 2020-01-21 13:24:12
Message-ID: CANXE4TcZp4hNHS6JA12cY1-n7tC=zcQDG+B=E1205bqsosCOwQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Replay lag can build up naturally, even when recovery_min_apply_delay
is not set, because WAL generation on master is concurrent and WAL
replay on standby is performed by a single process.

Hao and I have incorporated the new GUC from Konstantin's patch
and used it to start WAL receiver in the main replay loop, regardless
of whether recover_min_apply_delay is set.

Instead of going through each existing WAL record to determine the
streaming start point, WAL received is changed to persist WAL segment
number of a new WAL segment just before it is created. WAL streaming
always begins from WAL segment boundary. The persistent segment
number can be easily used to compute the start point, which is the
beginning of that segment.

We also have a TAP test to demonstrate the problem in two situations -
(1) WAL receiver process dies due to replication connection getting
disconnected and (2) standby goes through restart. The test uses
recovery_min_apply_delay to delay the replay and expects new commits
made after WAL receiver exit to not block.

Asim

Attachment Content-Type Size
v2-0001-Test-that-replay-of-WAL-logs-on-standby-does-not-.patch application/octet-stream 7.4 KB
v2-0002-Start-WAL-receiver-before-startup-process-replays.patch application/octet-stream 14.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2020-01-21 13:49:34 Re: vacuum verbose detail logs are unclear; log at *start* of each stage; show allvisible/frozen/hintbits
Previous Message Craig Ringer 2020-01-21 11:33:40 Re: Remove page-read callback from XLogReaderState.