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 1vNglX-00AvEl-0v for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Nov 2025 00:18:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vNglV-005beB-2u for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Nov 2025 00:18:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vNglV-005be3-1l for pgsql-hackers@lists.postgresql.org; Tue, 25 Nov 2025 00:18:41 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vNglU-001K5X-04 for pgsql-hackers@lists.postgresql.org; Tue, 25 Nov 2025 00:18:41 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-b73545723ebso921976666b.1 for ; Mon, 24 Nov 2025 16:18:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764029919; x=1764634719; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6hrerV69KPWp6wPH/9hZ1QBHjQfhefkE+9vkTiJ2PMo=; b=jVlf4Ffoiy4dQEsSzN1qq4+FHdO8gdVhvt6AvwjTnUk4/kYhPUbPSzSO8C3VJQcOpF phpruD77q3u+HqV+7QywSK3op6SDMw5h08Lz665DGtAGn01YM6XzzZ06Mwr1SK1frUeW u6os0eU5e9yjav+cgCg5W6ZQfRJS7vwnrYhG5drU7BCwpCdBZSXsV0vsIXQTXuuko/lU WkY37+cwsjrSxJZLfTTLsqLvjqllnKWBdN0yt3JH+6TJg3lqLhFR5+VzirEhEMnVFjDp eR8zm6zpKgukLjZRTPKP9aWl8JvhRG6DSmocWO7Eobrr81Hk9Pl3GaGpe4kW9KMPDoGM JTxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764029919; x=1764634719; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6hrerV69KPWp6wPH/9hZ1QBHjQfhefkE+9vkTiJ2PMo=; b=kdCkKsrOhnGn/BPZo+JLcrMYyIJb0ekM1v87BkujhachvlZ7IN0ozwydjuU0Hviine 9oBW3GY8asi88ac7H/NR7wRPqhTGBzWl1GWGhBHtFy5G+PTuWO7HK+VVmy810VzzaxyO 3ze54Bh9kVIzATUbDC4c6AzCf4RUwQg0I/C3i/N3cwAJIdhnLG3sODGilkqCh2uMRHmR R0Qw8IZtxnafqBbmivivLkh2RtcaagmbHF6ZkEfzXXR48lEMh37usRXjqWU8fAkCDGUI 0KoViH/KnaJDQP0adE7JdKidL1Dz2xa8bA7qysijOQubILrC1DpKidmAygeW80leKGz0 3WzA== X-Gm-Message-State: AOJu0YxCan2TCvc7hdfLXw/Cxrz9fNacbUzGQ3qbOPU1eBB/9JtdC7o0 CFFvivUgJuXvrS/xDrmSSYyM/o+ATsdihBJlKwXimoOpAQdkGtVneStWUWK1/0nxo+dm9wfHGaT u/H2cLffB8RmsU5P501IE18UbajOgpfR6zFP7 X-Gm-Gg: ASbGncsQkwYtGt0o2YhROh95M9Q4gMH2h1e2bfwIs+TQjDg2Ew6pKX97/+CS/KpVoZL uJeY0VEg8rLVZqWumoqiHOW9or08yyV0xSMSHaolQzBDDETOU1lgwuRn1ibAlta32mS13wN1/2e OwlY6ASgEIykyCIzYljIwPOp3Gx7Jmbp/b/OoZZZtneldgYPj7UDWGNpNTbvHk8Jh9QdPzM5CCH s2qHCg84W571mBsIbisZJc8bo+foctw8SICOiQeQ+8xjMPAIjSb9IupIUH4+2lh6XiIOQ== X-Google-Smtp-Source: AGHT+IHzb7WRyNb0dD1f7Jxz7svxwmVzKgMkwEbOR5UzagMwiS6o4U+PWoOO9Fk/5ED1qP2SFhbUgfxSCNdhfqn4eyU= X-Received: by 2002:a17:907:1c12:b0:b53:e871:f0ea with SMTP id a640c23a62f3a-b7671b15598mr1626650666b.56.1764029918644; Mon, 24 Nov 2025 16:18:38 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sami Imseih Date: Mon, 24 Nov 2025 18:18:26 -0600 X-Gm-Features: AWmQ_bnGuGinN6Dl-PaiWLotG1I5fyArB_6zkjT9iADLJRl3t2IqddEaY5lDxGU Message-ID: Subject: Re: [Proposal] Adding callback support for custom statistics kinds To: Michael Paquier Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > After re-reading your earlier suggestions, this sounds like a third > callback that is used for file cleanup, and this callback could be > the existing reset_all_cb. Also, instead of reset_all_cb being called > during pgstat_reset_after_failure, it can be called during the success > case, i.e, a new pgstat_reset_after_success. reset_all_cb also > carries a status argument so the extension knows what to do > in the case of success or failure. > This also means we need to also update all existing callbacks to > do work in the failed status. After second thought, I am not too thrilled with extending reset_all_cb to take responsibility for file cleanup, etc. I think it should just remain used to reset stats only. I think the best way forward will be to introduce a callback to be used by custom kinds only. This callback will be responsible for cleaning up files and related resources at the end of the write stats, read stats, and discard stats paths. The callback will provide back to the extension a status (READ, WRITE, DISCARD) and the extension will know how to clean up the resources it created depending on the situation. So, unlike my original proposal, this puts more responsibility on the extension to track and clean up its files, but this seems like the best approach to take here. Also, I am now leaning towards creating a separate test module rather than trying to do too much unrelated testing in injection points. It is definitely convenient to use injection points, but I think we can do better testing with a separate module. This module can also serve as an example for extension developers. what do you think? -- Sami Imseih Amazon Web Services (AWS)