Re: per backend WAL statistics - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: per backend WAL statistics
Date
Msg-id Z9Edh3gmiVIvJkv3@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to Re: per backend WAL statistics  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: per backend WAL statistics
List pgsql-hackers
Hi,

On Tue, Mar 11, 2025 at 11:14:24PM -0400, Tom Lane wrote:
> Michael Paquier <michael@paquier.xyz> writes:
> > And I guess that we're OK here, so applied.  That should be the last
> > one.
> 
> Quite a few buildfarm members are not happy about the initialization
> that 9a8dd2c5a added to PendingBackendStats.  For instance [1]:
> 
> gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels
-Wmissing-format-attribute-Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -O2 -I. -I.
-I../../../../src/include -D_GNU_SOURCE -I/usr/include/libxml2   -c -o pgstat_backend.o pgstat_backend.c
 
> pgstat_backend.c:39:1: warning: missing braces around initializer [-Wmissing-braces]
>  static PgStat_BackendPending PendingBackendStats = {0};
>  ^
> pgstat_backend.c:39:1: warning: (near initialization for \342\200\230PendingBackendStats.pending_io\342\200\231)
[-Wmissing-braces]
> 
> I guess that more than one level of braces is needed for this to
> be fully correct?

Thanks for the report! I think that it's better to remove the PendingBackendStats
initializer (instead of adding extra braces). The reason is that I'm concerned
about padding bytes (that could be added to the struct in the future) not being
zeroed (see [1]).

Done that way in the attached.

[1]: https://www.postgresql.org/message-id/Z8/W73%2BHVo%2B/pKHZ%40ip-10-97-1-34.eu-west-3.compute.internal

Regards,

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

Attachment

pgsql-hackers by date:

Previous
From: vignesh C
Date:
Subject: Re: pg_recvlogical requires -d but not described on the documentation
Next
From: Dilip Kumar
Date:
Subject: Re: Parallel heap vacuum