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 1vT6w5-00D9lF-1D for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Dec 2025 23:16:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vT6w4-008MbV-06 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Dec 2025 23:16:00 +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 1vT6w3-008MbK-2L for pgsql-hackers@lists.postgresql.org; Tue, 09 Dec 2025 23:16:00 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vT6w1-0048kg-2v for pgsql-hackers@lists.postgresql.org; Tue, 09 Dec 2025 23:15:59 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-6492e25cd7eso544410a12.0 for ; Tue, 09 Dec 2025 15:15:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765322157; x=1765926957; 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=jBUBmtKdtZ4mmzY9EICaaaIHN9dpSVQUGzzKtslG7xo=; b=VzjbDSbq6locF6/aNZb+Q7zMiVVxiopRK9TTxrDvXzNUf/wQXpfvbsgvgaByxice3q L1gsj9VBqMSK3YWtnc+pnmx6gq39HjbVkLBGfH+C4jtpmxt8QIelk1tDEPH2rb5ZobfY pog5iGRU7UfhdcVhB3QZKALTL7zKnwra1MXzRRJI4qEtdZDCAMosjo8peE/dzj76CpuP gNVb166RgDydUCldBaQQzTs+ftl7Bd8//TB70uPbAKpP9syFfEunBUEZ+nEUAQpSFYoV iszIPWRYmsADxqCaATP4sF9LEw8zYhA7Dt8lbCPP8knSIf9ekPOlqcb6akfPb07gRTn6 Coew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765322157; x=1765926957; 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=jBUBmtKdtZ4mmzY9EICaaaIHN9dpSVQUGzzKtslG7xo=; b=c++KqyNjF+Z6DOCUsbuYr/ehKNLxvSAq+OVAu1u1+s5KQ7RUMOvGv9Ez4ujWWIvUay dM8Y0rkr9lGdDeQtwAPLPEhKLR6RVDLM5lBD8Ry/+ln4Sp/8oVAMpsBjUPeDPCqRGmTx 374YMCmnd+rM4TjgR4buvaD4oQ4AYAXhusoRD3kXykksFjid35g2UIAcWPEXmnW6fuHM nwC29aP/3YTfRiu9fG6TgC8ZLryZsVLeqFb6HDKJQJvK2o3zsNgdv2bsYNTNUEtFNdNo VyPlKGnV1ZlfA5ipkstG9NT72EXYBM5vOrawonYzMkJ2OCud62yDqLKY1z5okS1fVzoj vmdQ== X-Forwarded-Encrypted: i=1; AJvYcCUvq8ep46qrcoJEYtxSMOYYXi3MILEZiSO8YfZaK7xuiOOP3puxnQyJLEIiZV9lGz3yHR7PqvD2F4K6fWPT@lists.postgresql.org X-Gm-Message-State: AOJu0YzywPhmkEEBs/GSfcW/X3R74/FjtSz/bn2QLMY5qXRmVjk2BlHn wga4p7NBEm7ngBXbmP8Yy3zmfQL1Q6TgVdbhWIB5qj01HmC0Kbc3Pyl37hoigsv2VpA0DkfJj5j V+iBM5j1hs0Yy83F5h6GDyB/hDv4bS/k= X-Gm-Gg: AY/fxX77QUtW59mnD+TfLR7LuOW6lOQn6sGhXcbIEjYbeE6Vz+K4PMB2FJ1paUe+zi6 M6zvwarZXAqA6nUfBCbN6NKDfZVYqVrO49b2DtP5TD8xC9i0qU1ZEe0QHKuP1JoCuDUlBuuRKPM kOQPFoxlhmDNcuYu+HKD8mNRa8JN8wWeKz9OPki5HmKUkeZnTb0r7ahh9UZznToCgeJsPiWvK81 Q3JQd0m0upc6ghKgruVFOIVZhHE1GHTJGebj0c0LhzsA4EGQ7jxuUd6Aa+YuEkC/MdJQ2QDafzP 0W4= X-Google-Smtp-Source: AGHT+IEQnb4kRLHcqDfu9e5DDDW8xq0BpgTX8xuQ6xcI0j9Jv543FfUD2mfN6lPGQnX55deUNpuJPX2fNdAKfl4eRPE= X-Received: by 2002:a05:6402:f11:b0:644:fc07:2d08 with SMTP id 4fb4d7f45d1cf-64963f22b65mr2155594a12.2.1765322156730; Tue, 09 Dec 2025 15:15:56 -0800 (PST) MIME-Version: 1.0 References: <4FEEC2B8-D9CF-4BD0-AA7E-44CE3E27ADD8@gmail.com> <5EC13E39-B41E-464A-B382-0ACEB18A15BB@gmail.com> <9252DA7C-C611-4A93-A484-E6CD42557C15@gmail.com> <4E61FDC4-CFBB-4116-980F-75ADD245A1F6@gmail.com> In-Reply-To: <4E61FDC4-CFBB-4116-980F-75ADD245A1F6@gmail.com> From: Sami Imseih Date: Tue, 9 Dec 2025 17:15:45 -0600 X-Gm-Features: AQt7F2rs0F1dnadEnPspSJdk7_ELeGve8mPi6Nm8rXjq3GZPZP1hLeVf8Mot9mk Message-ID: Subject: Re: [Proposal] Adding callback support for custom statistics kinds To: Chao Li Cc: Michael Paquier , PostgreSQL Hackers Content-Type: multipart/alternative; boundary="00000000000010eb0a06458d186b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000010eb0a06458d186b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > > IIUC, if *any* error occurs outside of a deserialize callback, first th= e > "error" > > code will be called, followed by "done" which will then trigger the > > end_extra_stats > > callback that will perform the cleanup. > > That is true. But problem is, without an error indication, > end_extra_stats(STATS_READ) can only blindly perform cleanup works. As yo= u > are providing general purposed callbacks, who knows what scenarios > extensions would do, so it=E2=80=99s better to provide more information t= o > callbacks. IMO, letting end_extra_stats() know current situation (normal = or > failure, even error code) is very meaningful. For example, my extension m= ay > want to log =E2=80=9CI am forced to quite due to outside error=E2=80=9D o= r =E2=80=9CI am done > successfully=E2=80=9D in end_extra_stats(). Anyway, that=E2=80=99s my own= opinion. If you > and Michael still consider that=E2=80=99s not a problem, I won=E2=80=99t = argue more. Thanks for explaining. If there is a good use-case to add more detail to the =E2=80=9Cend=E2=80=9D callback, it=E2=80=99s not very obvious yet. Mayb= e in the future, there will be a convincing reason to do so. When we hit the clean-up code on any =E2=80=9Cerror=E2=80=9D, it should be = accompanied by an error log. That is done in all cases inside pgstat.c, and I expect an extension to log the error as well. -- Sami Imseih Amazon Web Services (AWS) --00000000000010eb0a06458d186b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> IIUC, if *any* error occurs outside of = a deserialize callback, first the "error"
> code will be called, followed by "done" which will then trig= ger the
> end_extra_stats
> callback that will perform the cleanup.

That is true. But problem is, without an error indication, end_extra_stats(= STATS_READ) can only blindly perform cleanup works. As you are providing ge= neral purposed callbacks, who knows what scenarios extensions would do, so = it=E2=80=99s better to provide more information to callbacks. IMO, letting = end_extra_stats() know current situation (normal or failure, even error cod= e) is very meaningful. For example, my extension may want to log =E2=80=9CI= am forced to quite due to outside error=E2=80=9D or =E2=80=9CI am done suc= cessfully=E2=80=9D in end_extra_stats(). Anyway, that=E2=80=99s my own opin= ion. If you and Michael still consider that=E2=80=99s not a problem, I won= =E2=80=99t argue more.

Thanks for explaining. If there is a good use-case to add more detail= to the =E2=80=9Cend=E2=80=9D callback, it=E2=80=99s not very=C2=A0obvious yet. Maybe in the futu= re, there will be a convincing reason to do so.=C2=A0

<= /div>
When we hit the clean-up code on any =E2=80=9Cerror=E2=80=9D, it should be= accompanied by an error log. That is=C2=A0
d= one in all cases inside pgstat.c, and I expect an=C2=A0extension to log the error as well.=C2=A0<= /span>


--
Sami Imseih
Amazon Web= Services (AWS)


--00000000000010eb0a06458d186b--