- Notifications
You must be signed in to change notification settings - Fork5k
Commite221c0b
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: 151 parentdbd44ea commite221c0b
1 file changed
+14
-2
lines changedLines changed: 14 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 |
| |
42 | 47 |
| |
43 | 48 |
| |
44 | 49 |
| |
45 |
| - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
46 | 57 |
| |
47 |
| - | |
| 58 | + | |
| 59 | + | |
48 | 60 |
| |
49 | 61 |
| |
50 | 62 |
| |
|
0 commit comments
Comments
(0)