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 1gVJq6-0003sU-G9 for pgsql-bugs@arkaria.postgresql.org; Fri, 07 Dec 2018 17:22:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gVJq4-0004Vw-Sf for pgsql-bugs@arkaria.postgresql.org; Fri, 07 Dec 2018 17:22:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gVJq4-0004Vp-JT for pgsql-bugs@lists.postgresql.org; Fri, 07 Dec 2018 17:22:56 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gVJpx-0005qv-EG for pgsql-bugs@lists.postgresql.org; Fri, 07 Dec 2018 17:22:55 +0000 Received: by mail-qt1-x841.google.com with SMTP id t13so5314111qtn.3 for ; Fri, 07 Dec 2018 09:22:49 -0800 (PST) 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:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=+SzfWxoGT80E3xlT9FAprQDUNtw7tW7kvapFfsSKL5U=; b=j+uk+lZdhi/jbryDfpoXYD8c24yhUaMEAcb+MiG2OpCrZDP3+CVHHyKKNgGcgHER+E 6eY24r/N4Walrry83ok2arWetUYc6o+Pcz5Cy0T6oKVs9jQ66MdgcmmROm2TwAHK8f3Y A76FJsdZ7pI0HJFJ4G6dCIHeppX3M0kcpaTsmVT630rLZGNmQb0ZsF0YVknSCshpN/nH 5puQtIMQkjpTIlp57PPJTGRFidosG8nrfC5ILpSbTjYtgPenacn4N817TngSo2z+KT/T RzSFJ6Hs1N2Jls62oZMHktB9xNf75ZfX++7Q7nUh5LOarNme/nMIM0opm0OG1QiEm+Z1 Veeg== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=+SzfWxoGT80E3xlT9FAprQDUNtw7tW7kvapFfsSKL5U=; b=cJ2ruMO3NKnCrmTZCjc8txOvrEXUe5rdJ7ZLQ+g4WlZW/apGjNt577US5o5JsJOwFe ebS59P+cggQTDpBLmycL4wqqEu3650jc51iDm/tZqEfssr9lON3NSk2LEX1Zweeb5n5F ovI2NBcXrL3Vzk+6mSExvB4mMGPzp9L8osJ5tOz6m0IWdNih2Kv4OOJixXBC3thcaKiy hv2QwEbV11U1aYmQU+QH0VwtA85vKgCKenIzimxdAhey5zNb2LuK1WhfK03HsVbsb0ht gotusky1/aUoPbpIwlAEZ5dykSlAsgRcOiJB2RMug1f4PuqwjVePDD10ZWQ5g7N/L8Da Es7g== X-Gm-Message-State: AA+aEWahRWX4lVCTDhnsemScnZoe2O1tCEUpEGm7nOfzo20CLucfKkNj w34UqG0K6++ADEuD8OXzn5ZOqw== X-Google-Smtp-Source: AFSGD/WHCtf8fIx3jVw7mxCkLN0vioBbwSMZJpy/G29+DbrSsTNEqBIX3sv8PZ0Y3xWCCXy4X5JdWQ== X-Received: by 2002:ac8:43d0:: with SMTP id w16mr2919906qtn.78.1544203368545; Fri, 07 Dec 2018 09:22:48 -0800 (PST) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id m41sm3671280qtc.58.2018.12.07.09.22.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 09:22:48 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 341AB49B; Fri, 7 Dec 2018 14:22:46 -0300 (-03) Date: Fri, 7 Dec 2018 14:22:46 -0300 From: Alvaro Herrera To: Tom Lane Cc: bianpan2016@163.com, pgsql-bugs@lists.postgresql.org, Oleksandr Shulgin Subject: Re: BUG #15540: Use after release in ExecuteTruncateGuts Message-ID: <20181207172246.3bdayfkuni6cbqks@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <31125.1544198945@sss.pgh.pa.us> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Dec-07, Tom Lane wrote: > =?utf-8?q?PG_Bug_reporting_form?= writes: > > The function ExecuteTruncateGuts drops the reference to rel via > > relation_close when toast_relid is valid. However, after that, rel is passed > > to pgstat_count_truncate. This may result in a use-after-release bug. > > ... and, even more to the point, the truncation stats count is incorrectly > applied to the toast table not its parent. Whoops! Thanks for fixing. You're right, we quite likely didn't specifically test the case of there being a toast table. Amazing that it took so long to find it. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services