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 1nFYRS-0008Gt-Bo for pgsql-docs@arkaria.postgresql.org; Thu, 03 Feb 2022 09:30:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nFYRQ-0001Ys-5y for pgsql-docs@arkaria.postgresql.org; Thu, 03 Feb 2022 09:30:12 +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 1nFYRP-0001Yc-Aa for pgsql-docs@lists.postgresql.org; Thu, 03 Feb 2022 09:30:11 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFYRK-00009m-Fi for pgsql-docs@lists.postgresql.org; Thu, 03 Feb 2022 09:30:10 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 6C1105C01EA; Thu, 3 Feb 2022 04:30:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 03 Feb 2022 04:30:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=lFYoF5t+jJVMXlI/VD7pRFTVZLU2l8lz+gKBWfTYgVk=; b=Fh/oJd7K pb7ofraa8UPrnuhyw/zkFGje1SmsQ18lb2ZdkN+JDxYo2fpVDD2xhK8ErxMJgtTi WPeRhjkOTxNoeURYNVYV4xiElk6+Mr4QSG07QRoqAobXm3lY0Y+VTxZEILj1bSkm 1dadreQmrELXyMltP8Y24wLV4ojoZfRRq/OaK2mjaUBa5qRGKnVFYHwfjKW2xf6T XWywHvaxKXAzjj3EOyPeelHezbbSfknnai1ApJGDd6wJpHPEXBA7+1PVa1fYuHmi x9YzU+kbk43NToRMK0ajQt4CeWXtkaQRoR10BHMj5YYYKP/I6bC8P1lisrgjjWf6 N2kFuf2qdEGYDA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrgeejgddtvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrh hprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeefjeegheetuefhveevudel ueeftdejteeiffetvdduhfdtieefgfeutedtveeggfenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghuthes vghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Feb 2022 04:30:02 -0500 (EST) Message-ID: Date: Thu, 3 Feb 2022 10:30:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: maximum number of backtrace frames logged by backtrace_functions Content-Language: en-US To: Fujii Masao , pgsql-docs@lists.postgresql.org References: <0f0ed9f3-3892-e8a3-51c9-ed268dff6bdd@oss.nttdata.com> <4e16a3e9-e717-05e1-d905-6c21beba80f8@enterprisedb.com> From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 03.02.22 06:33, Fujii Masao wrote: > I encountered the "more than 100 backtrace frames" case when > investigating the bug of pg_log_query_plan() patch [1]. Since the > function that the patch added can be called repeatedly during call to > that function, the backtrace became larger than 100. I think this is not > general case, so basically 100 sounds enough limit size to me. > > OTOH I think it's helpful if the limit is documented when I occasionally > encounter the case and want to understand why all backtrace frames are > not logged. How about we issue a message when the backtrace is cut off. Then it's immediately visible to the user, instead of hidden away somewhere in the documentation. Something like this (untested): diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 7402696986..3777dff030 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -967,6 +967,8 @@ set_backtrace(ErrorData *edata, int num_skip) for (int i = num_skip; i < nframes; i++) appendStringInfo(&errtrace, "\n%s", strfrms[i]); free(strfrms); + if (nframes >= lengthof(buf)) + appendStringInfo(&errtrace, "\n(backtrace limited to %zu frames)", lengthof(buf)); } #else appendStringInfoString(&errtrace,