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 1qc7Qt-00Dt8B-J5 for pgsql-bugs@arkaria.postgresql.org; Fri, 01 Sep 2023 16:55:43 +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 1qc7Qs-00Ftj0-1R for pgsql-bugs@arkaria.postgresql.org; Fri, 01 Sep 2023 16:55:41 +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 1qc7Qr-00Ftiq-OF for pgsql-bugs@lists.postgresql.org; Fri, 01 Sep 2023 16:55:41 +0000 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qc7Qo-002Bca-G2 for pgsql-bugs@lists.postgresql.org; Fri, 01 Sep 2023 16:55:40 +0000 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3a5a7e7cd61so106471b6e.0 for ; Fri, 01 Sep 2023 09:55:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693587338; x=1694192138; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Zib6KJkw0v7mAZpOvvqqfPzMnI5n/A8ciNhM94i8Da4=; b=AJjVVpSHMNUDZLCRGF9fVFarZ75Q0shxaSLJtn//ypQbEWrcfv+ryDp782trKJvmla xVMus69Bwv3ofFQNLbR+6dYn6nyq8eBy0pySud/M6d2jMeTTQEgvva37gHGN16JJsqKg l0GtsQ5LhmthgRU+6KwaWqvFyNLLaeJtA57d9DGxKEUNY272AgATkQ9Z9xyeTFueLMNe jEiybpP8J6oDE7wr4GGcf8FSUhYLKUqovITzYdAxyk0x4CtJl5JhtQJY8qUBG2mG9bou p5MaDwIJSZAlHlCeR5c/4uKbZ5t5uBRqn+9zdomHhzKxwumoRSfpaKBuo/uIT7ES9oAR 9flw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693587338; x=1694192138; h=in-reply-to: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=Zib6KJkw0v7mAZpOvvqqfPzMnI5n/A8ciNhM94i8Da4=; b=kKvbk3JVXQICi1wOwbxiZfkwGJ0pXJEVYPSlX5NU3D93jWiKF61pGzm98f8RztSlIT Cff/gbgKOstJ5U2b6wkLm8b4RfJBubXZvzzq6/ab/goKiP5ndcxW4fbrjVOcbw2CrT+K LEBKATVjYxA7/8ucm49N4eAEI1SMvKAAepwFHGkVOUNGeOl2h2dgoN7/LqzBofQaAs3J wpun+4KfjJz2C4nvPv7TPNryzAEq7e3NBT33FTq69n6/3JQB776IFyI9C6AAakSuvfKJ c3Sc+693jqcgn8LXfbjLzm93IVQsncawBS/6ATl4EM0GcDJREs7K0fKLY3AB6w9m7kUB qC8Q== X-Gm-Message-State: AOJu0YxLf4Yi9dQ1AiVmavMV2Wbztbuj9V7RpO4F8iIngi3V35bTwguq cme5/Z/NZGVIonJPrJGqYnc= X-Google-Smtp-Source: AGHT+IE7s+05RD+zlT4WuVbOORPbQK5cagvf4p3EJk1zVONnEJNq/oWhiTBEgyLGXXc5jeGUtKSVDQ== X-Received: by 2002:a05:6808:238d:b0:3a3:6742:35d5 with SMTP id bp13-20020a056808238d00b003a3674235d5mr1931062oib.26.1693587337703; Fri, 01 Sep 2023 09:55:37 -0700 (PDT) Received: from nathanxps13 ([2600:1700:48f8:340f:ed2c:b641:352b:afe1]) by smtp.gmail.com with ESMTPSA id w9-20020a056808018900b003a75748af5esm2164440oic.30.2023.09.01.09.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 09:55:37 -0700 (PDT) Date: Fri, 1 Sep 2023 09:55:35 -0700 From: Nathan Bossart To: Michael Paquier Cc: Gurjeet Singh , Tom Lane , Richard =?iso-8859-1?Q?Vesel=FD?= , pgsql-bugs@lists.postgresql.org Subject: Re: Fwd: BUG #18016: REINDEX TABLE failure Message-ID: <20230901165535.GB3178187@nathanxps13> References: <1867443.1688912310@sss.pgh.pa.us> <20230726175000.GA3259285@nathanxps13> <20230727231441.GB3612597@nathanxps13> <20230728180056.GB3661419@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230728180056.GB3661419@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jul 28, 2023 at 11:00:56AM -0700, Nathan Bossart wrote: > On Fri, Jul 28, 2023 at 10:50:50AM +0900, Michael Paquier wrote: >> On Thu, Jul 27, 2023 at 04:14:41PM -0700, Nathan Bossart wrote: >>> On Wed, Jul 26, 2023 at 06:43:18PM -0700, Gurjeet Singh wrote: >>>> I felt the need for that paragraph, because it doesn't feel obvious to >>>> me as to why we can't simply reindex the toast table as the first >>>> thing in this function; the toast table reindex will trigger CCI, and >>>> that'd be bad if done before RelationGetIndexList(). >>> >>> I see. I'd suggest referencing the comment above the function, but in >>> general I do think having a comment about this is appropriate. >> >> + * This should be done after the suppression of the use of indexes (above), >> + * because the recursive call to reindex_relation() below will invoke >> + * CommandCounterIncrement(), which may prevent enumeration of the indexes >> + * on the table. >> >> This does not explain the reason why this would prevent the creation >> of a consistent index list fetched from the parent table, does it? >> Would some indexes be missing from what should be reindexed? Or some >> added unnecessarily? Would that be that an incorrect list? > > IIUC the issue is that something (e.g., VACUUM FULL, CLUSTER) might've just > rebuilt the heap, so if we CCI'd before gathering the list of indexes, the > new heap contents would become visible, and the indexes would be > inconsistent with the heap. This is a problem when the relation in > question is a system catalog that needs to be consulted to gather the list > of indexes. To handle this, we avoid the CCI until after gathering the > indexes so that the old heap contents appear valid and can be used as > needed. Once that is done, we mark the indexes as pending-rebuild and do a > CCI, at which point the indexes become inconsistent with the heap. This > behavior appears to have been added by commit b9b8831. How do we move this one forward? Michael and I provided some feedback about the comment, but AFAICT this patch is in good shape otherwise. Gurjeet, would you mind putting together a new version of the patch so that we can close on this one? -- Nathan Bossart Amazon Web Services: https://aws.amazon.com