Re: Fix two race conditions in processing interrupts

From: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix two race conditions in processing interrupts
Date: 2026-11-17 05:39:24
Message-ID: CAJTYsWV-m+GU7JzmVRcXwP3onV67isSf9Xdk+M-x+Q7=1v-EYg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, 17 Nov 2026 at 06:32, shihao zhong <zhong950419(at)gmail(dot)com> wrote:
>
> Thanks for your patches.
>
> 0001 looks good to me.

+1

> For 0002
>
> > if (s->blockState == TBLOCK_DEFAULT && s->state == TRANS_DEFAULT)
> I think that changed the recovery conflict logic because of the following code in
> postgres.c
>
> > case RECOVERY_CONFLICT_LOCK:
> > case RECOVERY_CONFLICT_TABLESPACE:
> > case RECOVERY_CONFLICT_SNAPSHOT:
> > /*
> > * If we aren't in a transaction any longer then ignore.
> > */
> > if (!IsTransactionOrTransactionBlock())
> > return;
> >
> > report_recovery_conflict(reason);
> > return;
>
> And it will eventually become a FATAL which changes the current behavior. Given
> the window is quite small, maybe it is worth mentioning in the commit message/comment?

I could repro this.

Pausing an idle backend at sinval-caught-up and triggering a tablespace
conflict kills the session:

FATAL: terminating connection due to conflict with recovery
DETAIL: User was or might have been using tablespace that must be dropped.

Without 0002 it's ignored. Not sure just documenting this is enough,
since the session was idle and never used that tablespace. Maybe we
could leave IsTransactionOrTransactionBlock() as-is and handle this
only for the idle stats check? Though I get the occurence of this should
not be much.

Regards,
Ayush

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Chao Li 2026-11-17 05:37:38 Re: extension_control_path: ignore empty elements and deduplicate directories