Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lPd7x-0006o8-6k for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Mar 2021 03:27:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lPd7Q-0005r6-CU for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Mar 2021 03:26:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lPd7Q-0005qz-5H for pgsql-hackers@lists.postgresql.org; Fri, 26 Mar 2021 03:26:40 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lPd7N-0007ug-Ca for pgsql-hackers@postgresql.org; Fri, 26 Mar 2021 03:26:39 +0000 Received: from hnk.local (p2350207-ipbf2126funabasi.chiba.ocn.ne.jp [114.167.184.207]) by oss.nttdata.com (Postfix) with ESMTPSA id 04460628CC; Fri, 26 Mar 2021 12:26:31 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com Subject: Re: Get memory contexts of an arbitrary backend process To: Kyotaro Horiguchi , torikoshia@oss.nttdata.com Cc: pgsql-hackers@postgresql.org, tgl@sss.pgh.pa.us, gkokolatos@protonmail.com, kasahara.tatsuhito@gmail.com, craig@2ndquadrant.com References: <0b0657d5febd0e46565a6bc9c62ba3f6@oss.nttdata.com> <2be9b430-e664-a342-7799-c92779808029@oss.nttdata.com> <20210326.120104.2148406039277091336.horikyota.ntt@gmail.com> From: Fujii Masao Message-ID: <6738f309-a41b-cbe6-bb57-a1c58ce9f05a@oss.nttdata.com> Date: Fri, 26 Mar 2021 12:26:31 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210326.120104.2148406039277091336.horikyota.ntt@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/03/26 12:01, Kyotaro Horiguchi wrote: > At Thu, 25 Mar 2021 23:45:17 +0900, torikoshia wrote in >> Attached new one. Regarding the argument max_children, isn't it better to set its default value, e.g., 100 like MemoryContextStats() uses? + ereport(WARNING, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("must be a superuser to log memory contexts"))); IMO this type of error, i.e., permission error, should be treated as ERROR rather than WARNING, like pg_terminate_backend() does. + ereport(WARNING, + (errmsg("failed to send signal: %m"))); Per message style rule, "could not send signal to process %d: %m" is better? > Thanks! > > - SELECT * FROM pg_get_backend_memory_contexts(); > + SELECT * FROM pg_get_backend_memory_contexts(0, 0); > > However we can freely change the signature since it's new in 14, but I > see the (void) signature as useful. I vaguely thought of defining > pg_get_backend_memory_contexts(void) in pg_proc.dat then defining > (int, int) as a different function in system_views.sql. That allows > the function of the second signature to output nothing. You can make a > distinction between the two signatures by using PG_NARGS() in the C > function. > > That being said, it's somewhat uneasy that two functions with the same > name returns different values. I'd like to hear others what they feel > like about the behavior. I think that it's confusing to merge two different features into one function. Isn't it better to leave pg_get_backend_memory_contexts() as it is, and make the log-memory-contexts feature as separate function, e.g., pg_log_backend_memory_contexts()? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION