Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wAXtC-0004oM-1q for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 18:44:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAXtA-001NJf-34 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 18:44:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wAXtA-001NJW-29 for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 18:44:33 +0000 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wAXt9-000000002Oi-2DlZ for pgsql-hackers@postgresql.org; Wed, 08 Apr 2026 18:44:32 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 557BCEC0047; Wed, 8 Apr 2026 14:44:31 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Wed, 08 Apr 2026 14:44:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1775673871; x=1775760271; bh=mqjHAHMYnO prOIifLaB2+EZeoniFdpg2M3JhwS1mWxs=; b=UcUvgMmRkioMBKcRbfdjaWz0Rj ACfpwgq0lPcVX6lQdfGtEtPoENwHkJSenaoudOALa5AbWOUUl6tRuUaFYWBiQPCl 4d8saOr4unzS4cH/MbcS3hhv9IGlhOtWNjIkqKrl2vljZx00IsCeYJP0XqfWMuxR 1d9urAeygcg4kj/H2L8B5iJy0178sn6B0BLgRjIwIO6VCxXG//X+c0VVPik3eTEz ifALBskGBY94pSV4nxbotV2L5/bglEBXcI+xEKXShxSbfJjeOIqqrqi8/QFubUK1 4m7gz/8Ob2MDnxLX1pf32j2xPT16mIn52B+P2zPapH9plIiHZG3PLbvPV9Iw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1775673871; x=1775760271; bh=mqjHAHMYnOprOIifLaB2+EZeoniFdpg2M3J hwS1mWxs=; b=QftdQzOwmsRM7GXXIww0bgumUJzYTVo/n5y6oXzqfNETj+R4mxA qnGpYAkSPN+VG2v1EebpRpj9+TNgGoFcJIC4KMm+pj50kwwEF+WFQJT3CDGKzuia bkfftTvmxtSm9Qm7+r3czjMQJhaFReqZE6CM8fSXiZbrAhXNbyhU4d59HeXdO+l7 GPDD1Jtoayqm02qbxYCFqZbeL8vD+2kGHA5QYlCdn5VuP2KOccjCcMPBxvdHOXRH m3ctUZTd4zZXwYL8KYk2D9ym2IneLGZ4N92pqUAuMeqPvSakLiti27eyeyD4N6ft GAtxNYTHjf7I+xXH5cizQj/n++ip435F26Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddvgeefvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtuggjsehttdfstddttddvnecuhfhrohhmpeetnhgurhgvshcu hfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrghtth gvrhhnpeeffffgledvffegtdevlefgtdeggffhvdekgfegteeiveejkeetudelveejhfeu geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnh gurhgvshesrghnrghrrgiivghlrdguvgdpnhgspghrtghpthhtohepledpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepsghhrghrrghthhdrrhhuphhirhgvugguhihfohhrph hoshhtghhrvghssehgmhgrihhlrdgtohhmpdhrtghpthhtohepvgigtghluhhsihhonhes ghhmrghilhdrtghomhdprhgtphhtthhopehnrghthhgrnhgusghoshhsrghrthesghhmrg hilhdrtghomhdprhgtphhtthhopehsrghmihhmshgvihhhsehgmhgrihhlrdgtohhmpdhr tghpthhtohepshgrthihrghnrghrlhgrphhurhgrmhesghhmrghilhdrtghomhdprhgtph htthhopehtnhgurhifrghnghesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhl qdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehtghhlse hsshhsrdhpghhhrdhprgdruhhspdhrtghpthhtoheprhhosgesgiiiihhllhgrrdhnvght X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Apr 2026 14:44:30 -0400 (EDT) Date: Wed, 8 Apr 2026 14:44:30 -0400 From: Andres Freund To: Nathan Bossart Cc: Sami Imseih , Tom Lane , Alexander Lakhin , Bharath Rupireddy , Robert Treat , satyanarlapuram@gmail.com, pgsql-hackers , tndrwang@gmail.com Subject: Re: Add pg_stat_autovacuum_priority Message-ID: References: <5684f479-858e-4c5d-b8f5-bcf05de1f909@gmail.com> <3077290.1775668665@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-04-08 13:37:31 -0500, Nathan Bossart wrote: > On Wed, Apr 08, 2026 at 01:28:06PM -0500, Sami Imseih wrote: > >> + if (AmAutoVacuumWorkerProcess()) > >> + pfree(tabentry); > >> } > > > > This works too, but v1-0001 is more generalized and we don't have to > > care about who the caller is when deciding to free or not. > > Well, I think if we were building this view from scratch without any > knowledge of autovacuum, we probably wouldnt bother manually freeing the > stats entries based on the value of the GUC. We'd probably just let the > commit/abort code take care of it, which AFAICT is what we do elsewhere. > Manually freeing the entries is also risky, which commit 02502c1bca touches > on: > > Note: pfree'ing the PgStat_StatTabEntry structs here seems a bit > risky, because pgstat_fetch_stat_tabentry_ext does not guarantee > anything about whether its result is long-lived. It appears okay > so long as autovacuum forces PGSTAT_FETCH_CONSISTENCY_NONE, but > I think that API could use a re-think. > > This seems very much to be an autovacuum-specific hack that we shouldn't be > propagating elsewhere. Agreed. There aren't that many callers of pgstat_fetch_entry (even if you count indirect ones), I think the best path might be to add a bool *may_free argument where necessary and just deal with the size of change that brings with it. Greetings, Andres Freund