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 1kjTGa-00033e-Bs for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Nov 2020 20:25:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kjTGW-00037o-HE for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Nov 2020 20:25:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kjTDO-00071O-Ai for pgsql-hackers@lists.postgresql.org; Sun, 29 Nov 2020 20:22:34 +0000 Received: from mail-io1-xd43.google.com ([2607:f8b0:4864:20::d43]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kjTDF-0002uj-AF for pgsql-hackers@lists.postgresql.org; Sun, 29 Nov 2020 20:22:33 +0000 Received: by mail-io1-xd43.google.com with SMTP id z136so9768741iof.3 for ; Sun, 29 Nov 2020 12:22:25 -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=GqPBbBoVssX9ASkxm77dJFXV/HvdSUWPxSnWq1Z8pzI=; b=yLAVlBA+W9vYln1QMy5rnq6mzGs3b/XSZ1HMbMF4ZmmiSR+r/bJdzX47zv1JCUYKve zThfKs+qtQut610Cgt6CyjycLzChjd8CS/qXzIR9dfhm/pt9a6yCuMCFpLIlUMlRqR+x xxDGbuO2Q5i0ShWfIxjeQNBadV+VYqJso2HcB7JEXUf8DCikyFWGvg/t2qZlnjg3H2lx pYne8AYhmU3Hb8wo9ASLUdG9V85q0sS+SioJhfdwhlr9X/mLdYr/Gqi5UHXit0fegU+H O0hdaXNBf3ER//rDOq58FDyFZj4JUbV7ggP2xkyPT+HOz5tiUP4nAksEhBvao+vLJ1tr 4uCg== 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=GqPBbBoVssX9ASkxm77dJFXV/HvdSUWPxSnWq1Z8pzI=; b=d1MLlrTWOMzleLI0dqIsQ2BJW0EIE3Z8avwTeLDNSt3svQT4PZdNdg5QLW31UZXxQE 9m9p/AiwmCpWc+nqzGXxgo+7o9FimENDpXjdg+rw0Xbnq52sglV1PF0QPN9tE4b16wAx iVw9vBb6qDcDMzaLn5qqVoCVKdjkm5mvb1CjFpUFgRiFF01/2Vg2Xz2k1I7tfgOK3piv tnA8YP2/6tBLPi5GTsdDJZ5UT/pKSQHnebQeIQ7Ai/aVRPuay8kTBMZDqllCGULaE6UP 1GTqd46J6MDHgwbbeW4gdKGoNpiX0xdAWRdhUSzfbJcSfrY9Oacxkt0tpQnI1SSMycfr Atwg== X-Gm-Message-State: AOAM5320VQkVP2F7zMYhaPlN7DmTFv6ATDmB4LJDE7A5t/jfXQc4roue yMDcU41rlIsBIvAmcfZY0rVthg== X-Google-Smtp-Source: ABdhPJxv1AL7dUJ/mV1obY5YWhc74IMsEQsfRrxQY0L18XPTJQ+Esq/0UYdwhOJTlzMbjxqljfxqqw== X-Received: by 2002:a02:9708:: with SMTP id x8mr15833712jai.43.1606681343753; Sun, 29 Nov 2020 12:22:23 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id f73sm9892913ilh.7.2020.11.29.12.22.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Nov 2020 12:22:22 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id EE5948010AF; Sun, 29 Nov 2020 14:22:21 -0600 (CST) Date: Sun, 29 Nov 2020 14:22:21 -0600 From: Justin Pryzby To: Michael Paquier Cc: =?utf-8?B?5p2O5p2wKOaFjui/vSk=?= , pgsql-hackers , =?utf-8?B?5pu+5paH5peMKOS5ieS7jik=?= , Alvaro Herrera Subject: Re: CREATE INDEX CONCURRENTLY on partitioned index Message-ID: <20201129202221.GA9477@telsasoft.com> References: <20201031063117.GF3080@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="cWoXeonUoKmBZSoM" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201031063117.GF3080@telsasoft.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --cWoXeonUoKmBZSoM Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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: > > > On Mon, Jun 15, 2020 at 08:15:05PM +0800, 李杰(慎追) wrote: > > > > As shown above, an error occurred while creating an index in the second partition. > > > > It can be clearly seen that the index of the partitioned table is invalid > > > > and the index of the first partition is normal, the second partition is invalid, > > > > and the Third Partition index does not exist at all. > > > > > > That's a problem. I really think that we should make the steps of the > > > concurrent operation consistent across all relations, meaning that all > > > the indexes should be created as invalid for all the parts of the > > > partition tree, including partitioned tables as well as their > > > partitions, in the same transaction. Then a second new transaction > > > gets used for the index build, followed by a third one for the > > > validation that switches the indexes to become valid. > > > > 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". @cfbot: rebased over recent changes to indexcmds.c -- Justin --cWoXeonUoKmBZSoM Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v11-0001-Allow-CREATE-INDEX-CONCURRENTLY-on-partitioned-t.patch"