Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBjd3-0005TC-Qy for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2021 19:33:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lBjd2-0005Sl-F2 for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2021 19:33:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBjd1-0005Sc-UY for pgsql-hackers@lists.postgresql.org; Mon, 15 Feb 2021 19:33:52 +0000 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lBjcx-00010w-64 for pgsql-hackers@lists.postgresql.org; Mon, 15 Feb 2021 19:33:51 +0000 Received: by mail-io1-xd36.google.com with SMTP id y5so4100812ioc.2 for ; Mon, 15 Feb 2021 11:33:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=elbn0gGAXqBcaAmvh++jXF8j3a+7qqOSNkU/2ze0xEs=; b=l2cyS1RbVpD5COp0UOEt4EBs23JqpIQbAisZq5dglK6XvSMn3nGhSe6i/Y2aLHg3eV FmVhhLK1l0LC4rXjCD6At4tvXbmzo3OqhyH9J1DEGL58LMt0LwcxDWTDolA16qfuhXL2 P21ZpvD93+qXvLer6MxEb8RvbqLEhYE3bJNbWvn+ukMbYoCW0vvt/8VmncvCoXYTW7jF my7jKqXeQlxO5x/Br3TR1wLIU8MLe6PnQA9MM42oLjLqy3pqkUKm8pPEwa73ycog5682 /V5MTXlH7t1E86/Mk147F8agi1AeS9RQJUazA35ids/o3/rKTidAAgCBuD6WX2HspYws 0pRA== 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:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=elbn0gGAXqBcaAmvh++jXF8j3a+7qqOSNkU/2ze0xEs=; b=sC+NMQnURrdZqr5sioaORz4WdVDvwk+E+glvHYNXlsdGPSifnJkBfGciEoeXbVI3Oy wamjvld6WFH95aRvTjW2e9hQhy18hZmsD5nz2aQKrTMvJ5rZNd9aCIBB9sREc2EY2DyX r5woayNvL5tGYnJKkMhFUuYCa+STqcqYy/ORfXDh3wHTmK8X8mvaAUNjBFUhnigHGbh5 XFqvSCwB8tTXeyDklB9IjjLAdxZ04KJfadtqFKIC/sA1EBt6ppikfmZHVcxMnDj7LEq7 tcK0SPvZJ0hWI+bdg0sBhj7RYKfa0P9cqUBFfm2ReeZJGbiLwh/v8Is+0Tzy5uSFYqTm 3PKg== X-Gm-Message-State: AOAM531Y/SzSnLGOB1j68ayIO8mt1gAfZCAVsc7XVBi/2wMxpw57GMl5 2Z0mNXDITBWl4K1PXjNFd2eoJA== X-Google-Smtp-Source: ABdhPJxlyBubsoN9kLvodR8xV2RGQngMov0eqMIPzxgQSqAy7mnvd3SMWCta+pmP4W/3ATheQcNkmw== X-Received: by 2002:a02:9042:: with SMTP id y2mr16693330jaf.94.1613417625140; Mon, 15 Feb 2021 11:33:45 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id o131sm9687275ila.5.2021.02.15.11.33.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Feb 2021 11:33:44 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id EA6CF800A3B; Mon, 15 Feb 2021 13:33:41 -0600 (CST) Date: Mon, 15 Feb 2021 13:33:41 -0600 From: Justin Pryzby To: Anastasia Lubennikova Cc: Masahiko Sawada , Michael Paquier , =?utf-8?B?5p2O5p2wKOaFjui/vSk=?= , pgsql-hackers , =?utf-8?B?5pu+5paH5peMKOS5ieS7jik=?= , Alvaro Herrera Subject: Re: CREATE INDEX CONCURRENTLY on partitioned index Message-ID: <20210215193341.GD28165@telsasoft.com> References: <20201031063117.GF3080@telsasoft.com> <20201129202221.GA9477@telsasoft.com> <20210128143013.GC7450@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="QTprm0S8XgL7H0Dt" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --QTprm0S8XgL7H0Dt Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Mon, Feb 15, 2021 at 10:06:47PM +0300, Anastasia Lubennikova wrote: > On 28.01.2021 17:30, Justin Pryzby wrote: > > On Thu, Jan 28, 2021 at 09:51:51PM +0900, Masahiko Sawada wrote: > > > On Mon, Nov 30, 2020 at 5:22 AM Justin Pryzby wrote: > > > > On Sat, Oct 31, 2020 at 01:31:17AM -0500, Justin Pryzby wrote: > > > > > Forking this thread, since the existing CFs have been closed. > > > > > https://www.postgresql.org/message-id/flat/20200914143102.GX18552%40telsasoft.com#58b1056488451f8594b0f0ba40996afd > > > > > > > > > > The strategy is to create catalog entries for all tables with indisvalid=false, > > > > > and then process them like REINDEX CONCURRENTLY. If it's interrupted, it > > > > > leaves INVALID indexes, which can be cleaned up with DROP or REINDEX, same as > > > > > CIC on a plain table. > > > > > > > > > > On Sat, Aug 08, 2020 at 01:37:44AM -0500, Justin Pryzby wrote: > > > > > > On Mon, Jun 15, 2020 at 09:37:42PM +0900, Michael Paquier wrote: > > > > > > Note that the mentioned problem wasn't serious: there was missing index on > > > > > > child table, therefor the parent index was invalid, as intended. However I > > > > > > agree that it's not nice that the command can fail so easily and leave behind > > > > > > some indexes created successfully and some failed some not created at all. > > > > > > > > > > > > But I took your advice initially creating invalid inds. > > > > > ... > > > > > > That gave me the idea to layer CIC on top of Reindex, since I think it does > > > > > > exactly what's needed. > > > > > On Sat, Sep 26, 2020 at 02:56:55PM -0500, Justin Pryzby wrote: > > > > > > On Thu, Sep 24, 2020 at 05:11:03PM +0900, Michael Paquier wrote: > > > > > > > It would be good also to check if > > > > > > > we have a partition index tree that maps partially with a partition > > > > > > > table tree (aka no all table partitions have a partition index), where > > > > > > > these don't get clustered because there is no index to work on. > > > > > > This should not happen, since a incomplete partitioned index is "invalid". > > > > > > > I had been waiting to rebase since there hasn't been any review comments and I > > > > > > expected additional, future conflicts. > > > > > > > > I attempted to review this feature, but the last patch conflicts with the > recent refactoring, so I wasn't able to test it properly. > Could you please send a new version? I rebased this yesterday, so here's my latest. > 2) Here we access relation field after closing the relation. Is it safe? >     /* save lockrelid and locktag for below */ >     heaprelid = rel->rd_lockInfo.lockRelId; Thanks, fixed this just now. > 3) leaf_partitions() function only handles indexes, so I suggest to name it > more specifically and add a comment about meaning of 'options' parameter. > > 4) I don't quite understand the idea of the regression test. Why do we > expect to see invalid indexes there? > +    "idxpart_a_idx1" UNIQUE, btree (a) INVALID Because of the unique failure: +create unique index concurrently on idxpart (a); -- partitioned, unique failure +ERROR: could not create unique index "idxpart2_a_idx2_ccnew" +DETAIL: Key (a)=(10) is duplicated. +\d idxpart This shows that CIC first creates catalog-only INVALID indexes, and then reindexes them to "validate". -- Justin --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0001-Allow-CREATE-INDEX-CONCURRENTLY-on-partitioned-t.patch"