On Tue, Feb 4, 2025 at 5:34 PM Melanie Plageman
<melanieplageman@gmail.com> wrote:
> I think I misspoke when I said we are unlikely to have contended
> all-visible pages. I suppose it is trivial to concoct a scenario where
> there are many pinned all-visible pages.
It's hard to keep heap pages pinned for a really long time, so there
aren't likely to be a lot of them at once. Maybe async I/O will change
that somewhat, but the word in this sentence that I would emphasize is
"concoct". I don't think it's normal for there to be lots of pinned
pages just hanging around.
(It's a bit easier to have index pages that stay pinned for a long
time because an index scan can, or at least could last I checked, hold
onto a pin while the cursor was open even if we're not currently
executing the query. But for a heap page that doesn't happen, AFAIK.)
> However, if we don't count an eagerly scanned page as a failure when
> we don't get the cleanup lock because we won't have incurred a read,
> then why would we count any eagerly scanned page in shared buffers as
> a failure? In the case that we actually tried freezing the page and
> failed because it was too new, that is giving us information about
> whether or not we should keep trying to freeze. So, it is not just
> about doing the read but also about what the failure indicates about
> the data.
That's a good point, but failure to get a tuple lock isn't a judgement
either way on whether the XIDs in the page are old or new.
> Interestingly, we call heap_tuple_should_freeze() in
> lazy_scan_noprune(), so we actually could tell whether or not there
> are some tuples on the page old enough to trigger freezing if we had
> gotten the cleanup lock. One option would be to add a new output
> parameter to lazy_scan_noprune() that indicates whether or not there
> were tuples with xids older than the FreezeLimit, and only if there
> were not, count it as a failed eager scan.
Yeah, that could be done, and it doesn't sound like a bad idea.
However, I'm also unsure whether we need to add additional logic for
this case. My intuition is that it just won't happen very often. I'm
not quite confident that I'm correct about that, but if I had to
guess, my guess would be "rare scenario".
--
Robert Haas
EDB: http://www.enterprisedb.com