From: lichuancheng@highgo.com <lichuancheng@highgo.com>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: BUG #15567: Wal receiver process restart failed when a damaged wal record arrived at standby.
Date: Thu, 3 Jan 2019 17:50:48 +0800
Message-ID: <2019010317504815140834@highgo.com> (raw)
References: <15567-a9ff747c5e7c031c@postgresql.org>
<CAK-MWwTYxLo9M5tzGToZeNj6YLKCcBhNETnGTbLexfj53RsW-w@mail.gmail.com>
<2018122913081786371813@highgo.com>
hello
I have analysis of the causes of bug when report it.
>[Code review]
>I read the code about startup process and walreciver process.
>When a damaged wal record arrived:
>1.The startup process shutdown the walreciver process use function ShutdownWalRcv().
>2.The startup process start the walreciver process use funtion RequestXLogStreaming() by signal PMSIGNAL_START_WALRECEIVER.
>3.The startup process try to read wal record.
> And now reciver process does not startup completely,so the startup process read the damaged wal record another times.
> And startup process set walrcv->walRcvState = WALRCV_STOPPED use function ShutdownWalRcv().
>4.go to 2.
>That's the infinite cycle.
And now i do a patch in mail attachment to solve the bug.
I test it on pg10.5 and work well.
-----
movead
Attachments:bug15567_lichuancheng_20190103.patch (application/octet-stream, 992B) downloaddiff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.cindex 48e8498d62..5066688288 100644--- a/src/backend/replication/walreceiverfuncs.c+++ b/src/backend/replication/walreceiverfuncs.c@@ -280,7 +280,26 @@ RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo,
SpinLockRelease(&walrcv->mutex);
if (launch)
+ {
SendPostmasterSignal(PMSIGNAL_START_WALRECEIVER);
+ + for(;;)+ {+ /*+ * Now we want to restart walreciver process and walrcv->walRcvState is WALRCV_STARTING.+ * We should not go on startup process until walrcv->walRcvState changed to other value.+ *+ * And we do a loop here in case of there may be any delay during restart of walreciver process.+ */+ if(WALRCV_STARTING != walrcv->walRcvState)+ {+ break;+ }++ elog(LOG,"startup process is waiting for restart of walreciver process");+ pg_usleep(1000000L);+ }+ }
else if (latch)
SetLatch(latch);
}
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: lichuancheng@highgo.com
Subject: Re: BUG #15567: Wal receiver process restart failed when a damaged wal record arrived at standby.
In-Reply-To: <2019010317504815140834@highgo.com>
References: <15567-a9ff747c5e7c031c@postgresql.org> <CAK-MWwTYxLo9M5tzGToZeNj6YLKCcBhNETnGTbLexfj53RsW-w@mail.gmail.com> <2018122913081786371813@highgo.com> <2019010317504815140834@highgo.com>
* 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