Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eN3j1-0006H6-Jc for pgsql-bugs@arkaria.postgresql.org; Thu, 07 Dec 2017 21:28:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eN3j1-0008LV-11 for pgsql-bugs@arkaria.postgresql.org; Thu, 07 Dec 2017 21:28:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eN3DB-0004dr-8K for pgsql-bugs@lists.postgresql.org; Thu, 07 Dec 2017 20:56:05 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eN3D7-0005da-Na for pgsql-bugs@lists.postgresql.org; Thu, 07 Dec 2017 20:56:03 +0000 Received: by mail-wm0-x242.google.com with SMTP id n138so140267wmg.2 for ; Thu, 07 Dec 2017 12:56:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mobile-ua-com.20150623.gappssmtp.com; s=20150623; h=from:mime-version:subject:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=F0ahaH+HdcJJlK9f7IAJmTHo7aFSkQ5ETjgXdsLKlWI=; b=sFhEOFgIYu5JC39H6XBsibH9FkMLGTq6pdFBy5qArf/TI7ya7z5nnUmAUI8bezJayB 6Xr42uPqNQlEFPk/TSo9RTCyJlrCjzAooQFdRojzslN2C4OE00JliDYnRcC2q7N/se0Z G6jqoYMXBA5WQdQBDucVuczlp5Dz9R7w4mE0nqgCXQkHcdjs6gYOIQeB0cv4Ibtuq61D C+IPGMHoFcjgWdK7CKHlF4Xj4O4jQ5GUNQwAT9+aw2k1FXko17GzRGf1bpks0/RLHQ1w peuXpsyEr6AHtSpmX2G7cKBXhsFQCaFSp86sCuUDn1hi7EAIcIHHUM3TCl8oilXh+aV7 6sGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=F0ahaH+HdcJJlK9f7IAJmTHo7aFSkQ5ETjgXdsLKlWI=; b=Vx+aoMnBrU0w8tgXzxoWJAYFRGU42bmqlnOve/tIVR+VeM0qNN8mjH+4vA9vB8Wm+x FQwlYc6myNcZxTw5ziulOUmESbyZvlvwS5uW8xAH58ashhrvy1TWwxbMVTLatVoh1swm YUZd5Jcg7QKdAl0JnFKdbmNIjQz6hVn0/7UbgjtA0ZNqFqDvLAkmGzbLVCq9Ru+mJSzw GdgwJPKW84QtSxcpyOuz+bWDiVxMbnWPsYmlGXdDA+6Ag2vTgwoLcgsY7LzWfSCKxvyH Nr9t0uPONzShIsqpbxqqz5Ouz3ACbS9n3y8SotQsVC2pEMTPDGxWaL7K1fe+XSDeZxOq r5rg== X-Gm-Message-State: AKGB3mILrhtqb2fQD4/lJgOpiEM7Dk3XP0JGDcY5EOYAvLgHqMRT8epJ qnN6ZbLE644jA+RIr1+ciKJx+w== X-Google-Smtp-Source: AGs4zMauoZplQQdUkdiYoudimJIF2yU/kYOSYHnxQlWtB/Xzb0oRYuenQ+KI72mPhHl5BX635tbSqQ== X-Received: by 10.28.108.3 with SMTP id h3mr2066158wmc.129.1512680159331; Thu, 07 Dec 2017 12:55:59 -0800 (PST) Received: from c59d-2c8f-faee-4449-d180-8330-07d0-2001.dyn.estpak.ee (c59d-2c8f-faee-4449-d180-8330-07d0-2001.dyn.estpak.ee. [2001:7d0:8330:d180:4449:faee:2c8f:c59d]) by smtp.gmail.com with ESMTPSA id k30sm7134224wrf.63.2017.12.07.12.55.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 12:55:58 -0800 (PST) From: Alexander Voytsekhovskyy X-Google-Original-From: Alexander Voytsekhovskyy Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.1 \(3445.4.7\)) Subject: Re: BUG in 10.1 - dsa_area could not attach to a segment that has been freed In-Reply-To: Date: Thu, 7 Dec 2017 22:55:56 +0200 Cc: Tomas Vondra , Amit Kapila , pgsql-bugs@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <21FE7F08-BFD3-47DB-8F68-184F02778273@gmail.com> References: <5426a66a-c722-6a34-2de2-275c774345aa@2ndquadrant.com> <46967194-cbb1-9a94-e39d-503c7c2ed417@2ndquadrant.com> To: Thomas Munro X-Mailer: Apple Mail (2.3445.4.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, i can confirm that this patch fix the bug for me. I can=E2=80=99t provide minimal reproducer, but i can share whole data = set with you > On Thu, Nov 30, 2017 at 10:18 AM, Thomas Munro > wrote: >> On Thu, Nov 30, 2017 at 9:34 AM, Alexander Voytsekhovskyy >> wrote: >>> Thanks for helping, here is one more try >>>=20 >>> #0 get_segment_by_index (area=3Darea@entry=3D0x556026700be8, = index=3D1) at >>> = /build/postgresql-10-qAeTPy/postgresql-10-10.1/build/../src/backend/utils/= mmgr/dsa.c:1736 >>> #1 0x00005560252c2b90 in dsa_get_address = (area=3Darea@entry=3D0x556026700be8, >>> dp=3Ddp@entry=3D1099511685280) 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=3Ddsa@entry=3D0x556026700be8, dp=3D1099511685280) at >>> = /build/postgresql-10-qAeTPy/postgresql-10-10.1/build/../src/backend/nodes/= tidbitmap.c:1503 >>> #3 0x0000556025066c7b in BitmapHeapNext = (node=3Dnode@entry=3D0x556026460710) at >>> = /build/postgresql-10-qAeTPy/postgresql-10-10.1/build/../src/backend/execut= or/nodeBitmapHeapscan.c:176 >>=20 >> 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. >=20 > 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: >=20 > = https://www.postgresql.org/message-id/CAEepm%3D0Mv9BigJPpribGQhnHqVGYo2%2B= kmzekGUVJJc9Y_ZVaYA%40mail.gmail.com >=20 > Are you able to provide a minimal reproducer, an anonymised partial > dump, or perhaps try out the patch on a copy of your database? >=20 > --=20 > Thomas Munro > http://www.enterprisedb.com