From: | Ramanathan <sivakrishnathan(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Proposal - Reduce lock during first phase of VACUUM TRUNCATE from ACCESS EXCLUSIVE to EXCLUSIVE |
Date: | 2025-02-25 15:56:13 |
Message-ID: | CAH4GEV8w7sjAhAP4q6-33uBckADrqqmg3bfimJCLnF5d6nUv8g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> Except that mid-transaction lock upgrades increase the risk of
deadlock failures.
Thanks for the feedback. However, wouldn’t that risk already exist in the
current vacuum truncate process? As it stands, VACUUM TRUNCATE performs a
lock upgrade—from ShareUpdateExclusiveLock to AccessExclusiveLock—during
the actual truncate phase. This upgrade, while brief, also carries an
inherent risk of deadlocks.
The proposed change simply shifts part of the locking burden to the
backward scan phase by using an EXCLUSIVE lock instead of ACCESS EXCLUSIVE.
The idea is to reduce the lock's restrictiveness during the scan phase and
only escalate to ACCESS EXCLUSIVE for the fast truncation. Since we’re
already handling a similar upgrade in the current workflow, the risk
profile should be comparable.Which can mitigate the extended outages on hot
standby replicas as the primary does not release the lock based on waiting
queries on the hot standby.
Looking forward to your thoughts.
Best regards,
Ram
ᐧ
On Mon, 17 Feb 2025 at 20:50, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Ramanathan <sivakrishnathan(at)gmail(dot)com> writes:
> > I propose modifying the use of an EXCLUSIVE lock during the backward scan
> > phase, then upgrading that lock to ACCESS EXCLUSIVE only for the actual
> > truncation phase. Since the truncation phase should be relatively quick,
> > the impact of the ACCESS EXCLUSIVE lock should be minimal.
>
> Except that mid-transaction lock upgrades increase the risk of
> deadlock failures.
>
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | Melanie Plageman | 2025-02-25 16:02:40 | Re: Trigger more frequent autovacuums of heavy insert tables |
Previous Message | Tomas Vondra | 2025-02-25 15:49:03 | Re: Parallel CREATE INDEX for GIN indexes |