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

Commit9a8dd2c

Browse files
committed
Improve check for detection of pending data in backend statistics
The callback pgstat_backend_have_pending_cb() is used as a way forpg_stat_report() to detect if there is any pending data for backendstatistics.It did not include a check based on pgstat_tracks_backend_bktype(), thatdiscards processes whose backend types do not support backendstatistics. The logic is not a problem on HEAD, as processes that donot support backend statistics cannot touch PendingBackendStats, so thecallback would always report that there is no pending data in this case.However, we would run into trouble once backend statistics includeportions of pending stats that are not always zeroed, like pgWalUsage.There is no reason for pgstat_backend_have_pending_cb() to not checkfor pgstat_tracks_backend_bktype(), anyway, and this pattern is safer inthe long run, so let's update the code to do so.While on it, this commit adds a proper initialization toPendingBackendStats.Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>Co-authored-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/Z8l6EMM4ImVoWRkg@ip-10-97-1-34.eu-west-3.compute.internal
1 parent8e167e6 commit9a8dd2c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* reported within critical sections so we use static memory in order to avoid
3737
* memory allocation.
3838
*/
39-
staticPgStat_BackendPendingPendingBackendStats;
39+
staticPgStat_BackendPendingPendingBackendStats= {0};
4040

4141
/*
4242
* Utility routines to report I/O stats for backends, kept here to avoid
@@ -222,6 +222,9 @@ pgstat_flush_backend(bool nowait, bits32 flags)
222222
bool
223223
pgstat_backend_have_pending_cb(void)
224224
{
225+
if (!pgstat_tracks_backend_bktype(MyBackendType))
226+
return false;
227+
225228
return (!pg_memory_is_all_zeros(&PendingBackendStats,
226229
sizeof(structPgStat_BackendPending)));
227230
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp