From: Robert Haas Date: Thu, 21 Dec 2017 14:09:04 +0000 (-0500) Subject: Cancel CV sleep during subtransaction abort. X-Git-Tag: REL_11_BETA1~1046 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59d1e2b95a826869e2789ffe01e9e552148eefde;p=postgresql Cancel CV sleep during subtransaction abort. Generally, error recovery paths that need to do things like LWLockReleaseAll and pgstat_report_wait_end also need to call ConditionVariableCancelSleep, but AbortSubTransaction was missed. Since subtransaction abort might destroy up the DSM segment that contains the ConditionVariable stored in cv_sleep_target, this can result in a crash for anything using condition variables. Reported and diagnosed by Andres Freund. Discussion: http://postgr.es/m/20171221110048.rxk6464azzl5t2fi@alap3.anarazel.de --- diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index e93d740b21..d430e662e6 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -4717,6 +4717,9 @@ AbortSubTransaction(void) /* Reset WAL record construction state */ XLogResetInsertion(); + /* Cancel condition variable sleep */ + ConditionVariableCancelSleep(); + /* * Also clean up any open wait for lock, since the lock manager will choke * if we try to wait for another lock before doing this.