Hi, It seems that Q19 from TPC-H is consistently failing with segfaults due to calling tbm_prepare_shared_iterate() with (tbm->dsa==NULL).
I'm not very familiar with how the dsa is initialized and passed around, but I only see the failures when the bitmap is constructed by a mix of BitmapAnd and BitmapOr operations. Another interesting observation is that setting force_parallel_mode=on may not be enough - there really need to be multiple parallel workers, which is why the simple query does cpu_tuple_cost=1. Attached is a bunch of files: 1) details for "full" query: * query.sql * plan.txt * backtrace.txt 2) details for the "minimal" query triggering the issue: * query-minimal.sql * plan-minimal.txt * backtrace-minimal.txt regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Program terminated with signal 6, Aborted.
#0 0x00007fe21265d1f7 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-196.el7.x86_64
(gdb) bt
#0 0x00007fe21265d1f7 in raise () from /lib64/libc.so.6
#1 0x00007fe21265e8e8 in abort () from /lib64/libc.so.6
#2 0x00000000008468e7 in ExceptionalCondition
(conditionName=conditionName@entry=0x9d213a "!(tbm->dsa != ((void *)0))",
errorType=errorType@entry=0x88fc69 "FailedAssertion",
fileName=fileName@entry=0x9d2014 "tidbitmap.c",
lineNumber=lineNumber@entry=800) at assert.c:54
#3 0x000000000065b04f in tbm_prepare_shared_iterate (tbm=tbm@entry=0x2b244e8)
at tidbitmap.c:800
#4 0x000000000062294a in BitmapHeapNext (node=node@entry=0x2adf118) at
nodeBitmapHeapscan.c:155
#5 0x0000000000616d7a in ExecScanFetch (recheckMtd=0x623050
<BitmapHeapRecheck>, accessMtd=0x622250 <BitmapHeapNext>, node=0x2adf118) at
execScan.c:97
#6 ExecScan (node=0x2adf118, accessMtd=0x622250 <BitmapHeapNext>,
recheckMtd=0x623050 <BitmapHeapRecheck>) at execScan.c:147
#7 0x0000000000624c75 in ExecProcNode (node=0x2adf118) at
../../../src/include/executor/executor.h:250
#8 gather_getnext (gatherstate=0x2aded50) at nodeGather.c:281
#9 ExecGather (pstate=0x2aded50) at nodeGather.c:215
#10 0x0000000000610d12 in ExecProcNode (node=0x2aded50) at
../../../src/include/executor/executor.h:250
#11 ExecutePlan (execute_once=<optimized out>, dest=0x2b09220,
direction=<optimized out>, numberTuples=0, sendTuples=1 '\001',
operation=CMD_SELECT, use_parallel_mode=<optimized out>, planstate=0x2aded50,
estate=0x2adeb00) at execMain.c:1721
#12 standard_ExecutorRun (queryDesc=0x2a3bdf0, direction=<optimized out>,
count=0, execute_once=<optimized out>) at execMain.c:363
#13 0x000000000074b50b in PortalRunSelect (portal=portal@entry=0x2a34050,
forward=forward@entry=1 '\001', count=0, count@entry=9223372036854775807,
dest=dest@entry=0x2b09220) at pquery.c:932
#14 0x000000000074ca18 in PortalRun (portal=portal@entry=0x2a34050,
count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=1 '\001',
run_once=run_once@entry=1 '\001', dest=dest@entry=0x2b09220,
altdest=altdest@entry=0x2b09220,
completionTag=completionTag@entry=0x7ffc8dad21c0 "") at pquery.c:773
#15 0x000000000074875b in exec_simple_query (
query_string=0x2a96ff0 "select\n *\nfrom\n part\nwhere\n (\n
p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')\n and p_size
between 1 and 5\n )\n or\n (\n p_container in ('MED BAG', 'MED
B"...) at postgres.c:1099
#16 0x0000000000749a03 in PostgresMain (argc=<optimized out>,
argv=argv@entry=0x2a44048, dbname=0x2a43eb0 "test", username=<optimized out>)
at postgres.c:4088
#17 0x000000000047665f in BackendRun (port=0x2a37cc0) at postmaster.c:4357
#18 BackendStartup (port=0x2a37cc0) at postmaster.c:4029
#19 ServerLoop () at postmaster.c:1753
#20 0x00000000006d70d9 in PostmasterMain (argc=argc@entry=3,
argv=argv@entry=0x2a14b20) at postmaster.c:1361
#21 0x00000000004774c1 in main (argc=3, argv=0x2a14b20) at main.c:228
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Gather
Workers Planned: 2
-> Parallel Bitmap Heap Scan on part
Recheck Cond: (((p_size <= 5) AND (p_size >= 1) AND (p_container = ANY
('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[]))) OR ((p_container = ANY
('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_size <= 10)
AND (p_size >= 1)))
-> BitmapOr
-> BitmapAnd
-> Bitmap Index Scan on part_p_size_idx
Index Cond: ((p_size <= 5) AND (p_size >= 1))
-> Bitmap Index Scan on
part_p_container_p_brand_p_partkey_idx
Index Cond: (p_container = ANY ('{"SM CASE","SM
BOX","SM PACK","SM PKG"}'::bpchar[]))
-> BitmapAnd
-> Bitmap Index Scan on
part_p_container_p_brand_p_partkey_idx
Index Cond: (p_container = ANY ('{"MED BAG","MED
BOX","MED PKG","MED PACK"}'::bpchar[]))
-> Bitmap Index Scan on part_p_size_idx
Index Cond: ((p_size <= 10) AND (p_size >= 1))
(15 rows)
-- increase cpu_tuple_cost to force parallel query
set cpu_tuple_cost = 1;
select
*
from
part
where
(
p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
and p_size between 1 and 5
)
or
(
p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
and p_size between 1 and 10
);
query.sql
Description: application/sql
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit
-> Finalize Aggregate
-> Gather
Workers Planned: 2
-> Partial Aggregate
-> Nested Loop
-> Parallel Bitmap Heap Scan on part
Recheck Cond: (((p_container = ANY ('{"SM
CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand =
'Brand#51'::bpchar) AND (p_size <= 5) AND (p_size >= 1)) OR ((p_container = ANY
('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand =
'Brand#54'::bpchar) AND (p_size <= 10) AND (p_size >= 1)) OR ((p_container =
ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand =
'Brand#42'::bpchar)))
Filter: ((p_size >= 1) AND (((p_brand =
'Brand#51'::bpchar) AND (p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM
PKG"}'::bpchar[])) AND (p_size <= 5)) OR ((p_brand = 'Brand#54'::bpchar) AND
(p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[]))
AND (p_size <= 10)) OR ((p_brand = 'Brand#42'::bpchar) AND (p_container = ANY
('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_size <= 15))))
-> BitmapOr
-> BitmapAnd
-> Bitmap Index Scan on
part_p_container_p_brand_p_partkey_idx
Index Cond: ((p_container =
ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand =
'Brand#51'::bpchar))
-> Bitmap Index Scan on
part_p_size_idx
Index Cond: ((p_size <= 5)
AND (p_size >= 1))
-> BitmapAnd
-> Bitmap Index Scan on
part_p_container_p_brand_p_partkey_idx
Index Cond: ((p_container =
ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand =
'Brand#54'::bpchar))
-> Bitmap Index Scan on
part_p_size_idx
Index Cond: ((p_size <= 10)
AND (p_size >= 1))
-> Bitmap Index Scan on
part_p_container_p_brand_p_partkey_idx
Index Cond: ((p_container = ANY
('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand =
'Brand#42'::bpchar))
-> Index Scan using
lineitem_l_partkey_l_quantity_l_shipmode_idx on lineitem
Index Cond: ((l_partkey = part.p_partkey) AND
(l_shipmode = ANY ('{AIR,"AIR REG"}'::bpchar[])))
Filter: ((l_shipinstruct = 'DELIVER IN
PERSON'::bpchar) AND (((l_quantity >= '3'::double precision) AND (l_quantity <=
'13'::double precision)) OR ((l_quantity >= '13'::double precision) AND
(l_quantity <= '23'::double precision)) OR ((l_quantity >= '25'::double
precision) AND (l_quantity <= '35'::double precision))) AND (((part.p_brand =
'Brand#51'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM
PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= '3'::double precision) AND
(l_quantity <= '13'::double precision) AND (part.p_size <= 5)) OR
((part.p_brand = 'Brand#54'::bpchar) AND (part.p_container = ANY ('{"MED
BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >=
'13'::double precision) AND (l_quantity <= '23'::double precision) AND
(part.p_size <= 10)) OR ((part.p_brand = 'Brand#42'::bpchar) AND
(part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[]))
AND (l_quantity >= '25'::double precision) AND (l_quantity <= '35'::double
precision) AND (part.p_size <= 15))))
(25 rows)
Core was generated by `postgres: tomas test [local] SELECT '.
Program terminated with signal 6, Aborted.
#0 0x00007fe21265d1f7 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-196.el7.x86_64
(gdb) bt
#0 0x00007fe21265d1f7 in raise () from /lib64/libc.so.6
#1 0x00007fe21265e8e8 in abort () from /lib64/libc.so.6
#2 0x00000000008468e7 in ExceptionalCondition
(conditionName=conditionName@entry=0x9d213a "!(tbm->dsa != ((void *)0))",
errorType=errorType@entry=0x88fc69 "FailedAssertion",
fileName=fileName@entry=0x9d2014 "tidbitmap.c",
lineNumber=lineNumber@entry=800) at assert.c:54
#3 0x000000000065b04f in tbm_prepare_shared_iterate (tbm=tbm@entry=0x2d89610)
at tidbitmap.c:800
#4 0x000000000062294a in BitmapHeapNext (node=node@entry=0x2ba6848) at
nodeBitmapHeapscan.c:155
#5 0x0000000000616c5b in ExecScanFetch (recheckMtd=0x623050
<BitmapHeapRecheck>, accessMtd=0x622250 <BitmapHeapNext>, node=0x2ba6848) at
execScan.c:97
#6 ExecScan (node=0x2ba6848, accessMtd=0x622250 <BitmapHeapNext>,
recheckMtd=0x623050 <BitmapHeapRecheck>) at execScan.c:164
#7 0x00000000006319ca in ExecProcNode (node=0x2ba6848) at
../../../src/include/executor/executor.h:250
#8 ExecNestLoop (pstate=0x2ba6670) at nodeNestloop.c:109
#9 0x000000000061d1c9 in ExecProcNode (node=0x2ba6670) at
../../../src/include/executor/executor.h:250
#10 fetch_input_tuple (aggstate=aggstate@entry=0x2ba5fb8) at nodeAgg.c:688
#11 0x000000000061f4a7 in agg_retrieve_direct (aggstate=0x2ba5fb8) at
nodeAgg.c:2313
#12 ExecAgg (pstate=0x2ba5fb8) at nodeAgg.c:2124
#13 0x0000000000624c75 in ExecProcNode (node=0x2ba5fb8) at
../../../src/include/executor/executor.h:250
#14 gather_getnext (gatherstate=0x2ba5c60) at nodeGather.c:281
#15 ExecGather (pstate=0x2ba5c60) at nodeGather.c:215
#16 0x000000000061d1c9 in ExecProcNode (node=0x2ba5c60) at
../../../src/include/executor/executor.h:250
#17 fetch_input_tuple (aggstate=aggstate@entry=0x2ba55a8) at nodeAgg.c:688
#18 0x000000000061f4a7 in agg_retrieve_direct (aggstate=0x2ba55a8) at
nodeAgg.c:2313
#19 ExecAgg (pstate=0x2ba55a8) at nodeAgg.c:2124
#20 0x000000000062ae39 in ExecProcNode (node=0x2ba55a8) at
../../../src/include/executor/executor.h:250
#21 ExecLimit (pstate=0x2ba4df0) at nodeLimit.c:95
#22 0x0000000000610d12 in ExecProcNode (node=0x2ba4df0) at
../../../src/include/executor/executor.h:250
#23 ExecutePlan (execute_once=<optimized out>, dest=0x2d484f0,
direction=<optimized out>, numberTuples=0, sendTuples=1 '\001',
operation=CMD_SELECT, use_parallel_mode=<optimized out>, planstate=0x2ba4df0,
estate=0x2ba4b40) at execMain.c:1721
#24 standard_ExecutorRun (queryDesc=0x2be7da0, direction=<optimized out>,
count=0, execute_once=<optimized out>) at execMain.c:363
#25 0x000000000074b50b in PortalRunSelect (portal=portal@entry=0x2a34050,
forward=forward@entry=1 '\001', count=0, count@entry=9223372036854775807,
dest=dest@entry=0x2d484f0) at pquery.c:932
#26 0x000000000074ca18 in PortalRun (portal=portal@entry=0x2a34050,
count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=1 '\001',
run_once=run_once@entry=1 '\001', dest=dest@entry=0x2d484f0,
altdest=altdest@entry=0x2d484f0,
completionTag=completionTag@entry=0x7ffc8dad21c0 "") at pquery.c:773
#27 0x000000000074875b in exec_simple_query (
query_string=0x2a99060 "select\r\n\tsum(l_extendedprice* (1 - l_discount))
as revenue\r\nfrom\r\n\tlineitem,\r\n\tpart\r\nwhere\r\n\t(\r\n\t\tp_partkey =
l_partkey\r\n\t\tand p_brand = 'Brand#51'\r\n\t\tand p_container in ('SM CASE',
'SM BOX', 'SM PACK"...) at postgres.c:1099
#28 0x0000000000749a03 in PostgresMain (argc=<optimized out>,
argv=argv@entry=0x2a434f8, dbname=0x2a43388 "test", username=<optimized out>)
at postgres.c:4088
#29 0x000000000047665f in BackendRun (port=0x2a3c8c0) at postmaster.c:4357
#30 BackendStartup (port=0x2a3c8c0) at postmaster.c:4029
#31 ServerLoop () at postmaster.c:1753
#32 0x00000000006d70d9 in PostmasterMain (argc=argc@entry=3,
argv=argv@entry=0x2a14b20) at postmaster.c:1361
#33 0x00000000004774c1 in main (argc=3, argv=0x2a14b20) at main.c:228
-- Sent via pgsql-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
