Re: USE_BARRIER_SMGRRELEASE on Linux? - Mailing list pgsql-hackers

From Andres Freund
Subject Re: USE_BARRIER_SMGRRELEASE on Linux?
Date
Msg-id 20220216192731.txn3vnlooa2bhdsm@alap3.anarazel.de
Whole thread Raw
In response to Re: USE_BARRIER_SMGRRELEASE on Linux?  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: USE_BARRIER_SMGRRELEASE on Linux?
List pgsql-hackers
Hi,

On 2022-02-16 09:37:21 -0800, Nathan Bossart wrote:
> I've also figured out a
> way to reproduce the issue without the pre-allocation patches applied:
> 
> 1. In checkpointer.c, add a 30 second sleep before acquiring ckpt_lck to
>    increment ckpt_started.
> 2. In session 1, run the following commands:
>     a. CREATE TABLESPACE test LOCATION '/path/to/dir';
>     b. CREATE TABLE test TABLESPACE test AS SELECT 1;
> 3. In session 2, start a checkpoint.
> 4. In session 1, run these commands:
>     a. ALTER TABLE test SET TABLESPACE pg_default;
>     b. DROP TABLESPACE test;  -- fails
>     c. DROP TABLESPACE test;  -- succeeds

Did you check whether this is a problem recently introduced or long-lived?

Does USE_BARRIER_SMGRRELEASE actually prevent this problem? Or was it just
that it influences the timing in a way that makes it less likely?


ISTM that the problem is partially caused by having multiple "checkpoint"
counters that are used in different ways, but then only waiting for one of
them. I wonder whether a better approach could be to either unify the
different counters, or to request / wait for the sync counter specifically?

Historically the sync stuff was something in md.c that the global system
didn't really know anything about, but now it's a "proper" subsystem, so we
can change the separation of concerns a bit more.


> Here's a patch that adds a call to AbsorbSyncRequests() in
> CheckpointerMain() instead of SyncPreCheckpoint().

That doesn't strike me as great architecturally. E.g. in theory the same
problem could exist in single user mode. I think it doesn't today, because
RegisterSyncRequest() will effectively "absorb" it immediately, but that kind
of feels like an implementation detail?


Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: do only critical work during single-user vacuum?
Next
From: Jacob Champion
Date:
Subject: Re: Observability in Postgres