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 1p1uN2-0005up-F1 for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Dec 2022 19:09:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p1uN1-00059r-1y for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Dec 2022 19:09:47 +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 1p1uN0-00059i-Fl for pgsql-hackers@lists.postgresql.org; Sun, 04 Dec 2022 19:09:46 +0000 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p1uMt-0001dd-F3 for pgsql-hackers@lists.postgresql.org; Sun, 04 Dec 2022 19:09:45 +0000 Received: by mail-io1-xd2e.google.com with SMTP id e189so6257066iof.1 for ; Sun, 04 Dec 2022 11:09:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ev6URt1FCs9AmoNz3q+hZnhsYdwXT/3xBNlq8gB+jNA=; b=fjhZdahcXji9Lmp/oYN5nRxnms/t8LzZVuszhr6EWu9CU2kdGc0p3SRhxz97twjaLu i3vGffCRKXwaINWft+3sMcOnR4TsmnF1tBJUN/I+iIbs06Phxnp/h+pj/W956jDtEjW8 d+CB3Gdkksc2fJVpw/mBopp7iAYp98/scwmH7M19mOEUKQrYNmsUslB5qPb5Ea0ODuzX WxBN9dq5Or0S1dlTfvklgTLKOnnGfA9oYyyQCgv+7RHaDZ11Qfp4xnTfY9eglzZ+8VUL d9Jr8AVTkQVTZMgljsLZXDN8O2jos3pg0uq9HstmpdGgJYcudTv7dw2joYJdGWxQ9pyL QmNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ev6URt1FCs9AmoNz3q+hZnhsYdwXT/3xBNlq8gB+jNA=; b=JbBZbcIAgJijPq329O93CFxIu4iPNMPVGQLA9UYijZkcC71WWQvCZ9I/xwSt0Q09D3 dscQW3yAoRyzjDRyv/tSxHW+LkejWF2fup3R+3CRqQSbdOrffMeu1goUSvpnnNgQiqcQ Sm2pnNNbIIN8JfJOTIDVW4pqAUKd/yAYKV5yySnQLKuOVlB24E+d+urtuVPqmpPtWj/X bYK2AhsRDTYjuE894I/jg78mfAPYTPGsWw2s1dfaR695UIPVMOUZ0cWtFjv6q1RAlkSg 3zETcw/QDocdDaAw3ay/B0SRgtSFvYbQcu36ge7ClPiD+l6K7q2AwSDgEGr3RHRQaalz AiRw== X-Gm-Message-State: ANoB5pkF7cWJMLEEqom22/qzFZk8KDgDKv42UsCJUGLhIteOKcJjKJet UPzZmF1cfuKzujlTlKW8WZPrlg== X-Google-Smtp-Source: AA0mqf78/acCBS4ftXfTOB8StAWrtPVcQcSYVlxzrIgUcne71DIHsRGRMB4XX8mweePSKtKyHiJWZg== X-Received: by 2002:a6b:4402:0:b0:6c3:996b:5960 with SMTP id r2-20020a6b4402000000b006c3996b5960mr27013126ioa.169.1670180977731; Sun, 04 Dec 2022 11:09:37 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id y17-20020a056e02119100b00300d3c0e33dsm4560011ili.4.2022.12.04.11.09.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Dec 2022 11:09:36 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id EAF7D800BCE; Sun, 4 Dec 2022 13:09:35 -0600 (CST) Date: Sun, 4 Dec 2022 13:09:35 -0600 From: Justin Pryzby To: Ilya Gladyshev Cc: Alexander Pyhalov , pgsql-hackers@lists.postgresql.org, Masahiko Sawada , Michael Paquier , =?utf-8?B?5p2O5p2wKOaFjui/vSk=?= , =?utf-8?B?5pu+5paH5peMKOS5ieS7jik=?= , Alvaro Herrera Subject: Re: CREATE INDEX CONCURRENTLY on partitioned index Message-ID: <20221204190935.GD14156@telsasoft.com> References: <20201129202221.GA9477@telsasoft.com> <20210128143013.GC7450@telsasoft.com> <20210226182019.GU20769@telsasoft.com> <04657227cc37b6353cf0c72bedac70cc@postgrespro.ru> <20220628183309.GD28130@telsasoft.com> <20221121030011.GU11463@telsasoft.com> <5bafee07d0e1b3ce5359d1656c90b4836d7cb6a1.camel@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="zCKi3GIZzVBPywwA" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5bafee07d0e1b3ce5359d1656c90b4836d7cb6a1.camel@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --zCKi3GIZzVBPywwA Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Dec 03, 2022 at 07:13:30PM +0400, Ilya Gladyshev wrote: > Hi, > > Thank you Justin and Alexander for working on this, I have reviewed and > tested the latest patch, it works well, the problems mentioned > previously are all fixed. I like the idea of sharing code of reindex > and index, but I have noticed some peculiarities as a user.  > > The reporting is somewhat confusing as it switches to reporting for > reindex concurrently while building child indexes, this should be fixed > with the simple patch I have attached. Another thing that I have > noticed is that REINDEX, which is used under the hood, creates new > indexes with suffix _ccnew, and if the index building fails, the > indexes that could not be build will have the name with _ccnew suffix. > This can actually be seen in your test: > > ERROR: could not create unique index "idxpart2_a_idx2_ccnew" > I find it quite confusing and I don't think that this the expected > behavior (if it is, I think it should be documented, like it is for > REINDEX). As an example of problems that it might entail, DROP INDEX > will not drop all the invalid indexes in the inheritance tree, because > it will leave _ccnew indexes in place, which is ok for reindex > concurrently, but that's not how C-I-C works now. I think that fixing > this problem requires some heavy code rewrite and I'm not quite sure This beavior is fixed. I re-factored and re-implented to use DefineIndex() for building indexes concurrently rather than reindexing. That makes the patch smaller, actually, and has the added benefit of splitting off the "Concurrently" part of DefineIndex() into a separate function. This currently handles partitions with a loop around the whole CIC implementation, which means that things like WaitForLockers() happen once for each index, the same as REINDEX CONCURRENTLY on a partitioned table. Contrast that with ReindexRelationConcurrently(), which handles all the indexes on a table in one pass by looping around indexes within each phase. BTW, it causes the patch to fail to apply in cfbot when you send an additional (002) supplementary patch without including the original (001) patch. You can name it *.txt to avoid the issue. https://wiki.postgresql.org/wiki/Cfbot#Which_attachments_are_considered_to_be_patches.3F Thanks for looking. -- Justin --zCKi3GIZzVBPywwA Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Allow-CREATE-INDEX-CONCURRENTLY-on-partitioned-table.patch"