Fix handling of injection_points regarding pending stats
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: 2024-12-27T00:23:12Z
Lists: pgsql-hackers
Attachments
- 0001-injection_points-Tweak-variable-numbered-stats-to-wo.patch (text/x-diff) patch 0001
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
Commits
-
injection_points: Tweak variable-numbered stats to work with pending data
- b757abefc041 18.0 landed