Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit28de66c

Browse files
committed
Rename some pgstats callbacks related to flush of entries
The two callbacks have_fixed_pending_cb and flush_fixed_cb have beenintroduced infc415ed to provide a way for fixed-numberedstatistics to control the flush of their data. These are renamed torespectively have_static_pending_cb and flush_static_cb. Therestriction that these only apply to fixed-numbered stats is removed.A follow-up patch will make use of them for backend statistics. Thisstats kind is variable-numbered, and patches are under discussion totrack WAL data for IO and backend stats which cannot usePgStat_EntryRef->pending as pending data would be touched in criticalsections, where no memory allocation can happen.Per discussion with Andres Freund.Author: Bertrand DrouvotReviewed-by: Michael PaquierDiscussion:https://postgr.es/m/66efowskppsns35v5u2m7k4sdnl7yoz5bo64tdjwq7r5lhplrz@y7dme5xwh2r5
1 parent60c513f commit28de66c

File tree

2 files changed

+30
-33
lines changed

2 files changed

+30
-33
lines changed

‎src/backend/utils/activity/pgstat.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ static const PgStat_KindInfo pgstat_kind_builtin_infos[PGSTAT_KIND_BUILTIN_SIZE]
437437
.shared_data_off= offsetof(PgStatShared_IO,stats),
438438
.shared_data_len=sizeof(((PgStatShared_IO*)0)->stats),
439439

440-
.flush_fixed_cb=pgstat_io_flush_cb,
441-
.have_fixed_pending_cb=pgstat_io_have_pending_cb,
440+
.flush_static_cb=pgstat_io_flush_cb,
441+
.have_static_pending_cb=pgstat_io_have_pending_cb,
442442
.init_shmem_cb=pgstat_io_init_shmem_cb,
443443
.reset_all_cb=pgstat_io_reset_all_cb,
444444
.snapshot_cb=pgstat_io_snapshot_cb,
@@ -455,8 +455,8 @@ static const PgStat_KindInfo pgstat_kind_builtin_infos[PGSTAT_KIND_BUILTIN_SIZE]
455455
.shared_data_off= offsetof(PgStatShared_SLRU,stats),
456456
.shared_data_len=sizeof(((PgStatShared_SLRU*)0)->stats),
457457

458-
.flush_fixed_cb=pgstat_slru_flush_cb,
459-
.have_fixed_pending_cb=pgstat_slru_have_pending_cb,
458+
.flush_static_cb=pgstat_slru_flush_cb,
459+
.have_static_pending_cb=pgstat_slru_have_pending_cb,
460460
.init_shmem_cb=pgstat_slru_init_shmem_cb,
461461
.reset_all_cb=pgstat_slru_reset_all_cb,
462462
.snapshot_cb=pgstat_slru_snapshot_cb,
@@ -474,8 +474,8 @@ static const PgStat_KindInfo pgstat_kind_builtin_infos[PGSTAT_KIND_BUILTIN_SIZE]
474474
.shared_data_len=sizeof(((PgStatShared_Wal*)0)->stats),
475475

476476
.init_backend_cb=pgstat_wal_init_backend_cb,
477-
.flush_fixed_cb=pgstat_wal_flush_cb,
478-
.have_fixed_pending_cb=pgstat_wal_have_pending_cb,
477+
.flush_static_cb=pgstat_wal_flush_cb,
478+
.have_static_pending_cb=pgstat_wal_have_pending_cb,
479479
.init_shmem_cb=pgstat_wal_init_shmem_cb,
480480
.reset_all_cb=pgstat_wal_reset_all_cb,
481481
.snapshot_cb=pgstat_wal_snapshot_cb,
@@ -713,22 +713,17 @@ pgstat_report_stat(bool force)
713713
{
714714
booldo_flush= false;
715715

716-
/* Check for pendingfixed-numberedstats */
716+
/* Check for pending stats */
717717
for (PgStat_Kindkind=PGSTAT_KIND_MIN;kind <=PGSTAT_KIND_MAX;kind++)
718718
{
719719
constPgStat_KindInfo*kind_info=pgstat_get_kind_info(kind);
720720

721721
if (!kind_info)
722722
continue;
723-
if (!kind_info->fixed_amount)
724-
{
725-
Assert(kind_info->have_fixed_pending_cb==NULL);
726-
continue;
727-
}
728-
if (!kind_info->have_fixed_pending_cb)
723+
if (!kind_info->have_static_pending_cb)
729724
continue;
730725

731-
if (kind_info->have_fixed_pending_cb())
726+
if (kind_info->have_static_pending_cb())
732727
{
733728
do_flush= true;
734729
break;
@@ -789,25 +784,20 @@ pgstat_report_stat(bool force)
789784

790785
partial_flush= false;
791786

792-
/* flush of variable-numbered stats */
787+
/* flush of variable-numbered statstracked in pending entries list*/
793788
partial_flush |=pgstat_flush_pending_entries(nowait);
794789

795-
/* flush offixed-numbered stats */
790+
/* flush ofother stats kinds */
796791
for (PgStat_Kindkind=PGSTAT_KIND_MIN;kind <=PGSTAT_KIND_MAX;kind++)
797792
{
798793
constPgStat_KindInfo*kind_info=pgstat_get_kind_info(kind);
799794

800795
if (!kind_info)
801796
continue;
802-
if (!kind_info->fixed_amount)
803-
{
804-
Assert(kind_info->flush_fixed_cb==NULL);
805-
continue;
806-
}
807-
if (!kind_info->flush_fixed_cb)
797+
if (!kind_info->flush_static_cb)
808798
continue;
809799

810-
partial_flush |=kind_info->flush_fixed_cb(nowait);
800+
partial_flush |=kind_info->flush_static_cb(nowait);
811801
}
812802

813803
last_flush=now;

‎src/include/utils/pgstat_internal.h

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ typedef struct PgStat_EntryRef
156156
* Pending statistics data that will need to be flushed to shared memory
157157
* stats eventually. Each stats kind utilizing pending data defines what
158158
* format its pending data has and needs to provide a
159-
* PgStat_KindInfo->flush_pending_cb callback to merge pendinginto shared
160-
* stats.
159+
* PgStat_KindInfo->flush_pending_cb callback to merge pendingentries
160+
*into the sharedstats hash table.
161161
*/
162162
void*pending;
163163
dlist_nodepending_node;/* membership in pgStatPending list */
@@ -260,7 +260,8 @@ typedef struct PgStat_KindInfo
260260

261261
/*
262262
* For variable-numbered stats: flush pending stats. Required if pending
263-
* data is used. See flush_fixed_cb for fixed-numbered stats.
263+
* data is used. See flush_static_cb when dealing with stats data that
264+
* that cannot use PgStat_EntryRef->pending.
264265
*/
265266
bool(*flush_pending_cb) (PgStat_EntryRef*sr,boolnowait);
266267

@@ -289,17 +290,23 @@ typedef struct PgStat_KindInfo
289290
void(*init_shmem_cb) (void*stats);
290291

291292
/*
292-
* For fixed-numbered statistics: Flush pending stats. Returns true if
293-
* some of the stats could not be flushed, due to lock contention for
294-
* example. Optional.
293+
* For fixed-numbered or variable-numbered statistics: Flush pending stats
294+
* entries, for stats kinds that do not use PgStat_EntryRef->pending.
295+
*
296+
* Returns true if some of the stats could not be flushed, due to lock
297+
* contention for example. Optional.
295298
*/
296-
bool(*flush_fixed_cb) (boolnowait);
299+
bool(*flush_static_cb) (boolnowait);
297300

298301
/*
299-
* For fixed-numbered statistics: Check for pending stats in need of
300-
* flush. Returns true if there are any stats pending for flush. Optional.
302+
* For fixed-numbered or variable-numbered statistics: Check for pending
303+
* stats in need of flush with flush_static_cb, when these do not use
304+
* PgStat_EntryRef->pending.
305+
*
306+
* Returns true if there are any stats pending for flush, triggering
307+
* flush_static_cb. Optional.
301308
*/
302-
bool(*have_fixed_pending_cb) (void);
309+
bool(*have_static_pending_cb) (void);
303310

304311
/*
305312
* For fixed-numbered statistics: Reset All.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp