Re: Eagerly scan all-visible pages to amortize aggressive vacuum

From: Robert Treat <rob(at)xzilla(dot)net>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>, Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru>, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Geoghegan <pg(at)bowt(dot)ie>
Subject: Re: Eagerly scan all-visible pages to amortize aggressive vacuum
Date: 2025-02-04 19:57:40
Message-ID: CAJSLCQ3h2Y6eKWzZ=y6-84i-yVDc17XnRENU=BkfnvYQ_gNoLg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 4, 2025 at 12:44 PM Melanie Plageman
<melanieplageman(at)gmail(dot)com> wrote:
> On Mon, Feb 3, 2025 at 9:09 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
> >
> > On 2025-01-29 14:12:52 -0500, Melanie Plageman wrote:
> > > From 71f32189aad510b73d221fb0478ffd916e5e5dde Mon Sep 17 00:00:00 2001
> > > From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
>
> > > @@ -1064,7 +1327,45 @@ lazy_scan_heap(LVRelState *vacrel)
> > > if (got_cleanup_lock)
> > > lazy_scan_prune(vacrel, buf, blkno, page,
> > > vmbuffer, all_visible_according_to_vm,
> > > - &has_lpdead_items);
> > > + &has_lpdead_items, &vm_page_frozen);
> > > +
> > > + /*
> > > + * Count an eagerly scanned page as a failure or a success.
> > > + */
> > > + if (was_eager_scanned)
> >
> > Hm - how should pages be counted that we couldn't get a lock on? I think
> > right now they'll be counted as a failure, but that doesn't seem quite right.
>
> Yea, I thought that counting them as failures made sense because we
> did fail to freeze them. However, now that you mention it, we didn't
> fail to freeze them because of age, so maybe we don't want to count
> them as failures. I don't expect us to have a bunch of contended
> all-visible pages, so I think the question is about what makes it more
> clear in the code. What do you think? Should I reset was_eager_scanned
> to false if we don't get the cleanup lock?
>

I feel like if we are making the trade-off in resources to attempt
eager scanning, and we weren't making progress for whatever reason
(and in the lock failure cases, wouldn't some of those be things that
would prevent us from freezing?) then it would generally be ok to bias
towards bailing sooner rather than later.

Robert Treat
https://xzilla.net

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2025-02-04 20:06:53 Re: should we have a fast-path planning for OLTP starjoins?
Previous Message Tom Lane 2025-02-04 19:56:22 Re: Better title output for psql \dt \di etc. commands