Re: Make pg_prewarm, autoprewarm yield for waiting DDL

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Palak Chaturvedi <chaturvedipalak1911(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Robert Haas <robertmhaas(at)gmail(dot)com>, SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Make pg_prewarm, autoprewarm yield for waiting DDL
Date: 2026-09-14 20:39:00
Message-ID: CALj2ACVkmMT0Nxsn9YihjPW26-fb=98Oc5Js=MgmePLqRy84sg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Sep 7, 2026 at 8:01 AM Palak Chaturvedi
<chaturvedipalak1911(at)gmail(dot)com> wrote:
>
> I found two other issues while reviewing v3.

Thanks for reviewing it.

> First, 0001 assumes that finding a LOCK in LockMethodLockHash means
> that this backend's fast-path lock has already been transferred and
> therefore has a PROCLOCK. I don't think that is guaranteed.
>
> For example, backend A can hold a weak relation lock through the fast
> path, while backend B acquires the same weak lock through the main
> lock table because its fast-path slots are full. In that case, the
> LOCK exists because of backend B, but backend A still has no PROCLOCK.
> If A calls LockHasWaiters(), 0001 finds the LOCK and then raises:
>
> ERROR: failed to re-find shared proclock object

Ah, you are right. Thanks for catching that. I added a "failed to
re-find shared proclock object" error as a test case in the 0003
patch, in case it's useful. It seems like I didn't fully implement
what Robert suggested here:
https://postgr.es/m/CA%2BTgmob3mVc0LgKNtgy-MdDd9KLffzw1X%3D9qR8UaRmON0xJWNA%40mail.gmail.com.
Fixed in the attached v4, which returns false when our proclock isn't
there instead of erroring out.

> Second, the current CFBot run fails in the Linux 32-bit job. The
> 002_autoprewarm_lock_yield test sets:
>
> shared_buffers = '2GB'
>
> The server then fails during startup with:
>
> FATAL: invalid size -2147483648 for shared memory request for
> "Buffer Blocks"
>
> 0003 describes the test as manual/local, but it is registered in the
> Meson and Make test suites, so CFBot runs it. It either needs a
> portable configuration, an early skip on unsupported builds, or
> should remain unregistered if it is only intended for manual use.

I reduced shared_buffers and relation size to 512MB and about 260MB
respectively and ran the test locally, so I'm not so sure if the CFBot
will be fully happy with it, so I chose to use nocfbot- prefix.

Please find the attached v4 patches.

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v4-0001-Fix-LockHasWaiters-crash-for-fast-path-locks.patch application/x-patch 4.8 KB
v4-0002-Make-autoprewarm-yield-to-conflicting-lock-reques.patch application/x-patch 6.7 KB
nocfbot-v4-0003-Add-test-for-autoprewarm-yielding-to-conflicting-.patch application/x-patch 11.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-09-14 21:00:31 Re: Optimize UUID parse using SIMD
Previous Message Bharath Rupireddy 2026-09-14 20:28:00 Re: Report index currently being vacuumed in pg_stat_progress_vacuum