Skip to content

Commit 80e373c

Browse files
committed
Fix statistics breakage from bgwriter/checkpointer process split.
ForwardFsyncRequest() supposed that it could only be called in regular backends, which used to be true; but since the splitup of bgwriter and checkpointer, it is also called in the bgwriter. We do not want to count such calls in pg_stat_bgwriter.buffers_backend statistics, so fix things so that they aren't. (It's worth noting here that this implies an alarmingly large increase in the expected amount of cross-process fsync request traffic, which may well mean that the process splitup was not such a hot idea.)
1 parent 4a9c30a commit 80e373c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/backend/postmaster/checkpointer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,8 @@ ForwardFsyncRequest(RelFileNode rnode, ForkNumber forknum, BlockNumber segno)
11321132
LWLockAcquire(CheckpointerCommLock, LW_EXCLUSIVE);
11331133

11341134
/* Count all backend writes regardless of if they fit in the queue */
1135-
CheckpointerShmem->num_backend_writes++;
1135+
if (!AmBackgroundWriterProcess())
1136+
CheckpointerShmem->num_backend_writes++;
11361137

11371138
/*
11381139
* If the checkpointer isn't running or the request queue is full, the
@@ -1147,7 +1148,8 @@ ForwardFsyncRequest(RelFileNode rnode, ForkNumber forknum, BlockNumber segno)
11471148
* Count the subset of writes where backends have to do their own
11481149
* fsync
11491150
*/
1150-
CheckpointerShmem->num_backend_fsync++;
1151+
if (!AmBackgroundWriterProcess())
1152+
CheckpointerShmem->num_backend_fsync++;
11511153
LWLockRelease(CheckpointerCommLock);
11521154
return false;
11531155
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy