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 1mL4Fp-0005N6-OE for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Aug 2021 13:56: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 1mL4Fn-0003e7-JG for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Aug 2021 13:56:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mL4Fm-0003dz-Sv for pgsql-hackers@lists.postgresql.org; Tue, 31 Aug 2021 13:56:43 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mL4Fh-0001Eb-Dr for pgsql-hackers@lists.postgresql.org; Tue, 31 Aug 2021 13:56:42 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 920F75C0054; Tue, 31 Aug 2021 09:56:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 31 Aug 2021 09:56:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=3szqx7WfJUFavTDPfHDIIE9zy3QZN/mIrxLxdPuADbg=; b=UnINNk6E GyvzTfy8FBcyg5dFL6TZaMHphZU2dPHX8JqVjn1Livlyc6mfUaI/TbZw03NNB4eg U0w7UjLAkZe4yjoBWGOmmjV7yL62wByY2Q+vkaQFnXS0dKc+NxFbhiLaIDyM28fZ PCE/EE9TnyiXoCgPeLwwjbHLTDfJ9X+PxcmNCNlZpwAvEc89rw9dC7EZAx5wgUBu 9D6BCD5F2Xg5L4v2nG7jgQvmLVlReOQFzM0N/z4cZZZMsMTev3s7f0QksELaHOOD ogRXa0FyNcmGietdBosOiX40h8f4oqFthUCSIOFdz5gtw7y4ehBeP2b+zhf/MmOu f78utW1d8fZgrg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddvuddgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedujeevjeffjeevuddutedvkeeiueeitddvieelfeekveej udefgeeuvdejhfeuleenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 31 Aug 2021 09:56:33 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 77ACC2A07DE; Tue, 31 Aug 2021 09:56:30 -0400 (-04) Date: Tue, 31 Aug 2021 09:56:30 -0400 From: Alvaro Herrera To: Andres Freund Cc: Pg Hackers , "Bossart, Nathan" , Kyotaro Horiguchi , =?utf-8?B?6JSh5qKm5aifKOeOiuS6jik=?= , Jakub Wartak Subject: Re: prevent immature WAL streaming Message-ID: <202108311356.sl33wcpcz5x6@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210831042949.52eqp5xwbxgrfank@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Aug-30, Andres Freund wrote: > I'm doubtful that the approach of adding awareness of record boundaries > is a good path to go down: Honestly, I do not like it one bit and if I can avoid relying on them while making the whole thing work correctly, I am happy. Clearly it wasn't a problem for the ancient recovery-only WAL design, but as soon as we added replication on top the whole issue of continuation records became a bug. I do think that the code should be first correct and second performant, though. > - There are very similar issues with promotions of replicas (consider > what happens if we need to promote with the end of local WAL spanning > a segment boundary, and what happens to cascading replicas). We have > some logic to try to deal with that, but it's pretty grotty and I > think incomplete. Ouch, I hadn't thought of cascading replicas. > - It seems to make some future optimizations harder - we should work > towards replicating data sooner, rather than the opposite. Right now > that's a major bottleneck around syncrep. Absolutely. > I think a better approach might be to handle this on the WAL layout > level. What if we never overwrite partial records but instead just > skipped over them during decoding? Maybe this is a workable approach, let's work it out fully. Let me see if I understand what you mean: * We would remove the logic to inhibit archiving and streaming- replicating the tail end of a split WAL record; that logic deals with bytes only, so doesn't have to be aware of record boundaries. * On WAL replay, we ignore records that are split across a segment boundary and whose checksum does not match. * On WAL write ... ? How do we detect after recovery that a record that was being written, and potentially was sent to the archive, needs to be "skipped"? -- Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/