On Wed, Nov 08, 2023 at 10:08:42AM +0900, Kyotaro Horiguchi wrote: > At Mon, 6 Nov 2023 14:00:13 +0530, Bharath Rupireddy > <bharath.rupireddyforpostg...@gmail.com> wrote in > I must say, I have reservations about this approach. The main concern > is the duplication of reset code, which has been efficiently > encapsulated for individual targets, into this location. This practice > degrades the maintainability and clarity of the code.
+{ oid => '8000', This OID pick had me smile. >> IMV, atomicity is not something that applies for the stats reset >> operation because stats are approximate numbers by nature after all. >> If the pg_stat_reset_shared() resets stats for only a bunch of stats >> types and fails, it's the basic application programming style that >> when a query fails it's the application that needs to have a retry >> mechanism. FWIW, the atomicity doesn't apply today if someone wants to >> reset stats in a loop for all stats types. > > The infrequent use of this feature, coupled with the fact that there > is no inherent need for these counters to be reset simultaneoulsy, > leads me to think that there is little point in centralizing the > locks. Each stat listed with fixed_amount has meaning taken in isolation, so I don't see why this patch has to be that complicated. I'd expect one code path that just calls a series of pgstat_reset_of_kind(). There could be an argument for a new routine in pgstat.c that loops over the pgstat_kind_infos and triggers the callbacks where .fixed_amount is set, but that's less transparent than the other approach. The reset time should be consistent across all the calls as we rely on GetCurrentTimestamp(). -- Michael
signature.asc
Description: PGP signature