Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rZdBr-005ZnT-91 for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Feb 2024 20:46:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rZdBq-00DBUo-Fc for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Feb 2024 20:46:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rZdBq-00DBUf-18 for pgsql-hackers@lists.postgresql.org; Mon, 12 Feb 2024 20:46:10 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rZdBj-006QMh-63 for pgsql-hackers@lists.postgresql.org; Mon, 12 Feb 2024 20:46:08 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1d94323d547so31868835ad.3 for ; Mon, 12 Feb 2024 12:46:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1707770762; x=1708375562; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=BCZXJnGM04wlyEfTBOr/ASHYYfEn0B7XKCB9IYi0WWo=; b=oymfu5YEUXdIJLyMf/+U+73cuLkW4E4fnwl/iLpSyPmTOuHax9rw5FW3mg9YlEX5Im E3A7ofJx0B0hb25+lHyyIkTUIuJQRxKgzrLltzF98pNe0xVtdNsTdmh1AHfjspBwL64m CQSC+ScYiRxTktqwHgzajO6NJssaNdYK0OxJoYsQzKmVbVcRbq+HcNOge63FGFeCU9dn wrdMqrCyC2/psmCQbLjkqgsEEkhIiZ3HrEPK9XhXVJidg6nY4p44YnLAF6I8ImmnTJGB jGsU4t+zolwR8LoMc0lF2jj2SFhU0TXG0iAGPKRui5wTDKUT/harDFluvorxoEHZZuq8 zopA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707770762; x=1708375562; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=BCZXJnGM04wlyEfTBOr/ASHYYfEn0B7XKCB9IYi0WWo=; b=U8v5S+LyCR//EpGraVL52/ijTmu0S3rcgAzQzQIUJgHYprMfLfcQ1ymr2VRwBVEzbo yvzq4AG+AA8BydR3xS23MuaMa3FmJynMX0yme+hk4OOhS0kEulqP38cDGVqdDgYeCrB2 g8FJvg9Y31eRLxgoW+lIFvA61LzktiM0vlaWQsTx9r6UhnlUng3vLSUUcJcsKcsnQX2X 5PebXBGzandYdaYtPS4q+ml1ytrvTIT4AXT2u8EocsHD4KbUzYYOM4FiWvaxyCdoc4lC CX0TlKOWURGRbNO7CwhkZxYJ1V7twp3r8AundabXVmvK1XJrGTftH5BRorjPLYfMw5yQ vkdQ== X-Forwarded-Encrypted: i=1; AJvYcCWkAUlNTO2JD3TKSgFhR7C7hbFvBOpm4ALtiOTRAx6ZFt9mTbY2dFU6fy2o7wLyU6e2y2/u2IxZJxkTHbQoP0Wz0/qiAd6ZY7e5GqqG9ZfmQglQ X-Gm-Message-State: AOJu0YxSwh3v3xFbyhYueSZw94AE4tr2Y/0NVlwRMzjY276dPToMTR5X MUPW0s5bgxS2eZXeVaEqPFffKz1Fr4L6E6STgEzKHY5lYFl/1z9W12700RhppQ== X-Google-Smtp-Source: AGHT+IG3kaDTbZ69/QIkk6BkRXrZU6uR5eHpPi4dGEkdLlQoHBQwWYESd2ZjJ8ZB6YlSB2MJNnVtzA== X-Received: by 2002:a17:902:da87:b0:1da:22a0:efba with SMTP id j7-20020a170902da8700b001da22a0efbamr6804561plx.63.1707770762334; Mon, 12 Feb 2024 12:46:02 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV94dsDHGTMC55UI+6PH5cPxGYQgS1BbXGYAmX04irTMO/zs3pRBLip5S8rPmPGn5cawEYyavXEKNxIamXKLPeiwrZHIlRG3vooyLXOOAPsNZTnl0Gpt1rdNeNfpgO72Vmp36gWxmYaVqq/zq1q8q5L3p5blcjqTdfqAFd0uBjKhiKr33N9X1iLhjt2kz4dIP1dgHK3U6qU99P7sNhTv66D7JHQrphSASk76BDvTHqLiTdcMjLoF4lZtglquTD20/jGNc+XfxrS8oZQtMI= Received: from [172.18.10.46] ([12.126.244.130]) by smtp.gmail.com with ESMTPSA id h5-20020a170902f7c500b001d9fc6df457sm753341plw.5.2024.02.12.12.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 12:46:01 -0800 (PST) Message-ID: Subject: Re: Improve WALRead() to suck data directly from WAL buffers when possible From: Jeff Davis To: Andres Freund Cc: Bharath Rupireddy , Alvaro Herrera , Dilip Kumar , Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org, Nathan Bossart , Masahiko Sawada Date: Mon, 12 Feb 2024 12:46:00 -0800 In-Reply-To: <20240212201853.r6dl25onohrwagxt@awork3.anarazel.de> References: <202401301731.o3cthlcry4ve@alvherre.pgsql> <20240212201853.r6dl25onohrwagxt@awork3.anarazel.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2024-02-12 at 12:18 -0800, Andres Freund wrote: > +=C2=A0=C2=A0=C2=A0 upto =3D Min(startptr + count, LogwrtResult.Write); > +=C2=A0=C2=A0=C2=A0 nbytes =3D upto - startptr; >=20 > Shouldn't it pretty much be a bug to ever encounter this? In the current code it's impossible, though Bharath hinted at an extension which could reach that path. What I committed was a bit of a compromise -- earlier versions of the patch supported reading right up to the Insert pointer (which requires a call to WaitXLogInsertionsToFinish()). I wasn't ready to commit that code without seeing a more about how that would be used, but I thought it was reasonable to have some simple code in there to allow reading up to the Write pointer. It seems closer to the structure that we will ultimately need to replicate unflushed data, right? Regards, Jeff Davis [1] https://www.postgresql.org/message-id/CALj2ACW65mqn6Ukv57SqDTMzAJgd1N_AdQtD= gy+gMDqu6v618Q@mail.gmail.com