Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRyat-00012I-70 for pgsql-committers@arkaria.postgresql.org; Thu, 21 Dec 2017 11:00:55 +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 1eRyas-0006Mj-JC for pgsql-committers@arkaria.postgresql.org; Thu, 21 Dec 2017 11:00:54 +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 1eRyar-0006MW-Vz; Thu, 21 Dec 2017 11:00:54 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eRyap-0003Rp-Od; Thu, 21 Dec 2017 11:00:52 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 6740D20B96; Thu, 21 Dec 2017 06:00:50 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Thu, 21 Dec 2017 06:00:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=wS/ifp27UiMyl107UEVaO5EUnbc4z /dMZF5DLYbnA0c=; b=jn8ACTllMOnl0nlMUart1VkGpKNBKeKo/mKGDvlEwVOf9 SUyusLPYWPU6E/9nThG6rRp+VnirOYPOg7btycNYAJKXCTZlsxg1J0Sk63GnLmxm IdwxKCSBQ4SBvmMTyZyvmkL6vDLK574SAPeIazqKbqiMFAx9ZAauD/bgLRqf/C3U fMxIktQ4zKc3Ay4ZG7yRcxgoxr/Eer0ZZb1XOTOF/U0txEbDM9fMfF+HjkZ1HISi +/udGslvFzn9hTmdmiuHqmMIB+wcnMDRwr3HtwvYY5uUW9pDKX7V6v/sjFb8GS4D kjFFVeJqF6vEHwnDJ8vg02udo4kEON+7Qux5v+OdQ== X-ME-Sender: Received: from intern.anarazel.de (p5de63f33.dip0.t-ipconnect.de [93.230.63.51]) by mail.messagingengine.com (Postfix) with ESMTPA id 153E67E53A; Thu, 21 Dec 2017 06:00:50 -0500 (EST) Date: Thu, 21 Dec 2017 03:00:48 -0800 From: Andres Freund To: pgsql-hackers@postgresql.org, pgsql-committers@postgresql.org, Thomas Munro , Robert Haas Subject: condition variable cleanup and subtransactions Message-ID: <20171221110048.rxk6464azzl5t2fi@alap3.anarazel.de> References: <20171221092940.gbxcszbzsr5khsfr@alap3.anarazel.de> <20171221095550.d3e7xhoakcowhu5b@alap3.anarazel.de> <20171221104225.w46zgr3w4f2mowls@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171221104225.w46zgr3w4f2mowls@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2017-12-21 02:42:25 -0800, Andres Freund wrote: > Trying to debug this I found another issue. I'd placed a sleep(10) in > ExecParallelHashCloseBatchAccessors() and then ctrl-c'ed the server for > some reason. Segfault time: > > #0 0x000055bfbac42539 in tas (lock=0x7fcd82ae14ac ) at /home/andres/src/postgresql/src/include/storage/s_lock.h:228 > #1 0x000055bfbac42b4d in ConditionVariableCancelSleep () at /home/andres/src/postgresql/src/backend/storage/lmgr/condition_variable.c:173 > #2 0x000055bfba8e24ae in AbortTransaction () at /home/andres/src/postgresql/src/backend/access/transam/xact.c:2478 > #3 0x000055bfba8e4a2a in AbortOutOfAnyTransaction () at /home/andres/src/postgresql/src/backend/access/transam/xact.c:4387 > So, afaics no workers had yet attached, the leader accepted the cancel > interrupt, the dsm segments were destroyed, and as part of cleanup > cv_sleep_target was supposed to be reset, which fails, because it's > memory has since been freed. Looking at how that can happen. Oh. This seems to be a condition variable bug independent of PHJ. The problem is that the DSM segment etc all get cleaned up in *subtransaction* abort. Afaict it's a bug that AbortTransaction() does ConditionVariableCancelSleep() but AbortSubTransaction() does not, despite the latter releasing dsm segments via ResourceOwnerRelease(RESOURCE_RELEASE_BEFORE_LOCKS). Adding that seems to fix the crash. This seems like something we need to backpatch. Greetings, Andres Freund