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 1kFmqs-0004Jm-Gg for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Sep 2020 23:16:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kFmqr-00016g-4q for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Sep 2020 23:16:37 +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 1kFmqq-00016Y-Az for pgsql-hackers@lists.postgresql.org; Tue, 08 Sep 2020 23:16:36 +0000 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kFmql-0004K0-Cl for pgsql-hackers@postgresql.org; Tue, 08 Sep 2020 23:16:35 +0000 Received: by mail-ej1-x641.google.com with SMTP id q13so768890ejo.9 for ; Tue, 08 Sep 2020 16:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6dpUI9vw2Zmu3+8rEcE2ckVEbx/zIXUQBdJ6gRMLt0A=; b=S7PRzJqPE0hphgG/iXvZLAQveRka1suDVNhn8d1D8WiuZl1FufPEWz18EzSwXU1XC6 6O4VPt43RLzyXOcqMq36kD3IPvPZ9UJWliIX8fF1u0/j8Qgvtt5caMliHWQjWvOLDVaB DBr5i2oE3CO5AieWKpjFq5hx8Ku+/qr/3l7D46UqqmL08bU7anUETzwpaESZoZhWRduo bNOrozlBm+zRGFMOlHhkpiDaH/TBq3cD2Oq9Tah5QCPruNs1MEC7PhVT8HYDoCfm2oLV rzBl/DHE2MZbiPEMJhxfdHdn637fZMjGQKIQuHt0cdWwUUyUrIHq0gADNH5sQgzHR0cC 8s+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6dpUI9vw2Zmu3+8rEcE2ckVEbx/zIXUQBdJ6gRMLt0A=; b=Tomb0m1BDXTDA6p/MdE0jPtJOSzjZUGqjabYeBpNo7OrAEjfz5GusSSlWGiAFS3e72 kKeBLNHieHi4FGhzFsv5G6eijN14uic/qjU5KimsBVTjjXkdKZ5e9Fbjq7cqojrr7Dvg CL+nsY6x3vUBuKn1gemwEnOZS1CX9QTIJAQxF2C/uWno5ObRtbgMHDtMapeLURDxeofo ZUlpb98l4l1r4NI2I0jQpQ7NP8p8Kpv2smS3j/5gh3tMF3CpCBDMyw2RMpoSW2/F5oxF kHQtKpu4XLCpWeBJLPgSlY0614+pxAsQP7Dxnr3qlKDiujgXOs2Vh2CoyJVmkX1lWkZC CgpA== X-Gm-Message-State: AOAM5330AQ4u9SWi6pirRDb/HmfYm0nLM0f0i9LUTl/fBmYtXdssdP+m NRC6DGwvV7gnsGarlhNEy3thuQ== X-Google-Smtp-Source: ABdhPJycina8lxTcaA77jx4MYy/ifyV4er2zgEjSSzjuP2yGkapf+TNSNevQ47CFqSUYxV3qaVZ++Q== X-Received: by 2002:a17:907:2168:: with SMTP id rl8mr834946ejb.308.1599606989848; Tue, 08 Sep 2020 16:16:29 -0700 (PDT) Received: from localhost (ip-86-49-253-216.net.upcbroadband.cz. [86.49.253.216]) by smtp.gmail.com with ESMTPSA id u26sm447755ejj.11.2020.09.08.16.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 16:16:29 -0700 (PDT) Date: Wed, 9 Sep 2020 01:16:27 +0200 From: Tomas Vondra To: Thomas Munro Cc: Stephen Frost , Dmitry Dolgov <9erthalion6@gmail.com>, David Steele , Andres Freund , Alvaro Herrera , pgsql-hackers Subject: Re: WIP: WAL prefetch (another approach) Message-ID: <20200908231235.lsgat5ni35h6odqt@development> References: <20200606003632.GS6680@tamriel.snowman.net> <20200803154659.nzf5qzuozts5dujp@development> <20200806104701.j3xnkczd6qelfnhj@development> <20200901131426.5lse2jlepm3uligv@development> <20200901141826.gbhqz664brtt4y2t@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, Sep 05, 2020 at 12:05:52PM +1200, Thomas Munro wrote: >On Wed, Sep 2, 2020 at 2:18 AM Tomas Vondra > wrote: >> On Wed, Sep 02, 2020 at 02:05:10AM +1200, Thomas Munro wrote: >> >On Wed, Sep 2, 2020 at 1:14 AM Tomas Vondra >> > wrote: >> >> from the archive >> > >> >Ahh, so perhaps that's the key. >> >> Maybe. For the record, the commands look like this: >> >> archive_command = 'gzip -1 -c %p > /mnt/raid/wal-archive/%f.gz' >> >> restore_command = 'gunzip -c /mnt/raid/wal-archive/%f.gz > %p.tmp && mv %p.tmp %p' > >Yeah, sorry, I goofed here by not considering archive recovery >properly. I have special handling for crash recovery from files in >pg_wal (XLRO_END, means read until you run out of files) and streaming >replication (XLRO_WALRCV_WRITTEN, means read only as far as the wal >receiver has advertised as written in shared memory), as a way to >control the ultimate limit on how far ahead to read when >maintenance_io_concurrency and max_recovery_prefetch_distance don't >limit you first. But if you recover from a base backup with a WAL >archive, it uses the XLRO_END policy which can run out of files just >because a new file hasn't been restored yet, so it gives up >prefetching too soon, as you're seeing. That doesn't cause any >damage, but it stops doing anything useful because the prefetcher >thinks its job is finished. > >It'd be possible to fix this somehow in the two-XLogReader design, but >since I'm testing a new version that has a unified >XLogReader-with-read-ahead I'm not going to try to do that. I've >added a basebackup-with-archive recovery to my arsenal of test >workloads to make sure I don't forget about archive recovery mode >again, but I think it's actually harder to get this wrong in the new >design. In the meantime, if you are still interested in studying the >potential speed-up from WAL prefetching using the most recently shared >two-XLogReader patch, you'll need to unpack all your archived WAL >files into pg_wal manually beforehand. OK, thanks for looking into this. I guess I'll wait for an updated patch before testing this further. The storage has limited capacity so I'd have to either reduce the amount of data/WAL or juggle with the WAL segments somehow. Doesn't seem worth it. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services