Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j7GyI-0001go-3f for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Feb 2020 11:04:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j7GyG-0006Hd-Ti for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Feb 2020 11:04:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j7GyG-0006HW-KO for pgsql-hackers@lists.postgresql.org; Thu, 27 Feb 2020 11:04:48 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j7GyE-0002k2-EX for pgsql-hackers@lists.postgresql.org; Thu, 27 Feb 2020 11:04:48 +0000 Received: from hnk.local (sp49-97-94-11.msc.spmode.ne.jp [49.97.94.11]) by oss.nttdata.com (Postfix) with ESMTPSA id 15F8D6022C; Thu, 27 Feb 2020 20:04:42 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.101.5 at oss.nttdata.com Subject: Re: Crash by targetted recovery To: Kyotaro Horiguchi Cc: pgsql-hackers@lists.postgresql.org References: <899463ee-549c-3f30-5752-ae1988ddc066@oss.nttdata.com> <20200227.152307.953966656438810060.horikyota.ntt@gmail.com> <20200227.170530.2264412619413068664.horikyota.ntt@gmail.com> From: Fujii Masao Message-ID: Date: Thu, 27 Feb 2020 20:04:41 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200227.170530.2264412619413068664.horikyota.ntt@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 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