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 1nHly0-0002r0-Gp for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Feb 2022 12:21:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nHlxy-0004jn-6z for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Feb 2022 12:20:58 +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 1nHlxx-0004jZ-U8 for pgsql-hackers@lists.postgresql.org; Wed, 09 Feb 2022 12:20:57 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nHlxv-0007hn-Di for pgsql-hackers@postgresql.org; Wed, 09 Feb 2022 12:20:56 +0000 Received: from mail.postgrespro.ru (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 8D22F21C2A33; Wed, 9 Feb 2022 15:20:54 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1644409254; bh=TG0pBxPCY7Six3n4k7jnkH5edLOY24YuFIUjtEMRWhU=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=pc8SX681giTNBN7jsD9Lw/NKwjknQJDrUDbTQmYFTwO+gJIqxXJlWN2ebgXRj4XQk gBUGWmPq/mp3aq/XhRMdDHjG4yIFn9vg0ZWN+G3x4s8QEfKTc8UJtINJ0c+mSTs6mV ZVEZz6akYyJzljFtBNbhOXvHHpA8jQAPnbG7lK4U= MIME-Version: 1.0 Date: Wed, 09 Feb 2022 15:20:54 +0300 From: Alexander Pyhalov To: Pgsql Hackers Cc: Justin Pryzby Subject: CREATE INDEX CONCURRENTLY on partitioned index In-Reply-To: References: User-Agent: Roundcube Webmail/1.4.11 Message-ID: <15f8831291ed3e736c912836caedda80@postgrespro.ru> X-Sender: a.pyhalov@postgrespro.ru Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alexander Pyhalov писал 2022-02-09 15:18: > Hi. > > I've looked at patches, introducing CREATE INDEX CONCURRENTLY for > partitioned tables - > https://www.postgresql.org/message-id/flat/20210226182019.GU20769%40telsasoft.com#da169a0a518bf8121604437d9ab053b3 > . > The thread didn't have any activity for a year. > > I've rebased patches and tried to fix issues I've seen. I've fixed > reference after table_close() in the first patch (can be seen while > building with CPPFLAGS='-DRELCACHE_FORCE_RELEASE'). Also merged old > 0002-f-progress-reporting.patch and > 0003-WIP-Add-SKIPVALID-flag-for-more-integration.patch. It seems the > first one didn't really fixed issue with progress report (as > ReindexRelationConcurrently() uses pgstat_progress_start_command(), > which seems to mess up the effect of this command in DefineIndex()). > Also third patch completely removes attempts to report create index > progress correctly (reindex reports about individual commands, not the > whole CREATE INDEX). > > So I've added 0003-Try-to-fix-create-index-progress-report.patch, > which tries to fix the mess with create index progress report. It > introduces new flag REINDEXOPT_REPORT_PART to ReindexParams->options. > Given this flag, ReindexRelationConcurrently() will not report about > individual operations, but ReindexMultipleInternal() will report about > reindexed partitions. To make the issue worse, some partitions can be > handled in ReindexPartitions() and ReindexMultipleInternal() should > know how many to correctly update PROGRESS_CREATEIDX_PARTITIONS_DONE > counter, so we pass the number of handled partitions to it. > > I also have question if in src/backend/commands/indexcmds.c:1239 > 1240 oldcontext = MemoryContextSwitchTo(ind_context); > 1239 childidxs = RelationGetIndexList(childrel); > 1241 attmap = > 1242 > build_attrmap_by_name(RelationGetDescr(childrel), > 1243 parentDesc); > 1244 MemoryContextSwitchTo(oldcontext); > > should live in ind_context, given that we iterate over this list of > oids and immediately free it, but at least it shouldn't do much harm. Sorry, messed the topic. -- Best regards, Alexander Pyhalov, Postgres Professional