Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fAW6l-0000sx-WE for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Apr 2018 07:41:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fAW6l-0000am-4J for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Apr 2018 07:41:55 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fAW6k-0000ac-NO for pgsql-hackers@lists.postgresql.org; Mon, 23 Apr 2018 07:41:54 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fAW6g-0007nJ-MH for pgsql-hackers@postgresql.org; Mon, 23 Apr 2018 07:41:53 +0000 Received: by mail-lf0-x244.google.com with SMTP id g203-v6so13423222lfg.11 for ; Mon, 23 Apr 2018 00:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=r6vNVa5DSfvJ6iA12Jz3dMdcowif8eQeU30VHVhbAoQ=; b=qt4TEaRr4MN5AQWQHDjS5kJX9sU5DUFg176brnha1YbbJJ/BcgRHwgmnUvef8pHMUp b+o+dTsMOVQ04O+lIodOzsaeePs8TOoYLEOld/v/c7jzElx7miW0W70hAuqYXNW8laDu 4WQr/Svq2eWXBzfbVPARXnK+kpCNfI+SGcphybLeExSA+FRGyxvxuGMsRku2AZvjSYv7 CocwGyCOyQbR+ME7m6xmM7TiG32SkKeX8DCZHc+LKVEpSrNzXNV+UYz5LURSle77BXUX tBQcr1URKbZuYN9Vc4YgcptgQN/ywqNjg/j/SwezHi+LGav6czVQoQ9pCvzcmTMSH6LE jcTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=r6vNVa5DSfvJ6iA12Jz3dMdcowif8eQeU30VHVhbAoQ=; b=Z0YRGXrIaDlCjvb51KEe7i3mBAUolmv/0NOZ9JWfUEcg97Z/R7VmRmtYCAmsNVY2Dv wzCPmL3BJHGoI2mssnqtPQx/ZihCUoRbvSSktN5pAclqCJ+yaiujYgrAQP8tTBU6ubEB 09tmlnMgvghp8cvZS6rebHkJYg3UYMKXBHulu741BzZrWU6YSZnr/kp4hdk5cjUsoGNC h+TsoTPSaAjNcExI9MMNo3Gh/vTOCcugjSzdSEgFSIxf/qrjGkCit4tQSibAzYCOr7kk /c5h5WbOgQsqBButXS4683nzlAiY9QE0BhVKM8L4c6GOO26Hcpi8qpHA4Atms4kkxCbi ZUkA== X-Gm-Message-State: ALQs6tA/B37pGL782FP5pBmzmsFjx9rzc0oKnTFXcVVisiImIqgwu/f7 tylY1f7anahbjudyhKWf34bxIA== X-Google-Smtp-Source: AIpwx4+9Yeoo7vhZOn2lpR3AJR0V2Vvso1jMTaowhDvwt0KrmdG+ldxUso30xpQQ9ngt396VvELBkg== X-Received: by 10.46.97.1 with SMTP id v1mr6387072ljb.62.1524469308417; Mon, 23 Apr 2018 00:41:48 -0700 (PDT) Received: from [192.168.1.111] (dsl-hkibng32-54fbf8-78.dhcp.inet.fi. [84.251.248.78]) by smtp.gmail.com with ESMTPSA id t26sm2198571lji.33.2018.04.23.00.41.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 00:41:47 -0700 (PDT) Sender: Heikki Linnakangas Subject: Re: [HACKERS] [BUGS] Bug in Physical Replication Slots (at least 9.5)? To: Kyotaro HORIGUCHI , andres@anarazel.de Cc: michael.paquier@gmail.com, sfrost@snowman.net, nag1010@gmail.com, jdnelson@dyn.com, pgsql-hackers@postgresql.org References: <20180117123832.GB2416@tamriel.snowman.net> <20180118115827.GA12826@paquier.xyz> <20180118195252.hyxgkb3krcqjzfjm@alap3.anarazel.de> <20180119.105453.132600443.horiguchi.kyotaro@lab.ntt.co.jp> From: Heikki Linnakangas Message-ID: <89e33d4f-5c75-0738-3dcb-44c4df59e920@iki.fi> Date: Mon, 23 Apr 2018 03:41:47 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180119.105453.132600443.horiguchi.kyotaro@lab.ntt.co.jp> 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: Precedence: bulk On 18/01/18 20:54, Kyotaro HORIGUCHI wrote: > At Thu, 18 Jan 2018 11:52:52 -0800, Andres Freund wrote in <20180118195252.hyxgkb3krcqjzfjm@alap3.anarazel.de> >> On 2018-01-18 20:58:27 +0900, Michael Paquier wrote: >>> b) The second patch that I would like to mention is doing things on the >>> standby side by being able to change a WAL source when fetching a single >>> record so as it is possible to fetch the beginning of a cross-segment >>> record from say an archive or the local xlog, and then request the rest >>> on the primary. This patch can be found in >>> https://www.postgresql.org/message-id/20171026.190551.208996945.horiguchi.kyotaro%40lab.ntt.co.jp >>> and the diff in WaitForWALToBecomeAvailable() scares me a lot because, >>> it seems to me that this actually breaks timeline switch >>> consistency. The concept of switching a WAL source in the middle of a >>> WAL segment is risky anyway, because we perform sanity checks while >>> switching sources. The bug we are dealing about here is very rare, and >>> seeing a problem like that for a timeline switch is even more rare, but >>> the risk is not zero and we may finish with a corrupted instance, so we >>> should not in my opinion take this approach. Also this actually achieves >>> point 2) above, not completely though, but not 1). >> >> I don't agree with the sentiment about the approach, but I agree there >> might be weaknesses in the implementation (which I have not reviewed). I >> think it's perfectly sensible to require fetching one segment from >> pg_xlog and the next one via another method. Currently the inability to >> do so often leads to us constantly refetching the same segment. > > Though I'm still not fully confident, if reading a set of > continuation records from two (or more) sources can lead to > inconsistency, two successve (complete) records are facing the > same risk. This seems like the best approach to me as well. Looking at the patch linked above (https://www.postgresql.org/message-id/20171026.190551.208996945.horiguchi.kyotaro%40lab.ntt.co.jp): > --- a/src/backend/access/transam/xlog.c > +++ b/src/backend/access/transam/xlog.c > @@ -11693,6 +11693,10 @@ retry: > Assert(reqLen <= readLen); > > *readTLI = curFileTLI; > + > + if (!XLogReaderValidatePageHeader(xlogreader, targetPagePtr, readBuf)) > + goto next_record_is_invalid; > + > return readLen; > > next_record_is_invalid: What is the point of adding this XLogReaderValidatePageHeader() call? The caller of this callback function, ReadPageInternal(), checks the page header anyway. Earlier in this thread, you said: > The rest to do is let XLogPageRead retry other sources > immediately. To do this I made ValidXLogPageHeader(at)xlogreader(dot)c > public (and renamed to XLogReaderValidatePageHeader). but I don't understand that. - Heikki