Start Walreceiver completely before shut down it on standby server.

From: jiankang liu <liujk1994(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Start Walreceiver completely before shut down it on standby server.
Date: 2019-12-10 09:52:29
Message-ID: CAJ+DhQaf9ZMkqPPnapu06mvMFe-b_K4NGF+-MV+e=JB2edF4cQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Start Walreceiver completely before shut down it on standby server.

The walreceiver will be shut down, when read an invalid record in the
WAL streaming from master.And then, we retry from archive/pg_wal again.

After that, we start walreceiver in RequestXLogStreaming(), and read
record from the WAL streaming. But before walreceiver starts, we read
data from file which be streamed over and present in pg_wal by last
time, because of walrcv->receivedUpto > RecPtr and the wal is actually
flush on disk. Now, we read the invalid record again, what the next to
do? Shut down the walreceiver and do it again.

So, we always read the invalid record, starting the walreceiver and make
it down before it starts completely.

This code fix it by set the walrcv->receivedUpto to the starting point,
we can read nothing before the walreceiver starts and streaming.

Attachment Content-Type Size
start_walreceiver.diff application/octet-stream 781 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rushabh Lathia 2019-12-10 09:59:43 Re: backup manifests
Previous Message Noah Misch 2019-12-10 09:29:19 Re: Windows UTF-8, non-ICU collation trouble