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 1lUA60-0005tq-6w for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Apr 2021 15:27:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lUA5z-0003pw-21 for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Apr 2021 15:27:55 +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 1lUA5y-0003pp-MK for pgsql-hackers@lists.postgresql.org; Wed, 07 Apr 2021 15:27:54 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lUA5t-0002vq-MH for pgsql-hackers@postgresql.org; Wed, 07 Apr 2021 15:27:52 +0000 Received: by mail-ed1-x535.google.com with SMTP id w18so21460177edc.0 for ; Wed, 07 Apr 2021 08:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=uO00keklkXM+VHVgoIeZXXW1G+MoT4n5NkqwOOnTXnk=; b=nmd9E0I+DLg6UW3J4M40nElbAK1LfXjkR7SkLtgcCr4Cl3I83zjWCQ8zko7/CZ1riq suUcrQH9du+lF1SzKrvgU3KnBM7en5iUKO2rz8tt00Ufct5NuDbq+MrCH8hpCpHMOM9c oV0xo510i9o0dZ01jKKgFDXn2L0pvoW9YhgNyEvYECE/vgeLt+3mmjKmcltUW2zE/8kS idQkJEJ7LYa9qwPLJlrSerUfbItNpIy7ovi8z5vCZ51OFpswWxJsE3rQ29HT7N9inqua pvHnw/A5EuO55+iilX+pPIq3iSsmSxdKqQvbdmvTdYoMJJDAUDTs9r/fW7nKyhFySzrf m/MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=uO00keklkXM+VHVgoIeZXXW1G+MoT4n5NkqwOOnTXnk=; b=MYUg40PI/KMdKSVbctQZOs65d/L7Wb+S60xE6C8SjJjcwHTZr+wzdLuwG31DwKsj1B /1Fd/APavGvBK7aNUbGBp3E/k/LHbm3VO8HTZVYpXGQUj9OhyoNk4PhqcB9XRGco8tFg hzDhwujo0h9S60rKb/TAWNWjzZegNTIxG96OoL3K2+HiE9bNgOklBesrR93loJc/m+E/ KsUjcJ7lf2b36JQ1Y3mIQCdHX3kmtAVgppZyZWozhWdfeWHB445wVtAClvJgzuaHYvY0 Cjg1tiJywQaGcY/gRCtGj2o4fvUf6mMURNfiyVgwZDqm4J3hyoZajcaGon8Fr74T/lfE ex/Q== X-Gm-Message-State: AOAM533rne/jRH66QBkZ5uGvl8NiCgvuEMtuK90YgH0KBOlrSMh4HvXb 8anUHCe2z68GNUXxqXFWWJ1YHa4YG6+1dgpHeTBZVHLFGA8kHHEUuQWEKjr++HqlXiNCi+MOshL HY7XnkCTQehAXsM0MDWj7d+qXT5Zb26fX2llX/NSRx5Z54kDlww1x0CYxZL6tgUDvGWFcma2DSq maAtNOIHtCZy+FgebWWupoBUqlvQobtI77hDCyNeVTilxT+rLH2C6KjGyBSlykUva6SQXDX7V8t miQe8u+7T4mRreFOJA6IBniqgLCmflMVYziyA== X-Google-Smtp-Source: ABdhPJxD6x1CQCxH33VUgcIPYRjs76fD2PeHjBeZGOXVB28jXeH51WJd4Eax2fHQUmFxISIoQZ/1sg== X-Received: by 2002:aa7:cf03:: with SMTP id a3mr5107779edy.142.1617809268328; Wed, 07 Apr 2021 08:27:48 -0700 (PDT) Received: from [10.137.0.20] (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id r25sm15954446edv.78.2021.04.07.08.27.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Apr 2021 08:27:47 -0700 (PDT) Subject: Re: WIP: WAL prefetch (another approach) To: Thomas Munro Cc: Stephen Frost , Andres Freund , Jakub Wartak , Alvaro Herrera , Tomas Vondra , Dmitry Dolgov <9erthalion6@gmail.com>, David Steele , pgsql-hackers References: <20210210215033.GA27507@tamriel.snowman.net> <103ec76d-8bbc-09e1-460c-8785751431b5@enterprisedb.com> <20210212044614.5wqjkjbcmbwzever@alap3.anarazel.de> <20210213213930.GM27507@tamriel.snowman.net> <20210214231815.GO27507@tamriel.snowman.net> <17b3f450-048c-f3a6-7086-259523f33cbc@enterprisedb.com> <20210317214331.GF20766@tamriel.snowman.net> <28c3352e-5388-6410-aae7-05907079e6c9@enterprisedb.com> <8dd2dcc2-0b6b-a4ab-c1b3-032c0a5ab1c3@enterprisedb.com> From: Tomas Vondra Message-ID: Date: Wed, 7 Apr 2021 17:27:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/7/21 1:24 PM, Thomas Munro wrote: > Here's rebase, on top of Horiguchi-san's v19 patch set. My patches > start at 0007. Previously, there was a "nowait" flag that was passed > into all the callbacks so that XLogReader could wait for new WAL in > some cases but not others. This new version uses the proposed > XLREAD_NEED_DATA protocol, and the caller deals with waiting for data > to arrive when appropriate. This seems tidier to me. > OK, seems reasonable. > I made one other simplifying change: previously, the prefetch module > would read the WAL up to the "written" LSN (so, allowing itself to > read data that had been written but not yet flushed to disk by the > walreceiver), though it still waited until a record's LSN was > "flushed" before replaying. That allowed prefetching to happen > concurrently with the WAL flush, which was nice, but it felt a little > too "special". I decided to remove that part for now, and I plan to > look into making standbys work more like primary servers, using WAL > buffers, the WAL writer and optionally the standard log-before-data > rule. > Not sure, but the removal seems unnecessary. I'm worried that this will significantly reduce the amount of data that we'll be able to prefetch. How likely it is that we have data that is written but not flushed? Let's assume the replica is lagging and network bandwidth is not the bottleneck - how likely is this "has to be flushed" a limit for the prefetching? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company