Re: VM corruption on standby - Mailing list pgsql-hackers

From Andres Freund
Subject Re: VM corruption on standby
Date
Msg-id kbrpeatngns37xad6ym3a5qj3izbsspnbtyim6gsux6p3djxyf@n5hkeclcq3vl
Whole thread Raw
In response to Re: VM corruption on standby  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: VM corruption on standby
List pgsql-hackers
Hi,

On 2025-08-19 23:47:21 -0400, Tom Lane wrote:
> Thomas Munro <thomas.munro@gmail.com> writes:
> > On Wed, Aug 20, 2025 at 7:50 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> I'm inclined to think that we do want to prohibit WaitEventSetWait
> >> inside a critical section --- it just seems like a bad idea all
> >> around, even without considering this specific failure mode.
> 
> > FWIW aio/README.md describes a case where we'd need to wait for an IO,
> > which might involve a CV to wait for an IO worker to do something, in
> > order to start writing WAL, which is in a CS.
> 
> Hm.  It still makes me mighty uncomfortable, because the point of a
> critical section is "crash the database if anything goes wrong during
> this bit".  Waiting for another process --- or thread --- greatly
> increases the scope of ways for things to go wrong.  So I'm not
> exactly convinced that this aspect of the AIO architecture is
> well-thought-out.

I don't see the alternative:

1) Some IO is done in critical sections (e.g. WAL writes / flushes)

2) Sometimes we need to wait for already started IO in critical sections
   (also WAL)

3) With some ways of doing AIO the IO is offloaded to other processes, and
   thus waiting for the IO to complete always requires waiting for another
   process

How could we avoid the need to wait for another process in criticial sections
given these points?

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Nazir Bilal Yavuz
Date:
Subject: Re: meson: Add _static and _shared suffixes to the library names
Next
From: vignesh C
Date:
Subject: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence