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

Commite221c0b

Browse files
committed
Fix behavior of "force" in pgstat_report_wal()
As implemented in5891c7a, setting "force" to true inpgstat_report_wal() causes the routine to not wait for the pgstatshmem lock if it cannot be acquired, in which case the WAL and I/Ostatistics finish by not being flushed. The origin of the confusioncomes from pgstat_flush_wal() and pgstat_flush_io(), that use "nowait"as sole argument. The I/O stats are new in v16.This is the opposite behavior of what has been used inpgstat_report_stat(), where "force" is the opposite of "nowait". Inthis case, when "force" is true, the routine sets "nowait" to false,which would cause the routine to wait for the pgstat shmem lock,ensuring that the stats are always flushed. When "force" is false,"nowait" is set to true, and the stats would only not be flushed if thepgstat shmem lock can be acquired, returning immediately withoutflushing the stats if the lock cannot be acquired.This commit changes pgstat_report_wal() so as "force" has the samebehavior as in pgstat_report_stat(). There are currently three callersof pgstat_report_wal():- Two in the checkpointer where force=true during a shutdown and themain checkpointer loop. Now the code behaves so as the stats are alwaysflushed.- One in the main loop of the bgwriter, where force=false. Now the codebehaves so as the stats would not be flushed if the pgstat shmem lockcould not be acquired.Before this commit, some stats on WAL and I/O could have been lost aftera shutdown, for example.Reported-by: Ryoga YoshidaAuthor: Ryoga Yoshida, Michael PaquierDiscussion:https://postgr.es/m/f87a4d7be70530606b864fd1df91718c@oss.nttdata.comBackpatch-through: 15
1 parentdbd44ea commite221c0b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,25 @@ static WalUsage prevWalUsage;
3838
*
3939
* Must be called by processes that generate WAL, that do not call
4040
* pgstat_report_stat(), like walwriter.
41+
*
42+
* "force" set to true ensures that the statistics are flushed; note that
43+
* this needs to acquire the pgstat shmem LWLock, waiting on it. When
44+
* set to false, the statistics may not be flushed if the lock could not
45+
* be acquired.
4146
*/
4247
void
4348
pgstat_report_wal(boolforce)
4449
{
45-
pgstat_flush_wal(force);
50+
boolnowait;
51+
52+
/* like in pgstat.c, don't wait for lock acquisition when !force */
53+
nowait= !force;
54+
55+
/* flush wal stats */
56+
pgstat_flush_wal(nowait);
4657

47-
pgstat_flush_io(force);
58+
/* flush IO stats */
59+
pgstat_flush_io(nowait);
4860
}
4961

5062
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp