Re: per backend WAL statistics
Michael Paquier <michael@paquier.xyz>
On Tue, Mar 04, 2025 at 08:48:28AM +0000, Bertrand Drouvot wrote: > s/report/Report/ and s/system/system./? to be consistent with the other single > line comments around. Right. > Yeah, I also think that's the right location. We could be more optimal for the WAL receiver if we add more timestamp calculations, I think, but that's a sensitive loop, and this is better than no information anyway. If somebody has a better idea, feel free. We could have an extra GUC to control that, but I'm feeling that we should restructure the WAL receiver before that, perhaps leverage some of its activity elsewhere (?). > + /* > + * Some BackendTypes only perform IO under IOOBJECT_WAL, hence exclude all > + * rows for all the other objects for these. > + */ > + if ((bktype == B_WAL_SUMMARIZER || bktype == B_WAL_RECEIVER || > + bktype == B_WAL_WRITER) && io_object != IOOBJECT_WAL) > + return false; > > I think that makes sense and it removes 15 lines out of 86. This function is > "hard" to read/parse from my point of view. Maybe we could re-write it in a > simpler way but that's outside the purpose of this thread. One thing I am planning to do here to improve the situation is the addition of a regression test that queries pg_stat_io for all the combinations of backend_type, object and contexts that are now allowed, to keep track of the number of tuples we have. > + WHERE backend_type = 'walsummarizer' AND object = 'wal'}); > > The object = 'wal' is not needed (thanks to === 3), maybe we can remove this > filtering? > > Also what about adding a test to check that sum(reads) is NULL where object != 'wal'? Not sure it matters as long as we track the supported combinations. We need something a bit more general here. (I've actually found a different issue while looking at the WAL receiver, which is a bit older than what we have here. Will post that in a different thread with you in CC.) -- Michael
Commits
-
Fix use-after-free in pgstat_fetch_stat_backend_by_pid()
- 3191a593d6de 18.0 landed
-
Remove initialization from PendingBackendStats
- f554a95379a9 18.0 landed
-
Add WAL data to backend statistics
- 76def4cdd7c2 18.0 landed
-
Improve check for detection of pending data in backend statistics
- 9a8dd2c5a6d9 18.0 landed
-
Fix some gaps in pg_stat_io with WAL receiver and WAL summarizer
- f4694e0f35b2 18.0 landed
-
Handle auxiliary processes in SQL functions of backend statistics
- 3f1db99bfabb 18.0 landed
-
Invent pgstat_fetch_stat_backend_by_pid()
- c2a50ac678eb 18.0 landed
-
Refactor code of pg_stat_get_wal() building result tuple
- 495864a4cf16 18.0 landed
-
Adding new PgStat_WalCounters structure in pgstat.h
- 0e42d31b0b22 18.0 landed
-
Remove pgstat_flush_wal()
- d7cbeaf261da 18.0 landed
-
Refactor some code related to backend statistics
- 2c14037bb57c 18.0 landed
-
Add backend-level statistics to pgstats
- 9aea73fc61d4 18.0 cited