Re: SegFault on 9.6.14 - Mailing list pgsql-hackers

From Jerry Sievers
Subject Re: SegFault on 9.6.14
Date
Msg-id 877e8ha71r.fsf@jsievers.enova.com
Whole thread Raw
In response to Re: SegFault on 9.6.14  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers
Thomas Munro <thomas.munro@gmail.com> writes:

> On Wed, Jul 17, 2019 at 11:06 AM Jerry Sievers <gsievers19@comcast.net> wrote:
>
>> (gdb) p *scan->rs_parallel
>> Cannot access memory at address 0x7fa673a54108
>
> So I guess one question is: was it a valid address that's been
> unexpectedly unmapped, or is the pointer corrupted?  Any chance you
> can strace the backend and pull out the map, unmap calls?

I'll dig further.

Here is a sanitized look at the query and explain plan...

The segfault happens $immediately upon issuance of the query.





begin;

-- This setting makes the segfault go away
--set local max_parallel_workers_per_gather to 0;

explain
select v.account_id, COUNT(cnt.clicks), te.description,
l.product_id
from thing3.thing10 te
join thing3.thing9 pv on pv.page_view_id = te.page_view_id
join thing3.thing11 v on v.visit_id = pv.visit_id
left join thing6.thing12 l on v.account_id=l.account_id
  left join lateral (
    select MAX(v.visit_id)
         ,COUNT(*) as clicks
         from thing3.thing10 te
         join thing3.thing9 pv on pv.page_view_id =
te.page_view_id
         join thing3.thing11 v on v.visit_id = pv.visit_id
         where te.description in ('thing7',
'thing8')
           and v.account_id=l.account_id
         GROUP BY v.account_id, v.visit_id
         order by v.account_id, v.visit_id desc
         limit 1
    )cnt on true
where (te.description in ('thing4',
'thing5')
         or te.description like'%auto%')
  and te.created_at > '2019-06-24 00:00:00'
--and l.loan_status_id in (5,6)
group by v.account_id, te.description,
l.product_id;

abort;
BEGIN

   QUERY PLAN
                 
 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 GroupAggregate  (cost=12300178.71..12300179.79 rows=48 width=44)
   Group Key: v.account_id, te.description, l.product_id
   ->  Sort  (cost=12300178.71..12300178.83 rows=48 width=44)
         Sort Key: v.account_id, te.description, l.product_id
         ->  Nested Loop Left Join  (cost=251621.81..12300177.37 rows=48 width=44)
               ->  Gather  (cost=1001.55..270403.27 rows=48 width=40)
                     Workers Planned: 3
                     ->  Nested Loop Left Join  (cost=1.56..269398.47 rows=15 width=40)
                           ->  Nested Loop  (cost=1.13..269391.71 rows=14 width=32)
                                 ->  Nested Loop  (cost=0.57..269368.66 rows=39 width=32)
                                       ->  Parallel Seq Scan on thing10 te  (cost=0.00..269228.36 rows=39 width=32)
                                             Filter: ((created_at > '2019-06-24 00:00:00'::timestamp without time zone)
AND(((description)::text = ANY ('{thing4,thing5}'::text[])) OR ((description)::text ~~ '%auto%'::text)))
 
                                       ->  Index Scan using page_views_pkey on thing9 pv  (cost=0.57..3.59 rows=1
width=8)
                                             Index Cond: (page_view_id = te.page_view_id)
                                 ->  Index Scan using visits_pkey on thing11 v  (cost=0.56..0.58 rows=1 width=8)
                                       Index Cond: (visit_id = pv.visit_id)
                           ->  Index Scan using index_loans_on_account_id on thing12 l  (cost=0.42..0.46 rows=2
width=8)
                                 Index Cond: (v.account_id = account_id)
               ->  Limit  (cost=250620.25..250620.27 rows=1 width=20)
                     ->  GroupAggregate  (cost=250620.25..250620.27 rows=1 width=20)
                           Group Key: v_1.visit_id
                           ->  Sort  (cost=250620.25..250620.26 rows=1 width=8)
                                 Sort Key: v_1.visit_id DESC
                                 ->  Hash Join  (cost=1154.34..250620.24 rows=1 width=8)
                                       Hash Cond: (te_1.page_view_id = pv_1.page_view_id)
                                       ->  Gather  (cost=1000.00..250452.00 rows=3706 width=4)
                                             Workers Planned: 3
                                             ->  Parallel Seq Scan on thing10 te_1  (cost=0.00..249081.40 rows=1195
width=4)
                                                   Filter: ((description)::text = ANY ('{thing7,thing8}'::text[]))
                                       ->  Hash  (cost=152.85..152.85 rows=119 width=12)
                                             ->  Nested Loop  (cost=1.01..152.85 rows=119 width=12)
                                                   ->  Index Scan using index_visits_on_account_id on thing11 v_1
(cost=0.43..15.63rows=18 width=8)
 
                                                         Index Cond: (account_id = l.account_id)
                                                   ->  Index Scan using index_pv_on_visit on thing9 pv_1
(cost=0.57..7.55rows=7 width=8)
 
                                                         Index Cond: (visit_id = v_1.visit_id)
(35 rows)

ROLLBACK


-- 
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres.consulting@comcast.net



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: A little report on informal commit tag usage
Next
From: Jerry Sievers
Date:
Subject: Re: SegFault on 9.6.14