pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: lichuancheng@highgo.com <lichuancheng@highgo.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #15567: Wal receiver process restart failed when a damaged wal record arrived at standby.
Date: Fri, 11 Jan 2019 10:59:12 +0800
Message-ID: <2019011110591261730856@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>


Thanks Michael Paquier for your explanation.
I have modified the patch  in mail attachment,wish your reply.


-----
movead



Attachments:

bug15567_lichuancheng_20190111.patch (application/octet-stream, 1.5K) download diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c index 48e8498d62..c4785b5f59 100644 --- a/src/backend/replication/walreceiverfuncs.c +++ b/src/backend/replication/walreceiverfuncs.c @@ -280,7 +280,42 @@ 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); + + 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); }

view thread (8+ messages)  latest in thread

Message-ID: <2019011110591261730856@highgo.com>
Permalink:  ../2019011110591261730856@highgo.com/
Also on:    postgresql.org/message-id/2019011110591261730856@highgo.com

 ·  · 

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: lichuancheng@highgo.com, michael@paquier.xyz
  Subject: Re: BUG #15567: Wal receiver process restart failed when a damaged wal record arrived at standby.
  In-Reply-To: <2019011110591261730856@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>

* 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