Re: Fwd: BUG #18016: REINDEX TABLE failure

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Gurjeet Singh <gurjeet@singh.im>, Tom Lane <tgl@sss.pgh.pa.us>, Richard Veselý <richard.vesely@softea.sk>, pgsql-bugs@lists.postgresql.org
Date: 2023-07-28T01:50:50Z
Lists: pgsql-bugs, pgsql-hackers
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?
--
Michael

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Reindex toast before its main relation in reindex_relation()

  2. Fix comment in index.c

  3. Clean up a bug in sql/json items commit 66ea94e8e6

  4. Create a "relation mapping" infrastructure to support changing the relfilenodes