pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Crash by targetted recovery
Date: Thu, 27 Feb 2020 20:04:41 +0900
Message-ID: <a74bfa5d-3a86-90b8-286e-9ff8822bd8e1@oss.nttdata.com> (raw)
In-Reply-To: <20200227.170530.2264412619413068664.horikyota.ntt@gmail.com>
References: <899463ee-549c-3f30-5752-ae1988ddc066@oss.nttdata.com>
	<20200227.152307.953966656438810060.horikyota.ntt@gmail.com>
	<ab80bd8c-1a3c-4ef2-e846-28258875f37a@oss.nttdata.com>
	<20200227.170530.2264412619413068664.horikyota.ntt@gmail.com>



On 2020/02/27 17:05, Kyotaro Horiguchi wrote:
> Thank you for the comment.
> At Thu, 27 Feb 2020 16:23:44 +0900, Fujii Masao <masao.fujii@oss.nttdata.com> wrote in
>> On 2020/02/27 15:23, Kyotaro Horiguchi wrote:
>>>> I failed to understand why random access while reading from
>>>> stream is bad idea. Could you elaborate why?
>>> It seems to me the word "streaming" suggests that WAL record should be
>>> read sequentially. Random access, which means reading from arbitrary
>>> location, breaks a stream.  (But the patch doesn't try to stop wal
>>> sender if randAccess.)
>>>
>>>> Isn't it sufficient to set currentSource to 0 when disabling
>>>> StandbyMode?
>>> I thought that and it should work, but I hesitated to manipulate on
>>> currentSource in StartupXLOG. currentSource is basically a private
>>> state of WaitForWALToBecomeAvailable. ReadRecord modifies it but I
>>> think it's not good to modify it out of the the logic in
>>> WaitForWALToBecomeAvailable.
>>
>> If so, what about adding the following at the top of
>> WaitForWALToBecomeAvailable()?
>>
>>      if (!StandbyMode && currentSource == XLOG_FROM_STREAM)
>>           currentSource = 0;
> 
> It works virtually the same way. I'm happy to do that if you don't
> agree to using randAccess. But I'd rather do that in the 'if
> (!InArchiveRecovery)' section.

The approach using randAccess seems unsafe. Please imagine
the case where currentSource is changed to XLOG_FROM_ARCHIVE
because randAccess is true, while walreceiver is still running.
For example, this case can occur when the record at REDO
starting point is fetched with randAccess = true after walreceiver
is invoked to fetch the last checkpoint record. The situation
"currentSource != XLOG_FROM_STREAM while walreceiver is
  running" seems invalid. No?

So I think that the approach that I proposed is better.

Regards,

-- 
Fujii Masao
NTT DATA CORPORATION
Advanced Platform Technology Group
Research and Development Headquarters





view thread (18+ messages)  latest in thread

Message-ID: <a74bfa5d-3a86-90b8-286e-9ff8822bd8e1@oss.nttdata.com>
Permalink:  ../a74bfa5d-3a86-90b8-286e-9ff8822bd8e1@oss.nttdata.com/
Also on:    postgresql.org/message-id/a74bfa5d-3a86-90b8-286e-9ff8822bd8e1@oss.nttdata.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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: masao.fujii@oss.nttdata.com, horikyota.ntt@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Crash by targetted recovery
  In-Reply-To: <a74bfa5d-3a86-90b8-286e-9ff8822bd8e1@oss.nttdata.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