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 1l583f-00033s-2s for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Jan 2021 14:14:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l583d-0003yy-W7 for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Jan 2021 14:14:01 +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 1l583d-0003yr-OY for pgsql-hackers@lists.postgresql.org; Thu, 28 Jan 2021 14:14:01 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l583b-0002bS-Ik for pgsql-hackers@lists.postgresql.org; Thu, 28 Jan 2021 14:14:01 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 3CE405C020C; Thu, 28 Jan 2021 09:13:57 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 28 Jan 2021 09:13:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=aimVQhEocOngHvEP0gL/jsYb6PoDSnFkxStdzwrcKWo=; b=q4Sehj/z 4JBo7zYxSC76j5sdmXQ4VCkpAksVsqmuB/8hF3gZ6JgQq1v+ciZuaGTgtjOn5IH9 +HZVrLEF6BtoCm6lCufIDa/sLZlm+7GY54Pj5WE7vMxJVSU7ij75+egmmJqRUNEZ BUxaWijUNja1nBs6gP3A3enWDzstA7SFxSMvc5lfOT69draOZOcBKf+GwUWHcqdL WAWygG6FFHyP/mG/pxxklZUQBUVrzSVDv5Ty9YgEsI2mCILAkSakxdg8PoQp8T2s +6D35A0bGbx5eRwd+wl4cLHjYmVeN57bHism4o/qMVWVwuO6iF04UoA/zzAmnTsH eHwR1mIuKNvvDQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedtgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfggtggugfgjfgesthekre dttderudenucfhrhhomhepkdetlhhvrghrohcujfgvrhhrvghrrgdkuceorghlvhhhvghr rhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepgfdvvedvte eiheevgfeltdetgffghfeghedvleehvdetiedthffgjeegkeekjeeknecukfhppeduledt rdelhedrudelrddujeejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.177]) by mail.messagingengine.com (Postfix) with ESMTPA id EEC821080064; Thu, 28 Jan 2021 09:13:55 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 3B73C2A0D41; Thu, 28 Jan 2021 11:13:53 -0300 (-03) Date: Thu, 28 Jan 2021 11:13:53 -0300 From: 'Alvaro Herrera' To: "k.jamison@fujitsu.com" Cc: "tsunakawa.takay@fujitsu.com" , "iwata.aya@fujitsu.com" , "'pgsql-hackers@lists.postgresql.org'" Subject: Re: libpq debug log Message-ID: <20210128141353.GA30703@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2021-Jan-28, k.jamison@fujitsu.com wrote: > I realized that existing libpq regression tests in src/test/examples do not > test PQtrace(). At the same time, no other functions Is calling PQtrace(), > so it's expected that by default if there are no compilation errors, then it > will pass all the tests. And it did. > > So to check that the tracing feature is enabled and, as requested, outputs > a trace file, I temporarily modified a bit of testlibpq.c instead **based from > my current environment settings**, and ran the regression test. Yeah. It seems useful to build a real test harness based on the new tracing functionality. And that is precisely why I added the option to suppress timestamps: so that we can write trace files that do not vary from run to run. That allows us to have an "expected" trace to which we can compare the trace file produced by the actual run. I had the idea that instead of a timestamp we would print a message counter. I didn't implement that, however. So what we need to do now, before we cast in stone such expected files, is ensure that the trace file produced by some program (be it testlibpq.c or some other program) accurately matches what is sent over the network. If the tracing infrastructure has bugs, then the trace will contain artifacts, and that's something to avoid. For example, in the trace you paste, why are there two "Query" messages every time, with the second one having length -1? I think this is a bug I introduced recently. > 2021-01-28 09:22:28.155 > Query 59 "SELECT pg_catalog.set_config('search_path', '', false)" > 2021-01-28 09:22:28.156 > Query -1 > 2021-01-28 09:22:28.157 < RowDescription 35 #1 "set_config" 0 #0 25 #65535 -1 #0 > 2021-01-28 09:22:28.157 < DataRow 10 #1 0 > 2021-01-28 09:22:28.157 < CommandComplete 13 "SELECT 1" And afterwards, why are always there two ReadyForQuery messages? > 2021-01-28 09:22:28.157 < ReadyForQuery 5 > 2021-01-28 09:22:28.157 < ReadyForQuery 5 I In ReadyForQuery, we also get a transaction status. In this case it's "I" which means "Idle" (pretty mysterious if you don't know, as was my case). A bunch of other values are possible. Do we want to translate this to human-readable flags, similarly to how we translate message tag chars to message names? Seems useful to me. Or maybe it's overengineering, about which see below. > 2021-01-28 09:22:28.159 < RowDescription 405 #14 "oid" 1262 #1 26 #4 -1 #0 "datname" 1262 #2 19 #64 -1 #0 "datdba" 1262 #3 26 #4 -1 #0 "encoding" 1262 #4 23 #4 -1 #0 "datcollate" 1262 #5 19 #64 -1 #0 "datctype" 1262 #6 19 #64 -1 #0 "datistemplate" 1262 #7 16 #1 -1 #0 "datallowconn" 1262 #8 16 #1 -1 #0 "datconnlimit" 1262 #9 23 #4 -1 #0 "datlastsysoid" 1262 #10 26 #4 -1 #0 "datfrozenxid" 1262 #11 28 #4 -1 #0 "datminmxid" 1262 #12 28 #4 -1 #0 "dattablespace" 1262 #13 26 #4 -1 #0 "datacl" 1262 #14 1034 #65535 -1 #0 This is terribly unreadable, but at this point that's okay because we're just doing tracing at a very low level. In the future we could add some new flag PQTRACE_INTERPRET_MESSAGES or something, which changes the output format to something more readable. Or maybe nobody cares to spend time doing that. Cheers -- Álvaro Herrera Valdivia, Chile "Para tener más hay que desear menos"