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 1jKOC2-00045W-Ou for pgsql-committers@arkaria.postgresql.org; Fri, 03 Apr 2020 15:25: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 1jKOC1-000856-B3 for pgsql-committers@arkaria.postgresql.org; Fri, 03 Apr 2020 15:25:13 +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 1jKOC1-00084x-4S for pgsql-committers@lists.postgresql.org; Fri, 03 Apr 2020 15:25:13 +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 1jKOBy-0000O1-NF for pgsql-committers@lists.postgresql.org; Fri, 03 Apr 2020 15:25:12 +0000 Received: from hnk.local (p2421237-ipbf2725funabasi.chiba.ocn.ne.jp [122.24.33.237]) by oss.nttdata.com (Postfix) with ESMTPSA id 29EDE602A6; Sat, 4 Apr 2020 00:25:06 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at oss.nttdata.com Subject: Re: pgsql: Include information on buffer usage during planning phase, in EX To: Tom Lane Cc: Michael Paquier , Fujii Masao , pgsql-committers@lists.postgresql.org References: <20200403025751.GB1759@paquier.xyz> <0fa34bc8-479e-61e8-94c0-9cdbc34ea0bb@oss.nttdata.com> <23095.1585884653@sss.pgh.pa.us> <4ecdae9c-fa0b-17b6-9166-0a45c396da22@oss.nttdata.com> <20577.1585920933@sss.pgh.pa.us> <1c26658b-fb09-3c4c-2eff-a61e86ab5316@oss.nttdata.com> <32174.1585925727@sss.pgh.pa.us> From: Fujii Masao Message-ID: <4e46867d-7183-ef3c-5299-755b4396e96c@oss.nttdata.com> Date: Sat, 4 Apr 2020 00:25:05 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <32174.1585925727@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------7ACAEEA344C54058275102CA" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------7ACAEEA344C54058275102CA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 2020/04/03 23:55, Tom Lane wrote: > Fujii Masao writes: >> On 2020/04/03 22:35, Tom Lane wrote: >>> I think this is a bad idea. It's overcomplicated, and more to the >>> point: now that we've seen the problem we should realize that we're >>> eventually going to have failures for *any* Buffers line in text-mode >>> output. We're already filtering them so hard as to be nearly useless >>> (see a couple lines further down). I think we should just drop them >>> in text mode and be content with checking for them in non-text modes. > >> Yeah, I'm fine with the idea. The regression test for EXPLAIN has >> the following four similar tests. The first one fails in regression test >> because of buffers output for the planning. Your idea seems to be >> equal to removal of this first test. Because there are already >> the same tests with other format. Is my understanding right? > > Well, there are at least three ways you could interpret my suggestion: > > * don't do the test with format = text at all > > * do it, but remove the buffers option > > * keep test the same, make explain_filter() drop Buffers lines > > But I had the last one in mind. Even if we can't *see* the output, > there is some value in making the backend run through the code --- > it'd at least catch core-dumping bugs there. Yes, this makes sense. Thanks for clarifying that! >> Or another idea is to specify "summary off" in the above first >> EXPLAIN command, to suppress the summary output including >> the buffers output for the planning. This seems simple and enough. > > That's still assuming that only the summary Buffers line is problematic, > which I think is wrong. Keep in mind that the explain.sql test is > barely two months old; it has never seen the field, and there is no > good reason to trust that it's rock solid stable. Now that we've > seen this failure, I'm quite afraid that the existing test case > > Seq Scan on int8_tbl i8 (cost=N.N..N.N rows=N width=N) (actual time=N.N..N.N rows=N loops=N) > Buffers: shared [read] > Planning Time: N.N ms > > can be made to fall over, eg by running with high enough shared_buffers. Yeah, so I'm feeling that it's better to firstly make the explain test more stable, separately from the patch for the planning buffers output. Attached is the patch that changes explain.c as follows (i.e., removes Buffers lines at all) to make it more stable. ln := regexp_replace(ln, '\m\d+\M', 'N', 'g'); -- In sort output, the above won't match units-suffixed numbers ln := regexp_replace(ln, '\m\d+kB', 'NkB', 'g'); - -- Text-mode buffers output varies depending on the system state - ln := regexp_replace(ln, '^( +Buffers: shared)( hit=N)?( read=N)?', '\1 [read]'); + -- Ignore text-mode buffers output because it varies depending + -- on the system state + CONTINUE WHEN (ln ~ ' +Buffers: .*'); return next ln; end loop; end; Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION --------------7ACAEEA344C54058275102CA Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="make_explain_test_more_stable.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="make_explain_test_more_stable.patch" ZGlmZiAtLWdpdCBhL3NyYy90ZXN0L3JlZ3Jlc3MvZXhwZWN0ZWQvZXhwbGFpbi5vdXQgYi9z cmMvdGVzdC9yZWdyZXNzL2V4cGVjdGVkL2V4cGxhaW4ub3V0CmluZGV4IDhmMzFjMzA4YzYu LjNlYzY2Y2VkYTMgMTAwNjQ0Ci0tLSBhL3NyYy90ZXN0L3JlZ3Jlc3MvZXhwZWN0ZWQvZXhw bGFpbi5vdXQKKysrIGIvc3JjL3Rlc3QvcmVncmVzcy9leHBlY3RlZC9leHBsYWluLm91dApA QCAtMjAsOCArMjAsOSBAQCBiZWdpbgogICAgICAgICBsbiA6PSByZWdleHBfcmVwbGFjZShs biwgJ1xtXGQrXE0nLCAnTicsICdnJyk7CiAgICAgICAgIC0tIEluIHNvcnQgb3V0cHV0LCB0 aGUgYWJvdmUgd29uJ3QgbWF0Y2ggdW5pdHMtc3VmZml4ZWQgbnVtYmVycwogICAgICAgICBs biA6PSByZWd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