public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michael Paquier <[email protected]>
To: Alvaro Herrera <[email protected]>
Cc: Andrey M. Borodin <[email protected]>
Cc: vignesh C <[email protected]>
Cc: Andrew Borodin <[email protected]>
Cc: [email protected]
Cc: Yura Sokolov <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: Thomas Munro <[email protected]>
Cc: Gilles Darold <[email protected]>
Cc: Alexander Korotkov <[email protected]>
Cc: Anastasia Lubennikova <[email protected]>
Cc: Daniel Gustafsson <[email protected]>
Cc: Kyotaro Horiguchi <[email protected]>
Cc: pgsql-hackers mailing list <[email protected]>
Subject: Re: MultiXact\SLRU buffers configuration
Date: Thu, 22 Aug 2024 09:29:30 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>

On Wed, Aug 21, 2024 at 01:55:06PM -0400, Alvaro Herrera wrote:
> I find it's strange that the information that stats cannot be used with
> injection points that have dependency on critical sections (?), is only
> in the commit message and not in the code.

A comment close to where inj_stats_enabled is declared in
injection_points.c may be adapted for that, say:
"This GUC is useful to control if statistics should be enabled or not
during a test with injection points, like for example if a test relies
on a callback run in a critical section where no allocation should
happen."

> Also, maybe it'd make sense for stats to be globally enabled, and that
> only the tests that require it would disable them?  (It's probably easy
> enough to have a value "injection_points.stats=auto" which means, if the
> module is loaded in shared_preload_libraries them set stats on,
> otherwise turn them off.)

I'm not sure that we need to get down to that until somebody has a
case where they want to rely on stats of injection points for their
stuff.  At this stage, I only want the stats to be enabled to provide
automated checks for the custom pgstats APIs, so disabling it by
default and enabling it only in the stats test of the module
injection_points sounds kind of enough to me for now.  The module
could always be tweaked to do that in the future, if there's a case.

> TBH I don't understand why the issue that
> stats require shared_preload_libraries only comes up now ...

Because there was no need to, simply.  It is the first test that
relies on a critical section, and we need allocations if we want to
use a wait condition. 

> Maybe another approach is to say that if an injection point is loaded via
> _LOAD() rather than the normal way, then stats are disabled for that one
> rather than globally?

One trick would be to force the GUC to be false for the duration of
the callback based on a check of CritSectionCount, a second one would
be to just skip the stats if are under CritSectionCount.  A third
option, that I find actually interesting, would be to call
MemoryContextAllowInCriticalSection in some strategic code paths of
the test module injection_points because we're OK to live with this
restriction in the module.

> Or give the _LOAD() macro a boolean argument to
> indicate whether to collect stats for that injection point or not.

Sticking some knowledge about the stats in the backend part of
injection points does not sound like a good idea to me.

> Lastly, it's not clear to me what does it mean that the test has a
> "dependency" on a critical section.  Do you mean to say that the
> injection point runs inside a critical section?

Yes.

> No issues with this, feel free to go ahead.

Cool, thanks.
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, ../[email protected]/2-signature.asc)
  download

view thread (3+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: MultiXact\SLRU buffers configuration
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox