From: lichuancheng@highgo.com <lichuancheng@highgo.com>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: Re: BUG #15567: Wal receiver process restart failed when a damaged wal record arrived at standby.
Date: Mon, 11 Mar 2019 14:52:50 +0800
Message-ID: <2019031114523281749136@highgo.com> (raw)
References: <15567-a9ff747c5e7c031c@postgresql.org>
<CAK-MWwTYxLo9M5tzGToZeNj6YLKCcBhNETnGTbLexfj53RsW-w@mail.gmail.com>
<2018122913081786371813@highgo.com>
<2019010317504815140834@highgo.com>
<20190109071411.GA23045@paquier.xyz>
<2019010916285112831844@highgo.com>
<2019011110591261730856@highgo.com>
hello
A change to prevent dead-cycle by function 'HandleStartupProcInterrupts()'
-----
movead
Attachments:bug15567_lichuancheng_20190225.patch (application/octet-stream, 1.6K) downloaddiff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.cindex 48e8498d62..301babaaa1 100644--- a/src/backend/replication/walreceiverfuncs.c+++ b/src/backend/replication/walreceiverfuncs.c@@ -280,7 +280,47 @@ 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.+ */++ SpinLockAcquire(&walrcv->mutex);++ if(WALRCV_STARTING != walrcv->walRcvState)+ {+ SpinLockRelease(&walrcv->mutex);+ break;+ }++ SpinLockRelease(&walrcv->mutex);++ /*+ * This possibly-long loop needs to handle interrupts of startup+ * process.+ */+ HandleStartupProcInterrupts();++ elog(LOG,"startup process is waiting for restart of walreciver process");++ /*+ * The walreciver progress is restarting now, startup progress sleep 1s here to ensure+ * the restarting, otherwise startup progress may shutdown the restarting in function+ * WaitForWALToBecomeAvailable().+ *+ * Infact 1s is enought for reciver process to restart. It is related to the slave+ * only, noting with network. + */+ 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: <2019031114523281749136@highgo.com>
References: <15567-a9ff747c5e7c031c@postgresql.org> <CAK-MWwTYxLo9M5tzGToZeNj6YLKCcBhNETnGTbLexfj53RsW-w@mail.gmail.com> <2018122913081786371813@highgo.com> <2019010317504815140834@highgo.com> <20190109071411.GA23045@paquier.xyz> <2019010916285112831844@highgo.com> <2019011110591261730856@highgo.com> <2019031114523281749136@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