Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLG5N-0003oq-Fi for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Sep 2021 02:34:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mLG5K-0000ze-Cs for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Sep 2021 02:34:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLG5K-0000zT-4Z for pgsql-hackers@lists.postgresql.org; Wed, 01 Sep 2021 02:34:42 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLG5G-0000qc-Sx for pgsql-hackers@lists.postgresql.org; Wed, 01 Sep 2021 02:34:40 +0000 Received: from hrk.local (p2388012-ipbf1027funabasi.chiba.ocn.ne.jp [118.6.6.12]) by oss.nttdata.com (Postfix) with ESMTPSA id 8113A605FC; Wed, 1 Sep 2021 11:34:34 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.3 at oss.nttdata.com Subject: Re: prevent immature WAL streaming To: Andres Freund , Alvaro Herrera Cc: Pg Hackers , "Bossart, Nathan" , Kyotaro Horiguchi , =?UTF-8?B?6JSh5qKm5aifKOeOiuS6jik=?= , Jakub Wartak References: <20210831042949.52eqp5xwbxgrfank@alap3.anarazel.de> <202108311356.sl33wcpcz5x6@alvherre.pgsql> <20210831155333.2vv2zdf7v4nhh2m2@alap3.anarazel.de> From: Fujii Masao Message-ID: Date: Wed, 1 Sep 2021 11:34:34 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210831155333.2vv2zdf7v4nhh2m2@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/09/01 0:53, Andres Freund wrote: > I was thinking that on a normal WAL write we'd do nothing. Instead we would > have dedicated code at the end of recovery that, if the WAL ends in a partial > record, changes the page following the "valid" portion of the WAL to indicate > that an incomplete record is to be skipped. Agreed! > Of course, we need to be careful to not weaken WAL validity checking too > much. How about the following: > > If we're "aborting" a continued record, we set XLP_FIRST_IS_ABORTED_PARTIAL on > the page at which we do so (i.e. the page after the valid end of the WAL). When do you expect that XLP_FIRST_IS_ABORTED_PARTIAL is set? It's set when recovery finds a a partially-flushed segment-spanning record? But maybe we cannot do that (i.e., cannot overwrite the page) because the page that the flag is set in might have already been archived. No? > I think we can just read the WAL and see if it ends with a partial > record. It'd add a bit of complication to the error checking in xlogreader, > because we'd likely want to treat verification from page headers a bit > different from verification due to record data. But that seems doable. Yes. > Does this make sense? Yes, I think! Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION