Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUe86-004cUE-M7 for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jul 2024 03:17:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sUe84-0087PS-KV for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jul 2024 03:17:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUe83-0087PK-6q for pgsql-hackers@lists.postgresql.org; Fri, 19 Jul 2024 03:17:56 +0000 Received: from fhigh3-smtp.messagingengine.com ([103.168.172.154]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUe80-000IiH-EO for pgsql-hackers@lists.postgresql.org; Fri, 19 Jul 2024 03:17:54 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 278E61140291; Thu, 18 Jul 2024 23:17:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 18 Jul 2024 23:17:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1721359071; x=1721445471; bh=8QB7oDcaqE 469DPUA2q5H7LkZJtqIW0IE0ThqSU015w=; b=nMAxeug/BJp38U5JZ8vU/nOcWb s3qi8CNJoGMcbey1rp78wC+ddL2HesDKX7nXoURxNtNHi0sN8o0Ufs3xcaTb9tG8 pB6oren2zkmRI5x6uti6lYdLHYCbi4Zn+NpmPomwwiLFUPgnnIGsDkZ6lTHoko2i 9HScY3PG+Ck4bWziNaUBQ7EBXR2SnntvG3eQaW5wytF5G6XJ7/naAxH2ASumgKSz 6X2KpZASkTph2KNxhd/Od7A4DuVAHvim54xc47nfxiiQCZ4JNKFwBq71/aInzH12 QjSujKbH1dwJ67xGgXYsTKbFN9AyeqBxaeyVjPvL6gUNYUu1xhGQNsqAm/VA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1721359071; x=1721445471; bh=8QB7oDcaqE469DPUA2q5H7LkZJtq IW0IE0ThqSU015w=; b=ASRjt4B4ZH4LpnsZ8UoohN/KVP796Z6VOEtvpd41tx7n qx57cdRoHmx6yww+qw/PkIsQJ4xzxDZh+at0BNcnN1A6bq9iPR3Pwj26fmoNStGr sK87Emg961nzHNXeU+/ltQJLl4PJq7yDL9S/xc1dKeMDekXElHiBlv5kji/CEmmx R4VaZFlipoyPYX+QBIX9X1p1qVMm3LdebkwfV+FcbchTUEOq/j90gQpglyxH35VD hKXlA3foHKXwCP2bNnBTtNgCjjSvBsEDQHZzAaKvowCjVAPA23Z1qujditq4yQ0r nXOjwQF45gPfyoOumDPToe26dXa/dAGtPU0UER9+dg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrhedtgdeilecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt udenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpefgheehgfdufedugfefleegieff geefhfekfeffvdehfedutdehteegleetveekteenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Jul 2024 23:17:49 -0400 (EDT) Date: Fri, 19 Jul 2024 12:17:35 +0900 From: Michael Paquier To: Ilya Gladyshev Cc: pgsql-hackers@lists.postgresql.org Subject: Re: REINDEX not updating partition progress Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ISYzhc31cg+fcTcO" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --ISYzhc31cg+fcTcO Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 12, 2024 at 11:07:49PM +0100, Ilya Gladyshev wrote: > While working on CIC for partitioned tables [1], I noticed that REINDEX f= or > partitioned tables is not tracking keeping progress of partitioned tables, > so I'm creating a separate thread for this fix as suggested. This limitation is not a bug, because we already document that partitions_total and partitions_done are 0 during a REINDEX. Compared to CREATE INDEX, a REINDEX is a bit wilder as it would work on all the indexes for all the partitions, providing this information makes sense. Agreed that this could be better, but what's now on HEAD is not wrong either. > The way REINDEX for partitioned tables works now ReindexMultipleInternal > treats every partition as an independent table without keeping track of > partition_done/total counts, because this is just generic code for > processing multiple tables. The patch addresses that by passing down the > knowledge a flag to distinguish partitions from independent tables > in=A0ReindexMultipleInternal and its callees. I also noticed that the > partitioned CREATE INDEX progress tracking could also benefit from > progress_index_partition_done function that zeroizes params in addition to > incrementing the counter, so I applied it there as well. Still it does not do it because we know that the fields are going to be overwritten pretty quickly anyway, no? For now, we could just do without progress_index_partition_done(), I guess, keeping it to the incrementation of PROGRESS_CREATEIDX_PARTITIONS_DONE. There's an argument that this makes the code slightly easier to follow, with less wrappers around the progress reporting. + int progress_params[3] =3D { + PROGRESS_CREATEIDX_COMMAND, + PROGRESS_CREATEIDX_PHASE, + PROGRESS_CREATEIDX_PARTITIONS_TOTAL + }; + int64 progress_values[3]; + Oid heapId =3D relid; Rather than having new code blocks, let's use a style consistent with DefineIndex() where we have the pgstat_progress_update_multi_param(), with a single {} block. Adding the counter increment at the end of the loop in ReindexMultipleInternal() is a good idea. It considers both the concurrent and non-concurrent cases. + progress_values[2] =3D list_length(partitions); + pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX, heapId); Hmm. Is setting the relid only once for pg_stat_progress_create_index the best choice there is? Could it be better to report the partition OID instead? Let's remember that indexes may have been attached with names inconsistent with the partitioned table's index. It is a bit confusing to stick to the relid all the partitioned table all the time, for all the indexes of all the partitions reindexed. Could it be better to actually introduce an entirely new field to the progress table? What I would look for is more information: 1) the partitioned table OID on which the REINDEX runs 2) the partition table being processed 3) the index OID being processed (old and new for concurrent case). The patch sets 1) to the OID of the partitioned table, lacks 2) and sets 3) each time an index is rebuilt. -- Michael --ISYzhc31cg+fcTcO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmaZ2s8ACgkQnvQgOdby QH0+8Q/+KWcGNPG+q3bgnhHcHoj1lNR2+I+waJX7iz5ITo6NkLTpO4xIu4W5tRwR M+mo4CjF2gjPpVggjhog3Qyku570jRtL/OE0uwBz5yg9T4gag4y+HCiAXoP8jSFd Hx1wualcpHECoQAGqyBfhVXHXFcn6LY2L3xRwndgT7t6CKtIDH34elUj0HBes8B9 db3yXVdFZeoWMLg3VgY6zi+VY3UkySpMk7KxOdvOLO2xC+6f5yBq5Zqj/6taHwL/ u46ReD0ujgYjuq3kYAyCzOJjO2/b4d8A1qXIESSppSFT7tExUB0JutwBl0CkqCJ9 UN9/yLbVoQ6rwAuCEYQBS5PxhDIhrQgk99JlBsil4alTjg/0jYAaC+75lEihJj9N Z4c6/UJZe9UnEVDcIOt20ypsxwFquUH621FGkDU6AEWI9FMGOWz2fAEphuIQg+bq l0C1huE3d8bDBmB/j6uWjJBCsdjYNF5Xg8itCnbft85GKsu8nQBfClz5Xf7/Z54H m3tS+Y/OrGmKCxoH8g/DxkXelRpSqZ2fnXhP/ZX/vSQnJ2gtNOQXoPIrtMFFXrcf LUmAT8YlpsNaGvG9PaCdtwFyNjM4+tMRDUn86IyHZcXN1/dN0eMDSWYHej5nOI3z YzshGV+YZUp56SfvGRwHS/FbDza5/2vuEnwe2CzoHRdG8cGGb1s= =jXpw -----END PGP SIGNATURE----- --ISYzhc31cg+fcTcO--