From 28de66cee5f45e2f173fa60dd6867c810ecabe38 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Tue, 21 Jan 2025 10:12:39 +0900 Subject: Rename some pgstats callbacks related to flush of entries The two callbacks have_fixed_pending_cb and flush_fixed_cb have been introduced in fc415edf8ca8 to provide a way for fixed-numbered statistics to control the flush of their data. These are renamed to respectively have_static_pending_cb and flush_static_cb. The restriction that these only apply to fixed-numbered stats is removed. A follow-up patch will make use of them for backend statistics. This stats kind is variable-numbered, and patches are under discussion to track WAL data for IO and backend stats which cannot use PgStat_EntryRef->pending as pending data would be touched in critical sections, where no memory allocation can happen. Per discussion with Andres Freund. Author: Bertrand Drouvot Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/66efowskppsns35v5u2m7k4sdnl7yoz5bo64tdjwq7r5lhplrz@y7dme5xwh2r5 --- src/include/utils/pgstat_internal.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/include/utils/pgstat_internal.h') diff --git a/src/include/utils/pgstat_internal.h b/src/include/utils/pgstat_internal.h index 4bb8e5c53ab..8914aaca9ab 100644 --- a/src/include/utils/pgstat_internal.h +++ b/src/include/utils/pgstat_internal.h @@ -156,8 +156,8 @@ typedef struct PgStat_EntryRef * Pending statistics data that will need to be flushed to shared memory * stats eventually. Each stats kind utilizing pending data defines what * format its pending data has and needs to provide a - * PgStat_KindInfo->flush_pending_cb callback to merge pending into shared - * stats. + * PgStat_KindInfo->flush_pending_cb callback to merge pending entries + * into the shared stats hash table. */ void *pending; dlist_node pending_node; /* membership in pgStatPending list */ @@ -260,7 +260,8 @@ typedef struct PgStat_KindInfo /* * For variable-numbered stats: flush pending stats. Required if pending - * data is used. See flush_fixed_cb for fixed-numbered stats. + * data is used. See flush_static_cb when dealing with stats data that + * that cannot use PgStat_EntryRef->pending. */ bool (*flush_pending_cb) (PgStat_EntryRef *sr, bool nowait); @@ -289,17 +290,23 @@ typedef struct PgStat_KindInfo void (*init_shmem_cb) (void *stats); /* - * For fixed-numbered statistics: Flush pending stats. Returns true if - * some of the stats could not be flushed, due to lock contention for - * example. Optional. + * For fixed-numbered or variable-numbered statistics: Flush pending stats + * entries, for stats kinds that do not use PgStat_EntryRef->pending. + * + * Returns true if some of the stats could not be flushed, due to lock + * contention for example. Optional. */ - bool (*flush_fixed_cb) (bool nowait); + bool (*flush_static_cb) (bool nowait); /* - * For fixed-numbered statistics: Check for pending stats in need of - * flush. Returns true if there are any stats pending for flush. Optional. + * For fixed-numbered or variable-numbered statistics: Check for pending + * stats in need of flush with flush_static_cb, when these do not use + * PgStat_EntryRef->pending. + * + * Returns true if there are any stats pending for flush, triggering + * flush_static_cb. Optional. */ - bool (*have_fixed_pending_cb) (void); + bool (*have_static_pending_cb) (void); /* * For fixed-numbered statistics: Reset All. -- cgit v1.2.3