Fix handling of injection_points regarding pending stats

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Subject: Fix handling of injection_points regarding pending stats
Date: 2024-12-27 00:23:12
Message-ID: Z23zcE4w1djukkva@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

While doing more stuff related to pgstats and WAL, I have bumped on
the fact that the module injection_points uses for its
variable-numbered stats a pending flush callback but it does not
handle its entries so as these would be handled locally first, with a
final flush timed by pgstat_report_stat() that would itself call the
pending flush callback. This is a less efficient practice, because it
requires to touch the pgstats dshash more often than necessary.

This is caused by the use of pgstat_get_entry_ref_locked() rather than
pgstat_prep_pending_entry() which would make sure to time the flush of
any pending entries appropriately depending on pgstat_report_stat().
I'd like to fix the module so as the flush timing is controlled like
all the other stats kinds, which is a better and more efficient
practice to have anyway as this code should stand as a template for
custom pgstats kinds.

While doing so, I have also noticed that injection_stats_flush_cb()
missed a pgstat_unlock_entry() when entries get locked.

All that is addressed in the patch attached. Feel free if you have
any comments.

Thanks,
--
Michael

Attachment Content-Type Size
0001-injection_points-Tweak-variable-numbered-stats-to-wo.patch text/x-diff 2.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-12-27 00:32:11 Re: Using Expanded Objects other than Arrays from plpgsql
Previous Message Michael Paquier 2024-12-27 00:07:02 Re: attndims, typndims still not enforced, but make the value within a sane threshold