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

Commite3cb1a5

Browse files
committed
Report stats when replaying XLOG_RUNNING_XACTS
Previously stats in the startup process would only get reported duringshutdown of the startup process. It has been that way for a long time, butbecame a lot more noticeable with the new pg_stat_io view, which separates outIO done by different backend types...While replaying after every XLOG_RUNNING_XACTS isn't the prettiest approach,it has the advantage of being quite easy. Given that we're well past featurefreeze...It's not a problem that we don't report stats more frequently withwal_level=minimal, in that case stats can't be read before the stats processhas shut down.Besides the above, this commit also changes pgstat_report_stat() to acquirethe timestamp with GetCurrentTimestamp() instead ofGetCurrentTransactionStopTimestamp().Thanks to Melih Mutlu, Kyotaro Horiguchi for prototypes of other approaches tosolving this issue.Reported-by: Fujii Masao <masao.fujii@oss.nttdata.com>Discussion:https://postgr.es/m/5315aedc-fbca-1556-c5de-dc2e00b23a14@oss.nttdata.com
1 parent7398e27 commite3cb1a5

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

‎src/backend/storage/ipc/standby.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,15 @@ standby_redo(XLogReaderState *record)
11931193
running.xids=xlrec->xids;
11941194

11951195
ProcArrayApplyRecoveryInfo(&running);
1196+
1197+
/*
1198+
* The startup process currently has no convenient way to schedule
1199+
* stats to be reported. XLOG_RUNNING_XACTS records issued at a
1200+
* regular cadence, making this a convenient location to report
1201+
* stats. While these records aren't generated with wal_level=minimal,
1202+
* stats also cannot be accessed during WAL replay.
1203+
*/
1204+
pgstat_report_stat(true);
11961205
}
11971206
elseif (info==XLOG_INVALIDATIONS)
11981207
{

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,21 @@ pgstat_report_stat(bool force)
615615
*/
616616
Assert(!pgStatLocal.shmem->is_shutdown);
617617

618-
now=GetCurrentTransactionStopTimestamp();
619-
620-
if (!force)
618+
if (force)
621619
{
620+
/*
621+
* Stats reports are forced either when it's been too long since stats
622+
* have been reported or in processes that force stats reporting to
623+
* happen at specific points (including shutdown). In the former case
624+
* the transaction stop time might be quite old, in the latter it
625+
* would never get cleared.
626+
*/
627+
now=GetCurrentTimestamp();
628+
}
629+
else
630+
{
631+
now=GetCurrentTransactionStopTimestamp();
632+
622633
if (pending_since>0&&
623634
TimestampDifferenceExceeds(pending_since,now,PGSTAT_MAX_INTERVAL))
624635
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp