Re: [PATCH] Fix vacuum_delay_point happening inside lock

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Kevin Rocker <me(at)kevinrocker(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Neil Chen <carpenter(dot)nail(dot)cz(at)gmail(dot)com>, pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Fix vacuum_delay_point happening inside lock
Date: 2026-08-23 16:28:47
Message-ID: B2DADB36-A1D1-4FA0-A467-2B67E9F37B88@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Kevin,

> Andrey, let me know if you have concerns about lock chaining/cleanup
> with this approach.

I don't see a problem with the move. It is before the cleanup lock on
the primary bucket is acquired, while the lock chaining within
hashbucketcleanup() is unchanged. A bucket with a long overflow chain
can accumulate more vacuum cost before delaying, but there is no safe
boundary inside that chain. The per-bucket placement seems like the
best available option.

There is now a production report of exactly this hash problem [0]. A
shutdown waited about six minutes for an autovacuum in
hashbucketcleanup(). Mostafa independently posted the same per-bucket
move and measured cancellation improving from about 2.08 seconds to
0.014 seconds. That confirms the placement and makes the hash fix a
backpatch candidate.

One detail in 0002: the two assertions do not check
QueryCancelHoldoffCount. Since vacuum_delay_point() is also expected to
service query cancellation, I think this should simply be:

Assert(INTERRUPTS_CAN_BE_PROCESSED());

This also expresses Tom's proposed invariant directly. Did you run
the full CI after this change? check-world on one system might be not
enough.

Best regards, Andrey Borodin.

[0] https://postgr.es/m/19628-c2b17d358181a1ea%40postgresql.org

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-08-23 16:55:32 Re: Allow a prosupport function to be attached to an aggregate
Previous Message Andrey Borodin 2026-08-23 16:02:52 Re: walsummarizer can get stuck when switching timelines