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 1lTuyM-0005WE-Hg for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Apr 2021 23:19:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lTuyL-0000OR-5N for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Apr 2021 23:19:01 +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 1lTuyK-0000OK-PN for pgsql-hackers@lists.postgresql.org; Tue, 06 Apr 2021 23:19:00 +0000 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lTuyE-0003eM-1s for pgsql-hackers@postgresql.org; Tue, 06 Apr 2021 23:18:59 +0000 Received: by mail-qt1-x829.google.com with SMTP id y12so12456196qtx.11 for ; Tue, 06 Apr 2021 16:18:53 -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:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=/MerA9/v2P0lJua0Gm6ZZMqOFlRwSPm7E1vauk27DV8=; b=Dq4fqEcoWaG6iuNAkbRanqxA1XTr5Znmi+Bjsyg7/jKns+MJb+/Pr0uUb1FBoerySn iaVOyhd/ftIbt9JDaxAyR9y5p9TOSqe1ZlKUbe7Xy4RATtOlNz7XGVjysJFpXhfkN+SO 6mBmRYq9nIWzEBYqCAGJLYBh7WcpVXDgaV1UALoNkrLLVsSjtJNiCWcdL3sWL2BtS6Om 9jKgTCEj1PJ/fTsF/IDHbJUWcZL8vAWuuGuesiMqfpHxHyVmBHZS5FjBOMX0/Lxo/nSC IF+9JHRSbgprv11F14PJ+m1vqnf2MMjY5PdYZVY3t81vLnH2gUwbhgJzfxKTFBz1qfix haWA== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=/MerA9/v2P0lJua0Gm6ZZMqOFlRwSPm7E1vauk27DV8=; b=XGe5mBTgI7IjvbHZAwquwfIf6SjcgAoCdnjy+pgY+via8kdsJ1ZCv+NdzMQYaH353c FhWGMxYs85nDR3zkdrXA9xYhnOO3/DWt9YQmNqvtEeYshbnuxGLkeukvV34HWAIdQOFT JsvJYtXoso9HO9pRJo/DjYU+J/LrxaHqB4jXcxKW6jEDuuCjICY4sejJeHQIfiS+cn7p c6cjOav0Lu6aefvhURor5RM8f/Mm5xnGv5z3tdO/ilvb1TGKEXYFtfxP9u45HFV2rQbY ih5gEQlQ7jbK+1utJ9rrJD0oXPTx/qh47BwzTakBRb4eh0LwpoYmttFcCWZ7BIFyV+cD TqQg== X-Gm-Message-State: AOAM531/r1OCvWc6xl0mzJIaMXezciVjJJ3tpsLNm/SaY2vI2GGxpVWH x8xFmoZ8hkYSU6IjUdmA+wMIjQ== X-Google-Smtp-Source: ABdhPJxYoDMuL8YnJtX2eRPC5RQDIy4PkTi+VXMOMUp6KWKfrE7ayUZoX/tTimc/13hvwF6NLBM2Bw== X-Received: by 2002:ac8:5951:: with SMTP id 17mr368769qtz.62.1617751133057; Tue, 06 Apr 2021 16:18:53 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.95]) by smtp.gmail.com with ESMTPSA id i6sm17107627qkf.96.2021.04.06.16.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 16:18:52 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id B570F2A0A89; Tue, 6 Apr 2021 19:18:50 -0400 (-04) Date: Tue, 6 Apr 2021 19:18:50 -0400 From: Alvaro Herrera To: Thomas Munro Cc: Kyotaro Horiguchi , takashi.menjo@gmail.com, Craig Ringer , Heikki Linnakangas , Andres Freund , pgsql-hackers , takashi.menjou.vg@hco.ntt.co.jp Subject: Re: Remove page-read callback from XLogReaderState. Message-ID: <20210406231850.GA15722@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Apr-07, Thomas Munro wrote: > I wonder if it would be better to have the client code access these > values through functions (even if they just access the variables in a > static inline function), to create a bit more separation? Something > like XLogReaderGetWanted(&page_lsn, &bytes_wanted), and then > XLogReaderSetAvailable(state, 42)? Just an idea. I think more opacity is good in this area, generally speaking. There are way too many globals, and they interact in nontrivial ways across the codebase. Just look at the ThisTimeLineID recent disaster. I don't have this patch sufficiently paged-in to say that bytes_wanted/ bytes_available is precisely the thing we need, but if it makes for a cleaner interface, I'm for it. This module keeps some state inside itself, and others part of the state is in its users; that's not good, and any cleanup on that is welcome. BTRW it's funny that after these patches, "xlogreader" no longer reads anything. It's more an "xlog interpreter" -- the piece of code that splits individual WAL records from a stream of WAL bytes that's caller's responsibility to obtain somehow. But (and, again, I haven't read this patch recently) it still offers pieces that support a reader, in addition to its main interface as the interpreter. Maybe it's not a totally stupid idea to split it in even more different files. -- Álvaro Herrera 39°49'30"S 73°17'W