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 1gRWQJ-0002HE-M1 for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Nov 2018 06:00:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gRWQI-0003jg-Ff for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Nov 2018 06:00:38 +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 1gRWQI-0003ii-4n for pgsql-hackers@lists.postgresql.org; Tue, 27 Nov 2018 06:00:38 +0000 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gRWQE-0003S1-HK for pgsql-hackers@lists.postgresql.org; Tue, 27 Nov 2018 06:00:36 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id wAR60V8f027219; Tue, 27 Nov 2018 15:00:31 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 805D9EA7C43; Tue, 27 Nov 2018 15:00:31 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 75365EA7BED; Tue, 27 Nov 2018 15:00:31 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 6FDE6400682; Tue, 27 Nov 2018 15:00:31 +0900 (JST) Subject: Re: Inadequate executor locking of indexes References: <19465.1541636036@sss.pgh.pa.us> <3046.1542990312@sss.pgh.pa.us> <4048acfe-82b0-55f3-48d0-9e686b933171@lab.ntt.co.jp> From: Amit Langote Message-ID: <31575bce-fbcd-530d-1f97-455c7959cd73@lab.ntt.co.jp> Date: Tue, 27 Nov 2018 15:00:20 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: David Rowley Cc: Tom Lane , PostgreSQL Hackers , Rushabh Lathia X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018/11/27 6:19, David Rowley wrote: > On Mon, 26 Nov 2018 at 18:57, Amit Langote > wrote: >> On 2018/11/26 14:25, David Rowley wrote: >>> I'm making efforts to delay per-partition work even further in the >>> executor, for example locking of the per-partition result relations >>> until after run-time pruning would be a significant win for >>> partitioned tables with many partitions when generic plans are in use. >>> Moving things back to InitPlan() flies in the face of that work. >>> >>> [1] https://commitfest.postgresql.org/20/1778/ >> >> That's an interesting point. Although, considering the concerns that Tom >> raised about the same index relation being locked such that lock-strength >> upgrade occurs (his example containing two CTEs), we'll have to find a way >> to do the ModifyTable run-time pruning such that result relations and >> their indexes (possibly under multiple ModifyTable nodes) are locked with >> RowExclusiveLock before they're locked with AccessShareLock lock as scan >> relations. For example, we might be able to find a way to do the >> ModifyTable run-time pruning in InitPlan before initializing plan trees. > > I thought my idea of the processing the rangetable at the end of > planning to determine the strongest lock per relation would have > solved that. Yeah, would be nice to make that work. Thanks, Amit