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 1skBOe-008SPQ-Me for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Aug 2024 23:51:16 +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 1skBOb-00DMnl-S6 for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Aug 2024 23:51:14 +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 1skBOa-00DMmw-Sy for pgsql-hackers@lists.postgresql.org; Fri, 30 Aug 2024 23:51:13 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1skBOY-002FbY-6b for pgsql-hackers@lists.postgresql.org; Fri, 30 Aug 2024 23:51:11 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-71434174201so2055535b3a.0 for ; Fri, 30 Aug 2024 16:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1725061869; x=1725666669; darn=lists.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=zwlgfMx7OqpI5MAHYMiZOH9wB29kUMXfc4ZuJ2tIO5Q=; b=NITbLgVogZjm+4zjMn5xaFJksys20RTzKUG6otkn9hP613f4OtMXVrBxI4HDtJbSSQ 4Vu51RdPmUrmxpJHUAucHpU/Rhk0VS0dapV3Ep7NtU/xehrAulYxsS6L5P70U1kvBGrz BH2O6WvGOdMha7BjFmgfDMU4tjTaX+wJOjRBk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725061869; x=1725666669; 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=zwlgfMx7OqpI5MAHYMiZOH9wB29kUMXfc4ZuJ2tIO5Q=; b=KHLVasgyWgXAXysutO5RoKl5IoUtGquBpthBsPwjnqn3MMEcZ1CdkuJimvCehKFQVD tSGwa6oNibEIP7wMP22iuG9xIqmFvd1JXVtqshKdkXKoXMOSy6Iru5hfHJ3hwj4cPowy oI6w3Lo/ZD2hIGt8w4MKLvHcs+ZTuWUbhRduQKIvlU50SP42GlOApaxDOjkURgGUI+Gz F1TCBz3pvWUlDZfgXQFdZ+RkzgD15IHiCVcYy2dlL7ShziY+O0HCmjdjgTNHG1nhhZcM YXSBFGzJW2kHTWKsb1+dqplBtC8UqnVmK4ZvznGIzEi3IH9eAkLavKu0RlxdIPJqaOjy MVTQ== X-Gm-Message-State: AOJu0Yypys9TytZ4Bvl3Cr/ZE1FcJ27T5dfn8sBvVGH7RTwF1D1dcbGs gLW0Dy/Y74uNInVKnSu8l8jIvuj3gd0zYDoA/PpsuX7xknL8Ce1KiAutEGVjdA== X-Google-Smtp-Source: AGHT+IG01WaQUMz5aRRG9+6J1bgjC8DI+okAK7M7KnaWyDWGbuoH+RsDV45tO6tB0fKvrRlxkrxpDA== X-Received: by 2002:a05:6a20:db0c:b0:1c4:8dc0:84f0 with SMTP id adf61e73a8af0-1cecf757fe0mr1006089637.43.1725061868945; Fri, 30 Aug 2024 16:51:08 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20515551a8esm31619675ad.251.2024.08.30.16.51.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Aug 2024 16:51:08 -0700 (PDT) Date: Fri, 30 Aug 2024 16:51:06 -0700 From: Noah Misch To: Nazir Bilal Yavuz Cc: PostgreSQL Hackers Subject: Re: Use read streams in pg_visibility Message-ID: <20240830235106.ac.nmisch@google.com> References: <20240820184742.f2.nmisch@google.com> <20240823190124.9e@rfd.leadboat.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 Tue, Aug 27, 2024 at 10:49:19AM +0300, Nazir Bilal Yavuz wrote: > On Fri, 23 Aug 2024 at 22:01, Noah Misch wrote: > > On Fri, Aug 23, 2024 at 02:20:06PM +0300, Nazir Bilal Yavuz wrote: > > > On Tue, 20 Aug 2024 at 21:47, Noah Misch wrote: > > > > On Tue, Aug 13, 2024 at 03:22:27PM +0300, Nazir Bilal Yavuz wrote: > I liked the block_range_read_stream_cb. Attached patches for that > (first 3 patches). I chose an nblocks way instead of last_blocks in > the struct. To read blocks 10 and 11, I would expect to initialize the struct with one of: { .first=10, .nblocks=2 } { .first=10, .last_inclusive=11 } { .first=10, .last_exclusive=12 } With the patch's API, I would need {.first=10,.nblocks=12}. The struct field named "nblocks" behaves like a last_block_exclusive. Please either make the behavior an "nblocks" behavior or change the field name to replace the term "nblocks" with something matching the behavior. (I used longer field names in my examples here, to disambiguate those examples. It's okay if the final field names aren't those, as long as the field names and the behavior align.) > > > > The callback doesn't return blocks having zero vm bits, so the blkno variable > > > > is not accurate. I didn't test, but I think the loop's "Recheck to avoid > > > > returning spurious results." looks at the bit for the wrong block. If that's > > > > what v1 does, could you expand the test file to catch that? For example, make > > > > a two-block table with only the second block all-visible. > > > > > > Yes, it was not accurate. I am getting blockno from the buffer now. I > > > checked and confirmed it is working as expected by manually logging > > > blocknos returned from the read stream. I am not sure how to add a > > > test case for this. > > > > VACUUM FREEZE makes an all-visible, all-frozen table. DELETE of a particular > > TID, even if rolled back, clears both vm bits for the TID's page. Past tests > > like that had instability problems. One cause is a concurrent session's XID > > or snapshot, which can prevent VACUUM setting vm bits. Using a TEMP table may > > have been one of the countermeasures, but I don't remember clearly. Hence, > > please search the archives or the existing pg_visibility tests for how we > > dealt with that. It may not be problem for this particular test. > > Thanks for the information, I will check these. What I still do not > understand is how to make sure that only the second block is processed > and the first one is skipped. pg_check_visible() and pg_check_frozen() > returns TIDs that cause corruption in the visibility map, there is no > information about block numbers. I see what you're saying. collect_corrupt_items() needs a corrupt table to report anything; all corruption-free tables get the same output. Testing this would need extra C code or techniques like corrupt_page_checksum() to create the corrupt state. That wouldn't be a bad thing to have, but it's big enough that I'll consider it out of scope for $SUBJECT. With the callback change above, I'll be ready to push all this.