Open mtakahar opened 6 months ago
The plan on a release build shown below. Note Workers Planned: 0
.
QUERY PLAN
----------------------------------------------------------------
Gather Merge (cost=1000.03..1000.04 rows=0 width=32)
Workers Planned: 0
-> Sort (cost=0.04..0.04 rows=1 width=32)
Sort Key: ('g'::text)
-> Parallel Append (cost=0.00..0.03 rows=1 width=32)
-> Result (cost=0.00..0.01 rows=1 width=32)
-> Result (cost=0.00..0.01 rows=1 width=32)
(7 rows)
Also the plan from the vanilla PG15:
QUERY PLAN
----------------------------------------------------------------
Gather Merge (cost=1000.02..1000.03 rows=0 width=32)
Workers Planned: 0
-> Sort (cost=0.03..0.03 rows=1 width=32)
Sort Key: ('l'::text)
-> Parallel Append (cost=0.00..0.01 rows=1 width=32)
-> Result (cost=0.00..0.01 rows=1 width=32)
-> Result (cost=0.00..0.01 rows=1 width=32)
(7 rows)
Tried in on a local build of vanilla PG REL_11_STABLE (11.20) (built with --enable-debug --enable-cassert
) to see if it hits the assert, but it wouldn't choose the parallel plan as the 15.1 installed via homebrew.
PG11 test# select version();
version
--------------------------------------------------------------------------------------------------------------------
PostgreSQL 11.20 on x86_64-apple-darwin22.6.0, compiled by Apple clang version 15.0.0 (clang-1500.1.0.2.5), 64-bit
(1 row)
PG11 test# /*+ Set(enable_seqscan OFF) */ SELECT 'l' UNION ALL ( SELECT 'g' ) ORDER BY 1 ;
?column?
----------
g
l
(2 rows)
PG11 test# explain /*+ Set(enable_seqscan OFF) */ SELECT 'l' UNION ALL ( SELECT 'g' ) ORDER BY 1 ;
QUERY PLAN
-------------------------------------------------------
Sort (cost=0.06..0.07 rows=2 width=32)
Sort Key: ('l'::text)
-> Append (cost=0.00..0.05 rows=2 width=32)
-> Result (cost=0.00..0.01 rows=1 width=32)
-> Result (cost=0.00..0.01 rows=1 width=32)
(5 rows)
PG11 test# set force_parallel_mode=on;
SET
PG11 test# /*+ Set(enable_seqscan OFF) */ SELECT 'l' UNION ALL ( SELECT 'g' ) ORDER BY 1 ;
?column?
----------
g
l
(2 rows)
PG11 test# explain /*+ Set(enable_seqscan OFF) */ SELECT 'l' UNION ALL ( SELECT 'g' ) ORDER BY 1 ;
QUERY PLAN
-------------------------------------------------------------
Gather (cost=1000.06..1000.27 rows=2 width=32)
Workers Planned: 1
Single Copy: true
-> Sort (cost=0.06..0.07 rows=2 width=32)
Sort Key: ('l'::text)
-> Append (cost=0.00..0.05 rows=2 width=32)
-> Result (cost=0.00..0.01 rows=1 width=32)
-> Result (cost=0.00..0.01 rows=1 width=32)
(8 rows)
@mtakahar, are you sure you had pg_hint_plan enabled when you ran it on vanilla PG?
The pg_hint_plan has known issues with parallel append: https://github.com/ossc-db/pg_hint_plan/issues/95
I was able to reproduce Workers Planned: 0
on vanilla PG and pg_hint_plan (both latest master), but it did not assert.
I commented on the upstream issue and suggested a fix.
We may wait for their response for some time, with Parallel Append disabled it should not bother us for some time.
@andrei-mart
I was able to reproduce Workers Planned: 0 on vanilla PG and pg_hint_plan (both latest master), That's inline with what I saw (https://github.com/yugabyte/yugabyte-db/issues/21733#issuecomment-2026451750).
but it did not assert. Did you try with a binary built with
--enable-debug --enable-cassert
? If so, great that you were able to confirm.
I guess you are right, I may have forgotten to build & enable corresponding pg_hint_plan when I tried the vanilla PG 11 and 15 I built with --enable-debug --enable-cassert
and that may be the reason I was unable to reproduce the plan with those.
I first built without, and than tried to rebuild with --enable-debug --enable-cassert
later, so I'm not sure I did not make a mistake somewhere and used correct binary.
Anyway, it is all about a block of code in pg_hint_plan code that does funny things to ParallelAppend.
We have ParallelAppend disabled in our code, so we are safe for a while, just need to be aware not to enable ParallelAppend and use pg_hint_plan at the same time. Hence we can wait to see what upstream does with the issue. If nothing, we will have to address it ourself before we re-enable ParallelAppend.
Jira Link: DB-10605
Description
Problem
cost_gather_merge + 225 at .../yugabyte-db/src/postgres/src/backend/optimizer/path/costsize.c:485
.Backtrace on a debug build:
Test Case
No tables necessary. Just run the query with SeqScan disabled either via hint or the guc parameter.
Issue Type
kind/bug
Warning: Please confirm that this issue does not contain any sensitive information