pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #16487: EXPLAIN produces JSON with duplicate "Workers" arrays
3+ messages / 3 participants
[nested] [flat]
* BUG #16487: EXPLAIN produces JSON with duplicate "Workers" arrays
@ 2020-06-08 19:06 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: PG Bug reporting form @ 2020-06-08 19:06 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: felix@felixge.de
The following bug has been logged on the website:
Bug reference: 16487
Logged by: Felix Geisendörfer
Email address: felix@felixge.de
PostgreSQL version: 12.1
Operating system: Any
Description:
Hi all,
I believe I found a bug that causes EXPLAIN to produce JSON with
duplicate "Workers" arrays when the following conditions are met:
- The options ANALYZE, VERBOSE and FORMAT JSON are used together.
- There is a Sort node in the plan that is executed in parallel.
Below is an example that should reproduce the issue in all version of
PostgreSQL >= 10. I tested with 12.1 and 11.6.
-- Create a sample table and nudge the planner to use a parallel plan
CREATE TABLE foo AS
SELECT * FROM generate_series(1, 10000) val;
SET parallel_setup_cost = 0;
SET parallel_tuple_cost = 0;
SET min_parallel_table_scan_size=0;
-- Run the actual query that causes the invalid JSON output
EXPLAIN (ANALYZE, VERBOSE, FORMAT JSON)
SELECT * FROM foo ORDER BY val;
Below is the relevant subset of the JSON produced by the query above.
Note the duplicate "Workers" arrays:
{
"Node Type": "Sort",
"Workers": [
{
"Worker Number": 0,
"Sort Method": "quicksort",
"Sort Space Used": 25,
"Sort Space Type": "Memory"
},
{
"Worker Number": 1,
"Sort Method": "quicksort",
"Sort Space Used": 25,
"Sort Space Type": "Memory"
}
],
"Workers": [
{
"Worker Number": 0,
"Actual Startup Time": 0.230,
"Actual Total Time": 0.230,
"Actual Rows": 0,
"Actual Loops": 1
},
{
"Worker Number": 1,
"Actual Startup Time": 0.231,
"Actual Total Time": 0.231,
"Actual Rows": 0,
"Actual Loops": 1
}
]
}
According to RFC 8259, I think this is technically still valid JSON:
> When the names within an object are not unique, the behavior of
> software that receives such an object is unpredictable.
However, I'm still reporting this as a bug since I assume that the
FORMAT JSON option is intended to have good interoperability with other
software.
I've also had a look in the code, and believe the issue was introduced
into backend/commands/explain.c in bf11e7e.
If somebody is willing to guide me a little, I'd also be interested in
attempting to create a patch to fix this. I haven't contributed to
PostgreSQL before and this seems like a nice opportunity.
Cheers
Felix
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #16487: EXPLAIN produces JSON with duplicate "Workers" arrays
@ 2020-06-08 21:41 Tom Lane <tgl@sss.pgh.pa.us>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2020-06-08 21:41 UTC (permalink / raw)
To: felix@felixge.de; +Cc: pgsql-bugs@lists.postgresql.org
PG Bug reporting form <noreply@postgresql.org> writes:
> I believe I found a bug that causes EXPLAIN to produce JSON with
> duplicate "Workers" arrays when the following conditions are met:
Yeah ... this is fixed for v13 but we felt that back-patching such a
change might cause more pain than benefit. See
https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=100136849
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #16487: EXPLAIN produces JSON with duplicate "Workers" arrays
@ 2020-06-09 06:21 Felix Geisendörfer <felix@felixge.de>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Felix Geisendörfer @ 2020-06-09 06:21 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs@lists.postgresql.org
> On 8. Jun 2020, at 23:41, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> PG Bug reporting form <noreply@postgresql.org> writes:
>> I believe I found a bug that causes EXPLAIN to produce JSON with
>> duplicate "Workers" arrays when the following conditions are met:
>
> Yeah ... this is fixed for v13 but we felt that back-patching such a
> change might cause more pain than benefit. See
>
> https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=100136849
>
> regards, tom lane
Thanks, that's great : ).
I should have checked the latest code first before posting this.
Cheers
Felix
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-06-09 06:21 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08 19:06 BUG #16487: EXPLAIN produces JSON with duplicate "Workers" arrays PG Bug reporting form <noreply@postgresql.org>
2020-06-08 21:41 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-06-09 06:21 ` Felix Geisendörfer <felix@felixge.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox