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 1tvKU6-003YXJ-51 for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Mar 2025 18:19:14 +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 1tvKU2-006Gqb-Ek for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Mar 2025 18:19: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 1tvKU1-006GqR-T2 for pgsql-hackers@lists.postgresql.org; Thu, 20 Mar 2025 18:19:10 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tvKTz-000AnP-2u for pgsql-hackers@postgresql.org; Thu, 20 Mar 2025 18:19:09 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2235189adaeso22791265ad.0 for ; Thu, 20 Mar 2025 11:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1742494747; x=1743099547; darn=postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Ec6IzoCuewSTQ5ZdqYkGgR0YgL0rUf7XyFisLYYRtSo=; b=WSoSmh0XO+Ju3+vQK5sSqOq5TCjACfr3bLoKuVpocQbYL+ne1NXatDjsrMIZDQvBiJ N5sBTeDmLGGtrLrOcu8qcZdTGRArTP86Krzu55srfZNjjWIZBhWWtNu2VYu9gaPi0QvE J0OEvpoUW7qcuXZQkFZl9l7PqCL+/vp0IhRj8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742494747; x=1743099547; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ec6IzoCuewSTQ5ZdqYkGgR0YgL0rUf7XyFisLYYRtSo=; b=qgEql1RmylMquHGl+UNNWVLSsLwUYInrXkgo5J1wCob1oZj07yuuC61HgocGJCqXth G6lC5j5V4aE5SZAlbKEOdqUvnqEnPb+glsnc0q6rSYksYIf7UV5kdfldoMD3XeWQ7dmb yF66aMxD4WUB035M+jRQT4fiKbbJdmTckOOZ2wFAkVQuZgt7JDSiP9L8IOjxJKIDSrwb ua5zBzlmEhJgX+aD0oeCpjShE9Yt/9x08v4PFlzE/8EeBQHFJnOc7zWvilVBuU8A03tm w4sZIEpLiG6RCoNOuNhyOHIc6gWp8SLBLvEfw6yeWtKp1puLVmQPpmB6zkesxPoxyPpI DNOg== X-Forwarded-Encrypted: i=1; AJvYcCXiw9MK8nZ0eH9funithef7s40F1O9bAmwsW6cfql0aiiKQzpqXaQoY6Q7zB+W+ECFm503P7jC9ed03lWOk@postgresql.org X-Gm-Message-State: AOJu0YxBDTjzZVrflSq3Hs8Qcaa2hEwGFJxIrYxLYSrWDG5WXFvnK7rI flx1RkkW38MtomxA/dhb6/q6l+F3qNHzbZBdBDRoh0xMjf6Ul4x17Tyha9HUkQ== X-Gm-Gg: ASbGncvsuBw13u1KW0dZK3ypoqDeoEiHBHRPt+whBfrxufexvDKGmz6x9kXUAf98rzR wNZUlFaQ7QJqAnpuz+0dOsUPi/ZtVAWLfwh483tzPzlNgjAaVED+E/2uSCkR9uFxn1jG6IK8hri xBxLd/m8F+0c9BGg0+RPWFhC/VXkD0Q6Up80e1OY2uBZo8Rr9H4bNS/ug11RNNsRliNnWu85xAP YKnFD8ulaIm0wO5W5YfM9kAGayrUcHUILupOuW7BdQU9VsAq8CLMAph9ZyhqpsZGpnvxfOcgoDN ezbPzwU8DNYsvkupiJvgZ4GxiAgyVuTBoVXFaec6tw== X-Google-Smtp-Source: AGHT+IFNZsXL5ONNBGIvovLMAiprIGscShuFm33fyP3K3GYcK5oRVmp6QIbfmDZqcnzopa1Axh7OgQ== X-Received: by 2002:a17:902:f685:b0:215:a303:24e9 with SMTP id d9443c01a7336-2278067c27dmr7125735ad.3.1742494746565; Thu, 20 Mar 2025 11:19:06 -0700 (PDT) Received: from google.com ([2601:647:5600:80d0::31cd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22781207f3csm906925ad.247.2025.03.20.11.19.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Mar 2025 11:19:06 -0700 (PDT) Date: Thu, 20 Mar 2025 11:19:04 -0700 From: Noah Misch To: Andres Freund Cc: Antonin Houska , pgsql-hackers@postgresql.org, Thomas Munro , Heikki Linnakangas , Robert Haas , Jakub Wartak , Jelte Fennema-Nio Subject: Re: AIO v2.5 Message-ID: <20250320181904.8a.nmisch@google.com> References: <20250312035743.f5.nmisch@google.com> <4b3f32ug3cayekysqlgspz2qjmeb7lca3gvazayglxr2m3d4dv@il33accgsji7> <17906.1741863183@localhost> <3yxd5r23zly5bytvgyktbxtxq2r3gbpi7xd4dugevh3h4w4q6c@lu6oatjjpltz> <20250319212530.80.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 20, 2025 at 01:05:05PM -0400, Andres Freund wrote: > On 2025-03-19 18:17:37 -0400, Andres Freund wrote: > > On 2025-03-19 14:25:30 -0700, Noah Misch wrote: > > > > + * marked as failed. In case of a partial read, some buffers may be > > > > + * ok. > > > > + */ > > > > + failed = > > > > + prior_result.status == ARS_ERROR > > > > + || prior_result.result <= buf_off; > > > > > > I didn't run an experiment to check the following, but I think this should be > > > s/<=/ > > [1*BLCKSZ, 2*BLSCKSZ - 1]. md_readv_complete will store result=1. buf_off==0 > > > should compute failed=false here, but buf_off==1 should compute failed=true. > > > > Huh, you might be right. I thought I wrote a test for this, I wonder why it > > didn't catch the problem... > > It was correct as-is. With result=1 you get precisely the result you describe > as the desired outcome, no? > prior_result.result <= buf_off > -> > 1 <= 0 -> failed = 0 > 1 <= 1 -> failed = 1 > > but if it were < as you suggest: > > prior_result.result < buf_off > -> > 1 < 0 -> failed = 0 > 1 < 1 -> failed = 0 > > I.e. we would assume that the second buffer also completed. That's right. I see it now. My mistake. > What does concern me is that the existing tests do *not* catch the problem if > I turn "<=" into "<". The second buffer in this case wrongly gets marked as > valid. We do retry the read (because bufmgr.c thinks only one block was read), > but find the buffer to already be valid. > > The reason the test doesn't fail, is that the way I set up the "short read" > tests. The injection point runs after the IO completed and just modifies the > result. However, the actual buffer contents still got modified. > > > The easiest way around that seems to be to have the injection point actually > zero out the remaining memory. Sounds reasonable and sufficient. FYI, I've resumed the comprehensive review. That's still ongoing.