From: Andres Freund <andres@anarazel.de>
To: pgsql-hackers@postgresql.org, pgsql-committers@postgresql.org, Thomas Munro <thomas.munro@enterprisedb.com>
To: Robert Haas <robertmhaas@gmail.com>
Subject: condition variable cleanup and subtransactions
Date: Thu, 21 Dec 2017 03:00:48 -0800
Message-ID: <20171221110048.rxk6464azzl5t2fi@alap3.anarazel.de> (raw)
In-Reply-To: <20171221104225.w46zgr3w4f2mowls@alap3.anarazel.de>
References: <E1eRwXy-0004IK-TO@gemulon.postgresql.org>
<20171221092940.gbxcszbzsr5khsfr@alap3.anarazel.de>
<20171221095550.d3e7xhoakcowhu5b@alap3.anarazel.de>
<20171221104225.w46zgr3w4f2mowls@alap3.anarazel.de>
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 <error: Cannot access memory at address 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
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-committers@postgresql.org
Cc: andres@anarazel.de, thomas.munro@enterprisedb.com, robertmhaas@gmail.com
Subject: Re: condition variable cleanup and subtransactions
In-Reply-To: <20171221110048.rxk6464azzl5t2fi@alap3.anarazel.de>
References: <E1eRwXy-0004IK-TO@gemulon.postgresql.org> <20171221092940.gbxcszbzsr5khsfr@alap3.anarazel.de> <20171221095550.d3e7xhoakcowhu5b@alap3.anarazel.de> <20171221104225.w46zgr3w4f2mowls@alap3.anarazel.de> <20171221110048.rxk6464azzl5t2fi@alap3.anarazel.de>
* 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