Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnIj0-0001RL-Mh for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jul 2019 08:22:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hnIiz-0001vu-HM for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jul 2019 08:22:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnIiz-0001vm-3p for pgsql-hackers@lists.postgresql.org; Tue, 16 Jul 2019 08:22:13 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnIiv-0007oo-OE for pgsql-hackers@postgresql.org; Tue, 16 Jul 2019 08:22:12 +0000 Received: by mail-wr1-x442.google.com with SMTP id x4so19865752wrt.6 for ; Tue, 16 Jul 2019 01:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pSndEgsngwuOvBwaVDj6Cy4MGN4LSdSygOs5OOjT1EA=; b=C374wdoT1SdwZgh4xijjhh556MzOGg9a9bCDx9Xcj6m7to4GCPte1SiaRwS5Ay+UKc i4j2G5UEdX2yGFCEFbdjmCU4ToT2sbPD003HvfHUCpOo1qNow0d+FyLvTeAi/n2vrpRQ 2yFiam0Fo90T6zbPtCIyMzCruawWpHe7hxJmwGanMUGmZHXSqizkc6TcMwtp3BHkrmDC /Q7pHxsERQvBhWPfbv02DkzHV+sAV0PGRH0Wb3y/QT6rGvL6y9KJLTmjVneK1HihlFI+ 3tJzndulZMFE8M0lvb1lxYEy9yA9baRIGXoKBxkKWkq+pVPWpwHRnJGsOuWSvpqeqE60 Hyuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pSndEgsngwuOvBwaVDj6Cy4MGN4LSdSygOs5OOjT1EA=; b=cudB651MYDQcnlHdIY5onQ0XdFNEf4o798WbvXwo5m6HUGdIEeM3/+baRbSKwP+ioT Kk75f1K6+b475mcPFc5CL+fN2cwgcl4mVHRNcmRUbAkhUyKelFiIRuhLGn9UqOdK2DJW XrwlwHbzYf43/tudN6vAhxWJmKYzdA1rd3cD2auYRH0P0XXaXINOAqL9ixKzzFWQW9m3 B3p/hwc0gaYQU10WjAZc9gh7JTRLrZkaEZ/ByMve+yNvR9YqG4SqRMDt4GqYa86K/10h VnwwdYWxkA//BtWxCqUN6kFb7XnsulmOPMA64u4J7rgPJSKNqy53J0tbuerHEF5Jwp0c 9jyw== X-Gm-Message-State: APjAAAWmTdxOrmBssgbYhoLNJD89zLXdM/NYN/kEfEw5/OJaeaTOCIpg sNj1a/IyeZz1iUcJszKHHwsANA== X-Google-Smtp-Source: APXvYqyfKrtr/lh58ywHBu8kIEkX1+U2jXdraRAZ1q9olQc6wiUdK9asNbD+7rbEGdbidAqbkYWZkA== X-Received: by 2002:adf:f888:: with SMTP id u8mr6798449wrp.238.1563265328508; Tue, 16 Jul 2019 01:22:08 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id g131sm13791037wmf.37.2019.07.16.01.22.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 01:22:05 -0700 (PDT) Date: Tue, 16 Jul 2019 10:22:04 +0200 From: Tomas Vondra To: Jerry Sievers Cc: pgsql-hackers@postgresql.org Subject: Re: SegFault on 9.6.14 Message-ID: <20190716082204.iecyfh6mhu6khdhz@development> References: <87ims2amh6.fsf@jsievers.enova.com> <20190716001529.uvpfngvxtlu5h2fr@development> <87blxuakv4.fsf@jsievers.enova.com> <20190716003449.fjegtxinhrqubysu@development> <87ftn6ojwf.fsf@jsievers.enova.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <87ftn6ojwf.fsf@jsievers.enova.com> User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Jul 15, 2019 at 08:20:00PM -0500, Jerry Sievers wrote: >Tomas Vondra writes: > >> On Mon, Jul 15, 2019 at 07:22:55PM -0500, Jerry Sievers wrote: >> >>>Tomas Vondra writes: >>> >>>> On Mon, Jul 15, 2019 at 06:48:05PM -0500, Jerry Sievers wrote: >>>> >>>>>Greetings Hackers. >>>>> >>>>>We have a reproduceable case of $subject that issues a backtrace such as >>>>>seen below. >>>>> >>>>>The query that I'd prefer to sanitize before sending is <30 lines of at >>>>>a glance, not terribly complex logic. >>>>> >>>>>It nonetheless dies hard after a few seconds of running and as expected, >>>>>results in an automatic all-backend restart. >>>>> >>>>>Please advise on how to proceed. Thanks! >>>>> >>>>>bt >>>>>#0 initscan (scan=scan@entry=0x55d7a7daa0b0, key=0x0, keep_startblock=keep_startblock@entry=1 '\001') >>>>> at /build/postgresql-9.6-5O8OLM/postgresql-9.6-9.6.14/build/../src/backend/access/heap/heapam.c:233 >>>>>#1 0x000055d7a72fa8d0 in heap_rescan (scan=0x55d7a7daa0b0, key=key@entry=0x0) at /build/postgresql-9.6-5O8OLM/postgresql-9.6-9.6.14/build/../src/backend/access/heap/heapam.c:1529 >>>>>#2 0x000055d7a7451fef in ExecReScanSeqScan (node=node@entry=0x55d7a7d85100) at /build/postgresql-9.6-5O8OLM/postgresql-9.6-9.6.14/build/../src/backend/executor/nodeSeqscan.c:280 >>>>>#3 0x000055d7a742d36e in ExecReScan (node=0x55d7a7d85100) at /build/postgresql-9.6-5O8OLM/postgresql-9.6-9.6.14/build/../src/backend/executor/execAmi.c:158 >>>>>#4 0x000055d7a7445d38 in ExecReScanGather (node=node@entry=0x55d7a7d84d30) at /build/postgresql-9.6-5O8OLM/postgresql-9.6-9.6.14/build/../src/backend/executor/nodeGather.c:475 >>>>>#5 0x000055d7a742d255 in ExecReScan (node=0x55d7a7d84d30) at /build/postgresql-9.6-5O8OLM/postgresql-9.6-9.6.14/build/../src/backend/executor/execAmi.c:166 >>>>>#6 0x000055d7a7448673 in ExecReScanHashJoin (node=node@entry=0x55d7a7d84110) at /build/postgresql-9.6-5O8OLM/postgresql-9.6-9.6.14/build/../src/backend/executor/nodeHashjoin.c:1019 >>>>>#7 0x000055d7a742d29e in ExecReScan (node=node@entry=0x55d7a7d84110) at /build/postgresql-9.6-5O8OLM/postgresql-9.6-9.6.14/build/../src/backend/executor/execAmi.c:226 >>>>> >>>>> >>>> >>>> Hmmm, that means it's crashing here: >>>> >>>> if (scan->rs_parallel != NULL) >>>> scan->rs_nblocks = scan->rs_parallel->phs_nblocks; <--- here >>>> else >>>> scan->rs_nblocks = RelationGetNumberOfBlocks(scan->rs_rd); >>>> >>>> But clearly, scan is valid (otherwise it'd crash on the if condition), >>>> and scan->rs_parallel must me non-NULL. Which probably means the pointer >>>> is (no longer) valid. >>>> >>>> Could it be that the rs_parallel DSM disappears on rescan, or something >>>> like that? >>> >>>No clue but something I just tried was to disable parallelism by setting >>>max_parallel_workers_per_gather to 0 and however the query has not >>>finished after a few minutes, there is no crash. >>> >> >> That might be a hint my rough analysis was somewhat correct. The >> question is whether the non-parallel plan does the same thing. Maybe it >> picks a plan that does not require rescans, or something like that. >> >>>Please advise. >>> >> >> It would be useful to see (a) exacution plan of the query, (b) full >> backtrace and (c) a bit of context for the place where it crashed. >> >> Something like (in gdb): >> >> bt full >> list >> p *scan > >The p *scan did nothing unless I ran it first however my gdb $foo isn't >strong presently. Hmm, the rs_parallel pointer looks sane (it's not obvious garbage). Can you try this? p *scan->rs_parallel Another question - are you sure this is not an OOM issue? That might sometimes look like SIGSEGV due to overcommit. What's the memory consumption / is there anything in dmesg? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services