Add regression test checking combinations of (object,backend_type,context) in pg_stat_io

Started by Michael Paquierabout 1 year ago4 messageshackers
Jump to latest
#1Michael Paquier
michael@paquier.xyz

Hi all,

While working on I/O statistics, I have noticed that it is not
complicated to break the set of rows returned by pg_stat_io if one is
not careful when updating pgstat_tracks_io_object().

Attached is a patch that I've found useful as a sanity check,
returning all the combinations supported for BackendType, IOContext
and IOObject, so as it is easily possible to evaluate if the
information returned is relevant.

Thoughts?
--
Michael

Attachments:

statio-regress-check.patchtext/x-diff; charset=us-asciiDownload+82-0
#2Bertrand Drouvot
bertranddrouvot.pg@gmail.com
In reply to: Michael Paquier (#1)
Re: Add regression test checking combinations of (object,backend_type,context) in pg_stat_io

Hi,

On Wed, Mar 05, 2025 at 11:05:48AM +0900, Michael Paquier wrote:

Hi all,

While working on I/O statistics, I have noticed that it is not
complicated to break the set of rows returned by pg_stat_io if one is
not careful when updating pgstat_tracks_io_object().

Attached is a patch that I've found useful as a sanity check,
returning all the combinations supported for BackendType, IOContext
and IOObject, so as it is easily possible to evaluate if the
information returned is relevant.

Thoughts?

That would mean changing the test each time pgstat_tracks_io_object() is
modified in such a way that the output is changed. That's a good thing as
the writer will need to double check if the new output makes sense according
to his changes. So I don't see any reason not to add this test.

+SELECT backend_type, object, context FROM pg_stat_io ORDER BY 1, 2, 3;

What about adding some extra paranoia like?

SELECT backend_type, object, context FROM pg_stat_io ORDER BY backend_type, object, context COLLATE "C";

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

#3Michael Paquier
michael@paquier.xyz
In reply to: Bertrand Drouvot (#2)
Re: Add regression test checking combinations of (object,backend_type,context) in pg_stat_io

On Wed, Mar 05, 2025 at 07:34:16AM +0000, Bertrand Drouvot wrote:

That would mean changing the test each time pgstat_tracks_io_object() is
modified in such a way that the output is changed. That's a good thing as
the writer will need to double check if the new output makes sense according
to his changes. So I don't see any reason not to add this test.

Thanks for the review.

What about adding some extra paranoia like?

SELECT backend_type, object, context FROM pg_stat_io ORDER BY
backend_type, object, context COLLATE "C";

Why not, to force the ordering.
--
Michael

#4Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#3)
Re: Add regression test checking combinations of (object,backend_type,context) in pg_stat_io

On Wed, Mar 05, 2025 at 09:19:16PM +0900, Michael Paquier wrote:

On Wed, Mar 05, 2025 at 07:34:16AM +0000, Bertrand Drouvot wrote:

What about adding some extra paranoia like?

SELECT backend_type, object, context FROM pg_stat_io ORDER BY
backend_type, object, context COLLATE "C";

Why not, to force the ordering.

For the sake of the archives. As 8b532771a099 has proved, this has
required two more COLLATE clauses in the query to force a stable
output, but we are in the clear now.
--
Michael