Re: [HACKERS] Parallel Bitmap Heap Scans segfaults due to(tbm->dsa==NULL) on PostgreSQL 10 - Mailing list pgsql-hackers

From Dilip Kumar
Subject Re: [HACKERS] Parallel Bitmap Heap Scans segfaults due to(tbm->dsa==NULL) on PostgreSQL 10
Date
Msg-id CAFiTN-t8udQJ=-7qimazpwhCVhRTkXo=OTCX5wr-ZhPeae7W+Q@mail.gmail.com
Whole thread Raw
In response to [HACKERS] Parallel Bitmap Heap Scans segfaults due to (tbm->dsa==NULL) onPostgreSQL 10  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Responses Re: [HACKERS] Parallel Bitmap Heap Scans segfaults due to(tbm->dsa==NULL) on PostgreSQL 10
List pgsql-hackers
On Thu, Oct 12, 2017 at 4:31 PM, Tomas Vondra
<tomas.vondra@2ndquadrant.com> wrote:
> 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.
>
I think I have got the issue, bitmap_subplan_mark_shared is not
properly pushing the isshared flag to lower level bitmap index node,
and because of that tbm_create is passing NULL dsa while creating the
tidbitmap.  So this problem will come in very specific combination of
BitmapOr and BitmapAnd when BitmapAnd is the first subplan for the
BitmapOr.  If BitmapIndex is the first subplan under BitmapOr then
there is no problem because BitmapOr node will create the tbm by
itself and isshared is set for BitmapOr.

Attached patch fixing the issue for me.  I will thoroughly test this
patch with other scenario as well.  Thanks for reporting.


-- 
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: [HACKERS] Parallel Bitmap Heap Scans segfaults due to (tbm->dsa==NULL) onPostgreSQL 10
Next
From: Tomas Vondra
Date:
Subject: Re: [HACKERS] Parallel Bitmap Heap Scans segfaults due to(tbm->dsa==NULL) on PostgreSQL 10