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.96) (envelope-from ) id 1vyV4Y-000AKa-00 for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Mar 2026 13:18:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vyV4W-0055gk-1E for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Mar 2026 13:18:28 +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.96) (envelope-from ) id 1vyV4V-0055gc-39 for pgsql-hackers@lists.postgresql.org; Fri, 06 Mar 2026 13:18:28 +0000 Received: from mail-dy1-x1329.google.com ([2607:f8b0:4864:20::1329]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vyV4U-00000000m8v-23nv for pgsql-hackers@postgresql.org; Fri, 06 Mar 2026 13:18:27 +0000 Received: by mail-dy1-x1329.google.com with SMTP id 5a478bee46e88-2be19f05d7dso397961eec.1 for ; Fri, 06 Mar 2026 05:18:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772803106; cv=none; d=google.com; s=arc-20240605; b=BtfWM3gmb5/YbqiKZRZ57pHKYYVknru8aCDoBLPgKbaL3syLLLyaLecRsonrQQc2Ay cQWzh4tS9XdGhMShctRdoqbo8Qucm1NzDo4rR8SjuDjz+LQw7F3jsdEpIWutEyQcFeLa nds+AeUDsFQbAD35/v3wVLZgtQuHTPsGObC6PEHMCJCIwf1H/OuZctETpDSO4/CkbIdz YQFwzV4qV3g5E+i6fMMT08RaD+ef3hR1UxcsL3rdqyc7ANl4mJnoo7uYC8gyPHzZn0wM FUIqjP0Q2cqGIzltOFkllc7AZ+xAPWA6Hi9pkzGRk6Y7R8w4Z6s4yXywCPgf7Z5VJTRH N4dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rJo5NJKhqpmFOVjbgCfh7sFR/TGKJ33AoTHYoPAcNyU=; fh=1dNTHJ3RE7haO4mONkNi9gCQx3eU5m4rkBLlwlSZIKE=; b=f2P10z9GtPtDkl48LdGqX8tQVNpiEnvFwDaFEkmbSGs6f6AEXqqIkUO4AqDAAPDdKa BPonN9tpF120oujI7I8U2w1KBxMHRxVfUMduZTLi7VLuIbi9EJHAOQNKcgP8nYsLuFDW csAGPqYPx/77juEGcBFskezz2N0+VthXyCNb9IpTyeTP/SETemOeKppTCohIVHAPuZva YdrVBNnkYRIVOC+c6qPI8ycYIZLh4+LhuJmrRGzbo1/2yQgut6SZEHpT49Qg2MjefNCi 40EScGsbu7KRjuHhwXpd0RewCWwdqTkbwhnrtd+KxL5urPo/KTW0TxiEL+3Wvg9WDV6t 1Rbg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772803106; x=1773407906; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rJo5NJKhqpmFOVjbgCfh7sFR/TGKJ33AoTHYoPAcNyU=; b=GdXRDa4zlxPw6tNpQzqoIDX1Dm/bmbawNlFItBHUYip6l+jN/V5tkU5aiXKHxb4DcX m4dzF5itgECee89CrNSQVqxkWUAH8VaEdN+Ss8bXKa3pazlFwzqe5MwS3FwCrN2uMe0r Am396a//faKLtVPG9dL3zjP0KKkaJkoq0LiGjzILn7ryau3HQi4vPV345N3avCvRvZ9I kjKmYnjK6UAG+roseCB6qHTKTIBMn64Aweyawej7rqqf/BzKHWdiGGGVsio09rt/WV0G BROjVQUXoGXFnscITe+aE0LATBGJmRZRioFPQ+nLoliuK5EDu/5+GDSD6GtKFOnlupLO jd2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772803106; x=1773407906; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rJo5NJKhqpmFOVjbgCfh7sFR/TGKJ33AoTHYoPAcNyU=; b=DPXmkwJE6bQKDSrBl0ABuPHP11glAH1QiMTBy88dFjyJ4S+RnmpOVL1uPiF8a4PVOR WleKQqF4rKInVhMqd1PhYrktu8j3dgrJRoSbJdmrkghfRFgHzqUY2bP/7/h4fd9MeZkc nQVvq1vc6NKmgk9uo31ArGvDPiiXgCGhh4gRXQ4ObB/W/kZjps1/4p+1qbSjzT8XuPs9 G5YaFVuENelY/5dtTeHrpTDTOWoXXvbG8VkklFVfgWn1nIIGptSYSqmjLguPIH0S2zF5 VD3xc7HS7DyO0LtCXwQ5p0oYHpp4GgLXJibj7w+UTELIqL27C9s0xFCWbMZ6V4VWKZlW VFpA== X-Forwarded-Encrypted: i=1; AJvYcCX1g/k/L9Luv9a1hXhWjhL2eFfOMwOTlWkFvYJWpwZ/SWG6QI6wsXqOpec0PQRE6s6b8PIHu/NF+wC20kHR@postgresql.org X-Gm-Message-State: AOJu0YySYPnzsujBItRKDMO2wbq2fe+1t9mDLW2YxW+KaKVNQBvpaShj 7PfEjWkBy2HfstgtAn3DRkF67GiK7+w4dVZp6rQLQvrjEQ0XoURDQxekOIQt7ymWmZVeKJt7sc2 nf/iFTCZYunumJ/7KOJJ5jCPTDrG6B6c= X-Gm-Gg: ATEYQzxNYW8ywu/lLmTudJBHtZcIKIGYy03+vhpSgF6aTnHquzYBsqMJzpIScF4BUy0 LL3r8zh77wwfBJTswzxXvr67287tDE6U6WpQ1rnysHB/wTf/Qd6nJc8odxCAr+jQYvAiEM7Guyk H3c/4aBtuWiFKw0GwKgRsFS1snLKsF9+z2NdNErPBGQ9VwOkCWSqN85ZfCPgexFBZ9lQvHH61Fb YWVZK4jKvbtsRlr/FIRxXdbQAld6r9eVmja4ChZ48Gr09hDSbLyJNQ8dzTzwKBtiQHzxlP8eMYS Niu6/r8EchULIppqbA== X-Received: by 2002:a05:7300:7494:b0:2bd:fff8:c7ea with SMTP id 5a478bee46e88-2be4e06a7damr873802eec.38.1772803105459; Fri, 06 Mar 2026 05:18:25 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Nazir Bilal Yavuz Date: Fri, 6 Mar 2026 16:18:13 +0300 X-Gm-Features: AaiRm53Ydq-DrLBy-bKCFjPXugqSVMWoB6nux9Ky_EMjrydx-ePHEaHwvzYTihU Message-ID: Subject: Re: Don't synchronously wait for already-in-progress IO in read stream To: Melanie Plageman Cc: Thomas Munro , Andres Freund , pgsql-hackers@postgresql.org, Peter Geoghegan , Tomas Vondra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, 3 Mar 2026 at 22:47, Melanie Plageman w= rote: > > On Thu, Feb 5, 2026 at 11:56=E2=80=AFAM Nazir Bilal Yavuz wrote: > > > > I did finally review Andres' test patches and have included my review > feedback here as well. > > "aio: Refactor tests in preparation for more tests" (v4-0001) looks > good to me as well. I included one tiny idea AI suggested to me in a > follow-on patch (v4-0002). This makes sense. > > diff --git a/src/test/modules/test_aio/t/004_read_stream.pl > > b/src/test/modules/test_aio/t/004_read_stream.pl > > +foreach my $method (TestAio::supported_io_methods()) > > +{ > > + $node->adjust_conf('postgresql.conf', 'io_method', 'worker'); > > + $node->start(); > > + test_io_method($method, $node); > > + $node->stop(); > > +} > > > > This seems wrong, we always test io_method=3Dworker. I think we need to > > replace 'worker' with the $method. Also, we can add check below to the > > test_io_method function in the 004_read_stream.pl: > > ``` > > is($node->safe_psql('postgres', 'SHOW io_method'), > > $io_method, "$io_method: io_method set correctly"); > > Good catch. Fixed. I also found a few other small things in this patch > (v4-0003) which I put in v4-0004. These look good. > Some ideas I had that I didn't include in v4-0003 because its Andres > patch and is subjective: > > For test_repeated_blocks, the first test: > > # test miss of the same block twice in a row > $psql->query_safe( > qq/ > SELECT evict_rel('largeish'); > /); > $psql->query_safe( > qq/ > SELECT * FROM read_stream_for_blocks('largeish', ARRAY[0, 2, 2, 4, 4]); > /); > ok(1, "$io_method: stream missing the same block repeatedly"); > > It says that it will miss the same block repeatedly, is that because > we won't start a read for any of the blocks until after > read_stream_get_block has returned all of them? If so, could be > clearer in the comment. Not everyone understands all the read stream > internals. I think we start a read of blocks because we hit stream->distance but it doesn't affect any consecutive same block numbers. What I understood is: Since io_combine_limit is 1, there won't be any IO combining. 0th block (0), miss, distance is 1; StartReadBuffersImpl() and WaitReadBuffers() are called for 0th block. 1th block (2), miss, distance is 2, StartReadBuffersImpl() is called. 2th block (2), miss, distance is 2, StartReadBuffersImpl() and WaitReadBuffers() are called 1th block. 3th block (4), miss, distance is 4, StartReadBuffersImpl() is called. 4th block (4), miss, distance is 4, StartReadBuffersImpl() and WaitReadBuffers() are called 2, 3 and 4th blocks. > I know a lot of other tests do this, but I find it so hard to read the > test with the SQL is totally left-aligned like that -- especially with > comments interspersed. You can easily flow the queries on multiple > lines and indent it more. I agree with you. > For test_repeated_blocks, the second test: > > # test hit of the same block twice in a row > $psql->query_safe( > qq/ > SELECT evict_rel('largeish'); > /); > $psql->query_safe( > qq/ > SELECT * FROM read_stream_for_blocks('largeish', ARRAY[0, 1, 2, 3, 4, > 5, 6, 5, 4, 3, 2, 1, 0]); > /); > ok(1, "$io_method: stream accessing same block"); > > I assume that the second access of 2 is a hit because we actually did > IO for the first one (unlike in the earlier case)? I think so but to clarify, all second access of [2, 1, 0] blocks are hit; r= ight? > For test_inject_foreign: > > In general, I am not ramped up enough on injection point stuff to know > if the actual new injection point stuff you added in test_aio.c is is > correct and optimal, but I did review the read stream additions to > test_aio.c and the tests added to 004_read_stream.pl. > > For test_inject_foreign, the 3rd test: > > # Test read stream encountering two buffers that are undergoing the s= ame > # IO, started by another backend > > I see that psql_b is requesting 3 blocks which can be combined into 1 > IO, which makes it different than the 1st foreign IO test case: > > ### > # Test read stream encountering buffers undergoing IO in another back= end, > # with the other backend's reads succeeding. > ### > > where psql_b only requests 1 but I don't really see how these are > covering different code. Maybe if the read stream one (psql_a) is > doing a combined IO it might exercise slightly different code, but > otherwise I don't get it. I think the main difference is that: > ### > # Test read stream encountering buffers undergoing IO in another back= end, > # with the other backend's reads succeeding. > ### SELECT array_agg(blocknum) FROM read_stream_for_blocks('largeish', ARRAY[0, 2, 5, 7]); We need to join waiting block number 5 and then start another IO for block number 7. > # Test read stream encountering two buffers that are undergoing the s= ame > # IO, started by another backend SELECT array_agg(blocknum) FROM read_stream_for_blocks('largeish', ARRAY[0, 2, 4]); We need to join waiting block number 2 but after waiting for an IO, IO for block number 4 should be already completed too. We don't need to start IO like the other case. --=20 Regards, Nazir Bilal Yavuz Microsoft