8000 Fix statistics breakage from bgwriter/checkpointer process split. · markokr/postgres@1e9326d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1e9326d

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 d843589 commit 1e9326d

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
@@ -1135,7 +1135,8 @@ ForwardFsyncRequest(RelFileNode rnode, ForkNumber forknum, BlockNumber segno)
11351135
LWLockAcquire(CheckpointerCommLock, LW_EXCLUSIVE);
11361136

11371137
/* Count all backend writes regardless of if they fit in the queue */
1138-
CheckpointerShmem->num_backend_writes++;
1138+
if (!AmBackgroundWriterProcess())
1139+
CheckpointerShmem->num_backend_writes++;
11391140

11401141
/*
11411142
* If the checkpointer isn't running or the request queue is full, the
@@ -1150,7 +1151,8 @@ ForwardFsyncRequest(RelFileNode rnode, ForkNumber forknum, BlockNumber segno)
11501151
* Count the subset of writes where backends have to do their own
11511152
* fsync
11521153
*/
1153-
CheckpointerShmem->num_backend_fsync++;
1154+
if (!AmBackgroundWriterProcess())
1155+
CheckpointerShmem->num_backend_fsync++;
11541156
LWLockRelease(CheckpointerCommLock);
11551157
return false;
11561158
}

0 commit comments

Comments
 (0)
0