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

Commit78f9506

Browse files
committed
pgstat: split out WAL handling from pgstat_{initialize,report_stat}.
A later commit will move the handling of the different kinds of stats intoseparate files. By splitting out WAL handling in this commit that later movewill just move code around without other changes.Author: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/20220303021600.hs34ghqcw6zcokdh@alap3.anarazel.de
1 parent89c546c commit78f9506

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

‎src/backend/postmaster/pgstat.c

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ static void pgstat_send_tabstats(TimestampTz now, bool disconnect);
348348
staticvoidpgstat_send_tabstat(PgStat_MsgTabstat*tsmsg,TimestampTznow);
349349
staticvoidpgstat_update_dbstats(PgStat_MsgTabstat*tsmsg,TimestampTznow);
350350
staticvoidpgstat_send_funcstats(void);
351+
staticvoidpgstat_wal_initialize(void);
352+
staticboolpgstat_wal_pending(void);
351353
staticvoidpgstat_send_slru(void);
352354
staticHTAB*pgstat_collect_oids(Oidcatalogid,AttrNumberanum_oid);
353355
staticboolpgstat_should_report_connstat(void);
@@ -882,17 +884,10 @@ pgstat_report_stat(bool disconnect)
882884

883885
/*
884886
* Don't expend a clock check if nothing to do.
885-
*
886-
* To determine whether any WAL activity has occurred since last time, not
887-
* only the number of generated WAL records but also the numbers of WAL
888-
* writes and syncs need to be checked. Because even transaction that
889-
* generates no WAL records can write or sync WAL data when flushing the
890-
* data pages.
891887
*/
892888
if (!have_relation_stats&&
893889
pgStatXactCommit==0&&pgStatXactRollback==0&&
894-
pgWalUsage.wal_records==prevWalUsage.wal_records&&
895-
WalStats.m_wal_write==0&&WalStats.m_wal_sync==0&&
890+
!pgstat_wal_pending()&&
896891
!have_function_stats&& !disconnect)
897892
return;
898893

@@ -3168,12 +3163,7 @@ pgstat_initialize(void)
31683163
{
31693164
Assert(!pgstat_is_initialized);
31703165

3171-
/*
3172-
* Initialize prevWalUsage with pgWalUsage so that pgstat_send_wal() can
3173-
* calculate how much pgWalUsage counters are increased by subtracting
3174-
* prevWalUsage from pgWalUsage.
3175-
*/
3176-
prevWalUsage=pgWalUsage;
3166+
pgstat_wal_initialize();
31773167

31783168
/* Set up a process-exit hook to clean up */
31793169
before_shmem_exit(pgstat_shutdown_hook,0);
@@ -3415,6 +3405,32 @@ pgstat_send_wal(bool force)
34153405
MemSet(&WalStats,0,sizeof(WalStats));
34163406
}
34173407

3408+
staticvoid
3409+
pgstat_wal_initialize(void)
3410+
{
3411+
/*
3412+
* Initialize prevWalUsage with pgWalUsage so that pgstat_send_wal() can
3413+
* calculate how much pgWalUsage counters are increased by subtracting
3414+
* prevWalUsage from pgWalUsage.
3415+
*/
3416+
prevWalUsage=pgWalUsage;
3417+
}
3418+
3419+
/*
3420+
* To determine whether any WAL activity has occurred since last time, not
3421+
* only the number of generated WAL records but also the numbers of WAL
3422+
* writes and syncs need to be checked. Because even transaction that
3423+
* generates no WAL records can write or sync WAL data when flushing the
3424+
* data pages.
3425+
*/
3426+
staticbool
3427+
pgstat_wal_pending(void)
3428+
{
3429+
returnpgWalUsage.wal_records!=prevWalUsage.wal_records||
3430+
WalStats.m_wal_write!=0||
3431+
WalStats.m_wal_sync!=0;
3432+
}
3433+
34183434
/* ----------
34193435
* pgstat_send_slru() -
34203436
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp