From: Alexander Voytsekhovskyy <av@mobile-ua.com>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG in 10.1 - dsa_area could not attach to a segment that has been freed
Date: Thu, 7 Dec 2017 22:55:56 +0200
Message-ID: <21FE7F08-BFD3-47DB-8F68-184F02778273@gmail.com> (raw)
In-Reply-To: <CAEepm=0gw062AW2WgiZ5c7sfPU-aLUkv35AQg0PJO8ViRoPepA@mail.gmail.com>
References: <CAPa4P2a8Umtzh6Pxjbw-u40X0PGHbJ_Wfts1T6NEHwRhrB2xTg@mail.gmail.com>
<CAA4eK1Ld1fbROer6fY1BHUc=xWzpE1O3Ms3ZuRyWjLJGQ82P=g@mail.gmail.com>
<CAPa4P2Zbd_LowKj2puQUuUSVbJUfjQ+TMxnDbm9yRRjY7gG-ww@mail.gmail.com>
<CAA4eK1JsYq=mK43GzaijFZF5zM_poSNZBodOed3Qordap0mUiA@mail.gmail.com>
<CAPa4P2YzgRTBHHRx2KAPUO1_xkmqQgT2xP0tS_e=phWvNzWdkA@mail.gmail.com>
<5426a66a-c722-6a34-2de2-275c774345aa@2ndquadrant.com>
<CAPa4P2ZwSfGXZLjM5_666Lc2L1QG5MNBhRQyk42y0+2Xx4SDwQ@mail.gmail.com>
<46967194-cbb1-9a94-e39d-503c7c2ed417@2ndquadrant.com>
<CAPa4P2Y-UDiu2AD_Zf6Kapgu4Dkgb89BvtUZfRTWCRuRKptc=g@mail.gmail.com>
<CAEepm=1V-ZjAAyG-xj6s7ESXFhzLsRBpyX=BLz-w2DS=ObNu4A@mail.gmail.com>
<CAEepm=0gw062AW2WgiZ5c7sfPU-aLUkv35AQg0PJO8ViRoPepA@mail.gmail.com>
Hi,
i can confirm that this patch fix the bug for me.
I can’t provide minimal reproducer, but i can share whole data set with you
> On Thu, Nov 30, 2017 at 10:18 AM, Thomas Munro
> <thomas.munro@enterprisedb.com> wrote:
>> On Thu, Nov 30, 2017 at 9:34 AM, Alexander Voytsekhovskyy
>> <young.inbox@gmail.com> wrote:
>>> Thanks for helping, here is one more try
>>>
>>> #0 get_segment_by_index (area=area@entry=0x556026700be8, index=1) at
>>> /build/postgresql-10-qAeTPy/postgresql-10-10.1/build/../src/backend/utils/mmgr/dsa.c:1736
>>> #1 0x00005560252c2b90 in dsa_get_address (area=area@entry=0x556026700be8,
>>> dp=dp@entry=1099511685280) at
>>> /build/postgresql-10-qAeTPy/postgresql-10-10.1/build/../src/backend/utils/mmgr/dsa.c:945
>>> #2 0x00005560250a2c2b in tbm_attach_shared_iterate
>>> (dsa=dsa@entry=0x556026700be8, dp=1099511685280) at
>>> /build/postgresql-10-qAeTPy/postgresql-10-10.1/build/../src/backend/nodes/tidbitmap.c:1503
>>> #3 0x0000556025066c7b in BitmapHeapNext (node=node@entry=0x556026460710) at
>>> /build/postgresql-10-qAeTPy/postgresql-10-10.1/build/../src/backend/executor/nodeBitmapHeapscan.c:176
>>
>> Thank you for the report and the back trace. I think this might be a
>> manifestation of the problem I just described[1] on -hackers.
>> Depending on the shape of a multi-Gather query plan and therefore the
>> order of control flow, you might finish up using the DSA area that
>> belongs to a different Gather node and then find that it goes away too
>> soon. Investigating.
>
> I haven't managed to reproduce this, but I was coincidentally
> investigating a bug that appears to explain it. I think what happened
> is that a background worker was first to execute BitmapHeapNext and
> allocated a dsa_pointer, and then the leader process reached
> BitmapHeapNext and called tbm_attach_shared_iterate which tried to
> deference it, but it had es_query_dsa set to another gather node's DSA
> area (whichever Gather most recently ran ExecInitParallelPlan). That
> requires a certain order of execution and timing that I'm not sure how
> to reach. I have posted a patch that should fix it over here:
>
> https://www.postgresql.org/message-id/CAEepm%3D0Mv9BigJPpribGQhnHqVGYo2%2BkmzekGUVJJc9Y_ZVaYA%40mail...
>
> Are you able to provide a minimal reproducer, an anonymised partial
> dump, or perhaps try out the patch on a copy of your database?
>
> --
> Thomas Munro
> http://www.enterprisedb.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: av@mobile-ua.com, thomas.munro@enterprisedb.com, tomas.vondra@2ndquadrant.com, amit.kapila16@gmail.com
Subject: Re: BUG in 10.1 - dsa_area could not attach to a segment that has been freed
In-Reply-To: <21FE7F08-BFD3-47DB-8F68-184F02778273@gmail.com>
References: <CAPa4P2a8Umtzh6Pxjbw-u40X0PGHbJ_Wfts1T6NEHwRhrB2xTg@mail.gmail.com> <CAA4eK1Ld1fbROer6fY1BHUc=xWzpE1O3Ms3ZuRyWjLJGQ82P=g@mail.gmail.com> <CAPa4P2Zbd_LowKj2puQUuUSVbJUfjQ+TMxnDbm9yRRjY7gG-ww@mail.gmail.com> <CAA4eK1JsYq=mK43GzaijFZF5zM_poSNZBodOed3Qordap0mUiA@mail.gmail.com> <CAPa4P2YzgRTBHHRx2KAPUO1_xkmqQgT2xP0tS_e=phWvNzWdkA@mail.gmail.com> <5426a66a-c722-6a34-2de2-275c774345aa@2ndquadrant.com> <CAPa4P2ZwSfGXZLjM5_666Lc2L1QG5MNBhRQyk42y0+2Xx4SDwQ@mail.gmail.com> <46967194-cbb1-9a94-e39d-503c7c2ed417@2ndquadrant.com> <CAPa4P2Y-UDiu2AD_Zf6Kapgu4Dkgb89BvtUZfRTWCRuRKptc=g@mail.gmail.com> <CAEepm=1V-ZjAAyG-xj6s7ESXFhzLsRBpyX=BLz-w2DS=ObNu4A@mail.gmail.com> <CAEepm=0gw062AW2WgiZ5c7sfPU-aLUkv35AQg0PJO8ViRoPepA@mail.gmail.com> <21FE7F08-BFD3-47DB-8F68-184F02778273@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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